/* ============================================================
   RYAN J. XU — frame
   Structure only. Copy + imagery live in js/config.js
   ============================================================ */

@font-face {
  font-family: "Accent";
  src: url("../accent.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

:root {
  --bg: #ffffff;
  --ink: #0d0d0d;
  --ink-soft: #8a8a8a;
  --hair: rgba(13, 13, 13, 0.14);

  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-brd: rgba(13, 13, 13, 0.12);
  --glass-shadow: 0 8px 32px rgba(13, 13, 13, 0.10);

  --ui: "Courier New", Courier, monospace;

  --title-size: clamp(2.25rem, 7.6vw, 8.5rem);
  --title-ls: 0.02em;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* "toggle vision" — the analytic view: structure over surface */
body.vision {
  --bg: #0c0d0f;
  --ink: #e9ffe4;
  --ink-soft: #4f7a52;
  --hair: rgba(120, 255, 140, 0.22);
  --glass-bg: rgba(20, 30, 22, 0.42);
  --glass-brd: rgba(120, 255, 140, 0.24);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  cursor: default;
  transition: background 260ms var(--ease), color 260ms var(--ease);
}

/* ── stage ─────────────────────────────────────────────── */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#mosaic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  pointer-events: none;
}

#title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  white-space: nowrap;
  font-family: var(--ui);
  font-size: var(--title-size);
  font-weight: 400;
  letter-spacing: var(--title-ls);
  line-height: 1;
  will-change: transform;
  user-select: none;
}

/* the char spans are written by js so we can measure the first letter */
#title .ch {
  display: inline;
}

/* zero-size inline-block: its bottom edge sits exactly on the baseline */
#title .baseline-ref {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: baseline;
}

/* ── home (reset zoom) ─────────────────────────────────── */

#home-btn {
  position: fixed;
  top: 26px;
  left: 26px;
  z-index: 50; /* above the font-dock hover strip it sits inside */
  padding: 10px 15px;
  border: 1px solid var(--glass-brd);
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--glass-shadow);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease),
    background 260ms var(--ease), opacity 240ms var(--ease);
}

#home-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#home-btn:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

/* ── toggle vision ─────────────────────────────────────── */

#vision-toggle {
  position: fixed;
  top: 26px;
  right: 26px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border: 1px solid var(--glass-brd);
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--glass-shadow);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease),
    background 260ms var(--ease);
}

#vision-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

#vision-toggle .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: transparent;
  transition: background 220ms var(--ease), box-shadow 220ms var(--ease);
}

#vision-toggle[aria-pressed="true"] .dot {
  background: var(--ink);
  box-shadow: 0 0 10px var(--ink);
}

/* ── bracket cursor: [ ] stands in for the pointer everywhere,
      not just in vision mode ─────────────────────────────── */

body,
body * {
  cursor: none !important;
}

#vision-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: block;
  pointer-events: none;
  transform: translate(-100vw, -100vh);
  font: 700 24px/1 "Courier New", Courier, monospace;
  letter-spacing: 0.08em;
  color: #ffffff;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.4);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 255, 255, 0.5);
  white-space: pre;
  user-select: none;
}

/* in vision mode, match the theme's ink color instead */
body.vision #vision-cursor {
  color: var(--ink);
  -webkit-text-stroke: 0;
  text-shadow: 0 0 6px color-mix(in srgb, var(--ink) 55%, transparent);
}

/* ── vision calibration popup: centered, self-dismissing ── */

#calibrate-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 80;
  transform: translate(-50%, -50%) translateY(6px) scale(0.98);
  padding: 18px 26px;
  border-radius: 16px;
  border: 1px solid var(--glass-brd);
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.1),
      rgba(255, 255, 255, 0) 45%
    ),
    var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: var(--ink);
  font: 600 15px/1.4 var(--ui);
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}

#calibrate-popup.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0) scale(1);
}

#calibrate-popup .sub {
  margin-top: 6px;
  font: 500 12px/1.4 var(--ui);
  letter-spacing: 0.02em;
  opacity: 0.6;
}

/* ── help: floating instructions ───────────────────────── */

#help-btn {
  position: fixed;
  right: 26px;
  bottom: 64px;
  z-index: 45;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-brd);
  border-radius: 50%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--glass-shadow);
  color: var(--ink);
  font: 700 14px/1 var(--ui);
  cursor: pointer;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease);
}

#help-btn:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

#help-panel {
  position: fixed;
  right: 26px;
  bottom: 110px;
  z-index: 60;
  width: min(400px, 88vw);
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding: 22px 22px 18px;
  border-radius: 20px;
  border: 1px solid var(--glass-brd);
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.1),
      rgba(255, 255, 255, 0) 45%
    ),
    var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: var(--ink);
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}

#help-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* animated iridescent ring around the rounded corners — the
   "holographic" edge — via a masked conic-gradient border */
#help-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    #ff9df0,
    #9dffe9,
    #9db7ff,
    #ffe89d,
    #ff9df0
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.55;
  animation: holo-spin 8s linear infinite;
  pointer-events: none;
}

@keyframes holo-spin {
  to {
    filter: hue-rotate(360deg);
  }
}

#help-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#help-close:hover {
  color: var(--ink);
}

#help-panel h2 {
  margin: 0 22px 14px 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

#help-panel dl {
  margin: 0;
}

#help-panel .help-row {
  padding: 10px 0;
  border-top: 1px solid var(--hair);
}

#help-panel .help-row:first-child {
  border-top: 0;
  padding-top: 0;
}

#help-panel dt {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

#help-panel dd {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

#help-panel .bracket {
  color: #34c95f;
  font-weight: 700;
}

#help-panel kbd {
  font: 700 11px var(--ui);
  padding: 1px 5px;
  border: 1px solid var(--glass-brd);
  border-radius: 4px;
}

/* ── font dock (left edge, hidden until proximity) ─────── */

/* the dock's own box is the hover region: a thin strip at rest,
   widening to hold the revealed menu so the pointer stays inside */
#font-dock {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 30;
  pointer-events: auto;
}

#font-dock.revealed {
  width: min(320px, 70vw);
}

/* faint affordance so the edge reads as interactive; gone once open */
#font-dock::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 132px;
  background: var(--ink);
  opacity: 0.18;
  transition: opacity 240ms var(--ease), height 240ms var(--ease);
}

#font-dock:hover::before,
#font-dock.revealed::before {
  opacity: 0;
  height: 40px;
}

#font-wheel {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  padding-left: 26px;
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
  transition: opacity 360ms var(--ease), transform 420ms var(--ease);
}

#font-dock.revealed #font-wheel {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

#font-wheel h2 {
  margin: 0;
  padding: 3px 12px 3px 0;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.15;
  white-space: nowrap;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  transform-origin: 0% 50%; /* grow rightward from the left edge */
  will-change: transform, opacity;
  /* short easing smooths per-frame magnify without lagging the cursor */
  transition: transform 110ms var(--ease), opacity 110ms var(--ease),
    letter-spacing 300ms var(--ease);
}

#font-wheel h2::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 1px;
  margin-right: 0;
  vertical-align: middle;
  background: var(--ink);
  transition: width 320ms var(--ease), margin-right 320ms var(--ease);
}

#font-wheel h2:hover::before,
#font-wheel h2.is-active::before {
  width: 22px;
  margin-right: 11px;
}

#font-wheel h2.is-active {
  letter-spacing: 0.22em;
}

/* ── zoom bar (right) ──────────────────────────────────── */

#zoom-bar {
  position: fixed;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

#zoom-bar .glass {
  padding: 10px 9px;
  border: 1px solid var(--glass-brd);
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--glass-shadow);
  transition: background 260ms var(--ease), border-color 260ms var(--ease);
}

#zoom-bar .track {
  position: relative;
  width: 6px;
  height: min(42vh, 340px);
  border-radius: 999px;
  background: rgba(13, 13, 13, 0.08);
  overflow: visible;
}

body.vision #zoom-bar .track {
  background: rgba(120, 255, 140, 0.12);
}

#zoom-bar .fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  border-radius: 999px;
  background: var(--ink);
}

/* the mark where the word hits the screen edge and becomes a mosaic */
#zoom-bar .threshold {
  position: absolute;
  left: -7px;
  right: -7px;
  bottom: 0;
  height: 1px;
  background: var(--ink);
  opacity: 0.5;
}

#zoom-bar .threshold::after {
  content: "";
  position: absolute;
  right: -9px;
  top: -2px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--ink);
  transform: rotate(45deg);
  background: var(--bg);
}

#zoom-bar .ticks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to top,
    var(--hair) 0 1px,
    transparent 1px 10%
  );
  opacity: 0.9;
  pointer-events: none;
}

#zoom-bar .readout {
  font-size: 11px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

#zoom-bar .readout .x {
  opacity: 0.45;
  margin-left: 1px;
}

#zoom-bar .caption {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--ink-soft);
  writing-mode: vertical-rl;
}

/* ── colophon + hint ───────────────────────────────────── */

#colophon {
  position: fixed;
  left: 26px;
  right: 26px;
  bottom: 20px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  pointer-events: none;
}

#scroll-hint {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 20px;
  letter-spacing: 0.3em;
  color: var(--ink-soft);
  pointer-events: none;
  transition: opacity 400ms var(--ease);
}

#scroll-hint span {
  animation: breathe 2.6s ease-in-out infinite;
  display: inline-block;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.is-hidden {
  opacity: 0 !important;
}

@media (max-width: 720px) {
  #zoom-bar .caption {
    display: none;
  }
  #colophon .slot[data-slot="center"] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
