/* ==========================================================================
   WRITE LINK — Fixed bottom-right link to /write/
   Inherits the same position and aesthetic as the former ASK toggle
   ========================================================================== */

.write-link {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;

  padding: 8px 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
  overflow: visible;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 400;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;

  opacity: 0;
  transform: translateY(8px);
  /* Beat 5 in the reveal sequence (see .section-dots in styles.css).
     Delay/duration come from the motion tokens in styles.css :root
     (--beat × 4, --dur-beat). Color transitions stay fast for scroll
     dark/light switching; only opacity and transform carry the delay. */
  transition:
    color 0.5s ease,
    opacity var(--dur-beat, 0.7s) var(--ease-fade, ease) calc(var(--beat, 0.4s) * 4),
    transform var(--dur-beat, 0.7s) var(--ease-fade, ease) calc(var(--beat, 0.4s) * 4);
  pointer-events: none;
}

/* Typewriter: WRITE → phrases on hover/focus/tap */
.write-link-short {
  transition: opacity 0.3s ease;
}

.write-link-long {
  position: absolute;
  right: 12px;
  bottom: 8px;
  white-space: nowrap;
  pointer-events: none;
}

/* Hide WRITE label when typewriter is active */
.write-link.typing .write-link-short {
  opacity: 0;
}

/* Only appear after hero entrance completes (JS adds .hero-settled to body) */
body.hero-settled .write-link {
  pointer-events: auto;
}

/* Light text on dark backgrounds */
body.hero-settled.on-dark .write-link {
  color: rgba(255, 255, 255, 0.78);
  opacity: 1;
  transform: translateY(0);
}

body.hero-settled.on-dark .write-link:hover {
  color: rgba(255, 255, 255, 0.95);
}

/* Dark text on light backgrounds — 0.62 alpha keeps the whisper
   but clears 4.5:1 on white (WCAG 1.4.3) */
body.hero-settled.on-light .write-link {
  color: rgba(0, 0, 0, 0.62);
  opacity: 1;
  transform: translateY(0);
}

body.hero-settled.on-light .write-link:hover {
  color: rgba(0, 0, 0, 0.85);
}

.write-link:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .write-link {
    bottom: 12px;
    right: 12px;
    /* Scales down on very narrow phones so the typewriter phrase
       doesn't extend past the viewport's left edge (clipped by
       body overflow:hidden). 320px stays inside even at the 8px floor. */
    font-size: clamp(8px, 2.5vw, 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .write-link {
    transition: color 0.5s ease;
    transform: none;
  }
}

@media (prefers-contrast: more) {
  body.hero-settled.on-dark .write-link { color: #fff; }
  body.hero-settled.on-light .write-link { color: #000; }
}

@media print {
  .write-link {
    display: none !important;
  }
}

/* Page exit fade */
body.page-exit {
  opacity: 0 !important;
  transition: opacity 0.18s ease-out !important;
}
body.page-enter {
  opacity: 0;
}
body.page-enter.page-enter-active {
  opacity: 1;
  transition: opacity 0.22s ease-in;
}
