/* ---------- Tokens ---------- */
:root {
  --ink:       #1a1a1a;
  --charcoal:  #2c2c2a;
  --stone:     #6b6a65;
  --fog:       #b5b3ad;
  --linen:     #e8e5df;
  --parchment: #f4f1eb;
  --signal:    #c23a3a;
  --ember:     #8a2828;

  /* Accessibility-tuned variants of the brand neutrals.
     stone-soft: WCAG AA on ink (≥4.5:1), used for body text on dark bg.
     stone-deep: WCAG AA on linen (≥4.5:1), used for form labels.
     signal-bright: WCAG AA on ink, used for CTA hover state only. */
  --stone-soft:    #9c9a94;
  --stone-deep:    #5b5a55;
  --signal-bright: #e35353;

  --font-display: 'Syne', 'Trebuchet MS', sans-serif;
  --font-body:    'Space Grotesk', 'Arial', sans-serif;
  --font-mono:    'Space Mono', 'Courier New', monospace;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Custom cursor ----------
   A small static red dot that tracks the pointer 1:1. No halo, no smoothing,
   no animation. Inverts to ink color over the red flood / modal state. */
@media (hover: hover) and (pointer: fine) {
  body,
  a, button, input, textarea, [role="button"] { cursor: none; }

  .cursor {
    position: fixed;
    left: 0;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--signal);
    opacity: 0.9;
    pointer-events: none;
    z-index: 9999;
    transform: translate3d(-100px, -100px, 0);
    will-change: transform;
  }

  /* Inverted state: ink dot for the red flood / modal */
  .cursor.is-inverted { background: var(--ink); }
}

@media (hover: none) or (pointer: coarse) {
  .cursor { display: none; }
}

/* ---------- Stage / resting state ---------- */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  padding: 2rem;
}

/* The wordmark + subtext sit centered; the CTA pins to the bottom of the stage */
.stage__center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(32px, 7vw, 64px);
  letter-spacing: 0.22em;
  color: var(--parchment);
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  white-space: nowrap;
}

/* Subtext under the wordmark — quiet descriptor */
.subtext {
  margin: 0.9rem 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: lowercase;
  color: var(--stone-soft);
  /* nudge to align with wordmark center given letter-spacing on the right */
  padding-left: 0.32em;
}

.wordmark__text {
  display: inline-block;
}

/* Animated period — single glowing red dot beside the wordmark */
.wordmark__period {
  position: relative;
  display: inline-block;
  width: 0.18em;
  height: 0.18em;
  margin-left: 0.08em;
  border-radius: 50%;
  background: var(--signal);
  /* sit on baseline like a real period */
  transform: translateY(-0.04em);
  animation: wordmarkPeriod 2.8s ease-in-out infinite;
}

/* Soft glow halo around the period */
.wordmark__period::before {
  content: '';
  position: absolute;
  inset: -90%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194,58,58,0.55) 0%, rgba(194,58,58,0.18) 45%, rgba(194,58,58,0) 75%);
  animation: wordmarkGlow 2.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes wordmarkPeriod {
  0%, 100% { opacity: 0.55; transform: translateY(-0.04em) scale(1);    }
  50%      { opacity: 1;    transform: translateY(-0.04em) scale(1.18); }
}
@keyframes wordmarkGlow {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.1);  }
}

/* ---------- CTA ---------- */
.cta {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--stone-soft);
  transition: color 300ms ease;
  padding: 14px 4px;
}

.cta__label {
  display: inline-block;
  white-space: nowrap;
  /* Reserve final width so the surrounding rules don't reflow as letters land */
  min-width: 0;
}

/* Blinking caret while the label is typing */
.cta__label::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: currentColor;
  opacity: 0;
  animation: ctaCaret 1.1s steps(1) infinite;
}
.cta.is-typing .cta__label::after,
.cta.is-typing-done .cta__label::after { opacity: 1; }
.cta.is-typing-done .cta__label::after { animation-duration: 1.4s; }

@keyframes ctaCaret {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.cta:hover,
.cta:focus-visible { color: var(--signal-bright); }

.cta:focus-visible { outline: 2px solid var(--signal-bright); outline-offset: 6px; }

/* ---------- Parchment layer ---------- */
.parchment {
  position: fixed;
  inset: 0;
  background: var(--parchment);
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease 300ms;
  z-index: 2;
}
.parchment.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ---------- Ink flood layer (sprite) ---------- */
.ink-layer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  height: 100%;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
}

.ink-layer.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Solid red underlay — guarantees full coverage once ink is fully flooded.
   Opacity is driven by JS so the timing aligns with the sprite animation. */
.ink-layer__solid {
  position: absolute;
  inset: 0;
  background: var(--signal);
  opacity: 0;
  pointer-events: none;
}

.ink-layer__bg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate3d(-2%, -50%, 0);
  /* Dimensions overwritten by JavaScript to proportionally fit viewport */
  height: 100%;
  width: 2500%;
  /* Sprite is a 25-frame black ink PNG; mask it and fill with signal red */
  background: var(--signal);
  -webkit-mask-image: url('ink-sprite.png');
          mask-image: url('ink-sprite.png');
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: 0 0;
          mask-position: 0 0;
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
  will-change: transform;
}

.ink-layer.is-opening .ink-layer__bg {
  animation: inkFill 800ms steps(24) forwards;
}

.ink-layer.is-closing .ink-layer__bg {
  animation: inkFillReverse 600ms steps(24) forwards;
}

@keyframes inkFill {
  0%   { transform: translate3d(-2%,  -50%, 0); }
  100% { transform: translate3d(-98%, -50%, 0); }
}
@keyframes inkFillReverse {
  0%   { transform: translate3d(-98%, -50%, 0); }
  100% { transform: translate3d(-2%,  -50%, 0); }
}

/* Hold state — keep last frame painting the viewport */
.ink-layer.is-holding .ink-layer__bg {
  transform: translate3d(-98%, -50%, 0);
  animation: none;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease;
}

.modal[hidden] { display: none; }

.modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.modal__card {
  position: relative;
  background: var(--parchment);
  border: 1px solid var(--fog);
  border-radius: 8px;
  padding: 2rem 2rem 1.5rem;
  max-width: 400px;
  width: 90%;
}

.modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
  color: var(--stone);
  transition: color 200ms ease;
  padding: 6px 8px;
}
.modal__close:hover,
.modal__close:focus-visible { color: var(--signal); }
.modal__close:focus-visible { outline: 1px dashed var(--signal); outline-offset: 2px; }

.modal__title {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
}

.modal__dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
  margin-left: 3px;
  /* Sit on the baseline like a real period */
  vertical-align: baseline;
  transform: translateY(0.05em);
}

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 0.9rem; }

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--stone-deep);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field textarea {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--linen);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 200ms ease;
}

.field input { height: 36px; }
.field textarea { height: 80px; resize: none; }

.field input:focus,
.field textarea:focus {
  border-color: var(--signal);
}

.form__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.submit {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--parchment);
  background: var(--signal);
  border-radius: 4px;
  padding: 10px 28px;
  transition: background-color 200ms ease;
}

.submit:hover,
.submit:focus-visible { background: var(--ember); }
.submit:focus-visible { outline: 1px dashed var(--ember); outline-offset: 3px; }

/* ---------- Sent confirmation ---------- */
.sent {
  display: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--ink);
  padding: 1rem 0 0.25rem;
  align-items: baseline;
  justify-content: center;
}
.sent:not([hidden]) { display: inline-flex; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .modal__card { padding: 1.5rem 1.25rem 1.25rem; }
  .cta { bottom: 6vh; font-size: 11px; }
  .subtext { font-size: 10px; letter-spacing: 0.28em; }

  /* Larger touch target for the close button (≥44×44) */
  .modal__close {
    top: 2px;
    right: 2px;
    min-width: 44px;
    min-height: 44px;
    padding: 12px 16px;
    font-size: 22px;
  }

  /* Inputs at 16px to prevent iOS zoom-on-focus, with taller hit area */
  .field input,
  .field textarea { font-size: 16px; }
  .field input { height: 44px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .wordmark__period,
  .wordmark__period::before { animation: none; opacity: 0.85; }
  .ink-layer.is-opening .ink-layer__bg,
  .ink-layer.is-closing .ink-layer__bg { animation: none; }
  .ink-layer.is-visible { transition: opacity 200ms ease; }
  .cursor { transition: none; }
}
