/* Nib orb page: page chrome around the WebGL scene (module D). The void itself is drawn by scene.js. */
:root {
  --void: #07060a;
  --void-2: #0d0a10;
  --ink: #e8ecf4;
  --amber: #ffcf9a;
  --heart: #ffb070;
  --dim: rgba(232, 236, 244, .34);
  --dimmer: rgba(232, 236, 244, .2);
  --hair: rgba(255, 236, 216, .09);
  --glass: rgba(18, 14, 20, .66);
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --ease: cubic-bezier(.22, .9, .24, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --gutter: max(16px, env(safe-area-inset-left));
  --gutter-r: max(16px, env(safe-area-inset-right));
  --gutter-b: max(16px, env(safe-area-inset-bottom));
  /* tunables: set to 0 to switch off if scene.js already does its own */
  --vignette: .62;
  --grain: .055;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 42%, var(--void-2) 0%, var(--void) 62%) fixed, var(--void);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
a { color: inherit; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* keyboard way into Nib's PC: invisible until focused */
.pcbtn { position: absolute; left: 0; bottom: 100%; margin-bottom: 8px; opacity: 0; pointer-events: none;
  font: 500 12px/1 "IBM Plex Mono", ui-monospace, monospace; color: #e8ecf4; background: rgba(12,10,16,.8);
  border: 1px solid rgba(255,207,154,.35); border-radius: 6px; padding: 6px 9px; white-space: nowrap; }
.pcbtn:focus-visible { opacity: 1; pointer-events: auto; }
:focus-visible { outline: 1px solid rgba(255, 207, 154, .7); outline-offset: 3px; border-radius: 6px; }

/* ---------- layers */
#stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  display: block; z-index: 0; outline: none; cursor: default;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.letters {
  position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden;
  user-select: none; -webkit-user-select: none; contain: layout style;
  font-family: var(--mono);
}
.vignette {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 46%, transparent 48%, rgba(3, 2, 5, var(--vignette)) 100%);
}
.grain {
  position: fixed; inset: -60%; z-index: 3; pointer-events: none; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  animation: grain 1.1s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 17% { transform: translate(-4%, 3%); } 33% { transform: translate(3%, -5%); }
  50% { transform: translate(-6%, -2%); } 67% { transform: translate(5%, 4%); } 83% { transform: translate(-2%, 6%); }
  100% { transform: translate(0, 0); }
}

/* invisible input that raises the phone keyboard; sits on the typing line so iOS does not scroll */
.tapform { position: fixed; left: 50%; bottom: 28%; width: 2px; height: 2px; margin: 0; z-index: 1; overflow: hidden; }
.tapin {
  position: absolute; left: 0; top: 0; width: 2px; height: 2px; padding: 0; border: 0;
  font-size: 16px; opacity: 0; color: transparent; background: transparent; caret-color: transparent;
  outline: none; -webkit-appearance: none; appearance: none;
}

/* ---------- intro veil */
.veil {
  position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; align-content: center; gap: 18px;
  background: var(--void); pointer-events: none;
  transition: opacity 1.8s var(--ease) .15s, visibility 0s linear 2s;
}
.veil-word {
  font: italic 300 clamp(40px, 7vw, 64px)/1 var(--serif); font-variation-settings: 'opsz' 144;
  color: var(--amber); opacity: .0; letter-spacing: -.01em;
  animation: veil-in 1.4s var(--ease) .25s forwards;
  text-shadow: 0 0 28px rgba(255, 176, 112, .35);
}
.veil-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--heart); justify-self: center;
  box-shadow: 0 0 18px 4px rgba(255, 176, 112, .45);
  animation: veil-dot 2.4s ease-in-out infinite;
}
@keyframes veil-in { to { opacity: .82; } }
@keyframes veil-dot { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: .9; transform: scale(1.15); } }
body.ready .veil, body.fallen .veil { opacity: 0; visibility: hidden; }

/* ---------- corner chrome */
.corner {
  position: fixed; bottom: var(--gutter-b); z-index: 5; display: flex; align-items: center; gap: 12px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 1.4s var(--ease) 1.2s, transform 1.4s var(--ease) 1.2s;
}
body.ready .corner { opacity: 1; transform: none; }
.corner.bl { left: var(--gutter); }
.corner.br { right: var(--gutter-r); }

.mark {
  display: inline-flex; align-items: baseline; gap: 9px; padding: 6px 8px 6px 4px; margin: -6px -8px -6px -4px;
  background: none; border: 0; cursor: pointer; color: var(--dim);
  transition: color .5s var(--ease);
}
.mark .word {
  font: italic 400 21px/1 var(--serif); font-variation-settings: 'opsz' 72; letter-spacing: -.01em;
  color: rgba(255, 207, 154, .55); transition: color .5s var(--ease), text-shadow .5s var(--ease);
}
.mark .q {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--dimmer); font: 500 10px/1 var(--mono); transform: translateY(-3px);
  transition: border-color .5s var(--ease), color .5s var(--ease), transform .5s var(--spring);
}
.mark:hover .word, .mark:focus-visible .word { color: var(--amber); text-shadow: 0 0 18px rgba(255, 176, 112, .45); }
.mark:hover .q, .mark:focus-visible .q { border-color: rgba(255, 207, 154, .5); color: var(--amber); transform: translateY(-3px) rotate(-8deg) scale(1.08); }

.meta {
  display: inline-flex; align-items: center; gap: 8px;
  font: 400 11px/1 var(--mono); letter-spacing: .06em; color: var(--dimmer);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: color .5s var(--ease);
}
.corner.br:hover .meta { color: var(--dim); }
.meta a { color: rgba(255, 207, 154, .55); text-decoration: none; border-bottom: 1px solid rgba(255, 207, 154, .25); }
.meta a:hover { color: var(--amber); }
.pip {
  width: 5px; height: 5px; border-radius: 50%; background: rgba(232, 236, 244, .25); flex: none;
  transition: background .8s var(--ease), box-shadow .8s var(--ease);
}
.pip.live { background: #ffb070; box-shadow: 0 0 8px 1px rgba(255, 176, 112, .55); animation: pip 3.2s ease-in-out infinite; }
.pip.nap { background: rgba(160, 170, 210, .45); }
.pip.load { background: rgba(255, 207, 154, .6); animation: pip 1.2s ease-in-out infinite; }
.pip.err { background: rgba(255, 120, 110, .65); }
@keyframes pip { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.mute {
  width: 30px; height: 30px; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .02); border: 1px solid var(--hair); color: var(--dim); cursor: pointer;
  transition: color .4s var(--ease), border-color .4s var(--ease), background .4s var(--ease), transform .4s var(--spring);
}
.mute:hover { color: var(--ink); border-color: rgba(255, 236, 216, .22); background: rgba(255, 255, 255, .05); }
.mute:active { transform: scale(.92); }
.mute svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mute .spk { fill: currentColor; fill-opacity: .18; }
.mute .slash { opacity: 0; }
.mute[aria-pressed="true"] .wave { opacity: 0; }
.mute[aria-pressed="true"] .slash { opacity: 1; }

/* ---------- glass overlay */
.glass {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(90% 80% at 50% 50%, rgba(7, 6, 10, .28), rgba(7, 6, 10, .74));
  -webkit-backdrop-filter: blur(16px) saturate(1.15); backdrop-filter: blur(16px) saturate(1.15);
  opacity: 0; visibility: hidden;
  transition: opacity .6s var(--ease), visibility 0s linear .6s;
}
.glass.open { opacity: 1; visibility: visible; transition: opacity .6s var(--ease), visibility 0s; }
.sheet {
  position: relative; width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  padding: clamp(26px, 5vw, 44px) clamp(22px, 5vw, 44px) clamp(22px, 4vw, 34px);
  border-radius: 24px;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 176, 112, .075), transparent 60%),
    linear-gradient(180deg, rgba(34, 27, 36, .62), rgba(13, 10, 15, .78));
  border: 1px solid var(--hair);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 50px 140px -30px rgba(0, 0, 0, .9);
  transform: translateY(14px) scale(.985);
  transition: transform .7s var(--spring);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .12) transparent;
  overscroll-behavior: contain;
}
.glass.open .sheet { transform: none; }
.close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: none; border: 1px solid transparent; color: var(--dim); cursor: pointer;
  transition: color .3s, border-color .3s, transform .4s var(--spring);
}
.close:hover { color: var(--ink); border-color: var(--hair); transform: rotate(90deg); }
.close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.kicker { margin: 0 0 6px; padding-right: 40px; font: 500 10.5px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dimmer); }
.sheet h2 {
  margin: 0 0 18px; font: italic 300 clamp(44px, 8vw, 64px)/.95 var(--serif); font-variation-settings: 'opsz' 144;
  letter-spacing: -.02em; color: var(--amber); text-shadow: 0 0 34px rgba(255, 176, 112, .28);
}
.lede {
  margin: 0 0 14px; font: 300 clamp(15px, 2.1vw, 16.5px)/1.62 var(--serif); font-variation-settings: 'opsz' 14;
  color: rgba(240, 236, 232, .86); text-wrap: pretty;
}
.lede.small { font-size: 14.5px; color: rgba(240, 236, 232, .62); }
.nap-note {
  margin: 18px 0 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(160, 170, 210, .16); background: rgba(160, 170, 210, .05);
  font: 400 12px/1.6 var(--mono); color: rgba(214, 220, 240, .72);
}
.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 22px 0 18px;
  border: 1px solid var(--hair); border-radius: 14px; overflow: hidden; background: var(--hair);
}
.facts > div { background: rgba(12, 10, 14, .82); padding: 11px 13px 12px; min-width: 0; }
.facts dt { font: 500 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dimmer); margin-bottom: 7px; }
.facts dd { margin: 0; font: 400 13px/1.25 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.howto { margin: 0 0 20px; font: 400 12px/1.6 var(--mono); color: var(--dim); }
kbd {
  font: 500 10.5px/1 var(--mono); padding: 2px 6px 3px; border-radius: 5px;
  border: 1px solid var(--hair); border-bottom-width: 2px; color: var(--ink);
}
.fine { border-top: 1px solid var(--hair); padding-top: 16px; }
.fine p { margin: 0 0 10px; font: 400 11.5px/1.65 var(--mono); color: rgba(232, 236, 244, .5); text-wrap: pretty; }
.fine a { color: rgba(255, 207, 154, .8); text-decoration-color: rgba(255, 207, 154, .3); text-underline-offset: 2px; }
.links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.links a {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; text-decoration: none;
  border: 1px solid var(--hair); background: rgba(255, 255, 255, .015);
  transition: border-color .35s var(--ease), background .35s var(--ease), transform .45s var(--spring);
}
.links a span { font: italic 400 19px/1.1 var(--serif); font-variation-settings: 'opsz' 48; color: var(--amber); }
.links a small { font: 400 11px/1.4 var(--mono); color: var(--dim); }
.links a:hover { border-color: rgba(255, 207, 154, .28); background: rgba(255, 176, 112, .05); transform: translateY(-2px); }

/* ---------- fallback (no WebGL / no 3D) */
.fallback {
  position: fixed; inset: 0; z-index: 7; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px 16px; text-align: center;
  background: radial-gradient(90% 70% at 50% 40%, var(--void-2), var(--void) 70%);
}
.fallback.show, body.fallen .fallback { display: flex; }
body.fallen #stage, body.fallen .letters, body.fallen .corner, body.fallen .tapform { display: none; }
.fb-orb {
  position: relative; width: clamp(140px, 34vw, 190px); aspect-ratio: 1; border-radius: 50%; margin-bottom: 18px;
  background:
    radial-gradient(60% 60% at 34% 28%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 38%),
    radial-gradient(70% 70% at 50% 56%, rgba(255, 190, 130, .35), rgba(255, 190, 130, 0) 70%),
    radial-gradient(100% 100% at 50% 50%, rgba(232, 222, 240, .1), rgba(150, 140, 190, .16) 70%, rgba(200, 220, 255, .32) 98%);
  box-shadow: inset 0 -12px 40px rgba(255, 176, 112, .16), inset 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 80px -20px rgba(255, 150, 80, .28);
  animation: fb-breathe 5.5s ease-in-out infinite;
}
.fb-heart {
  position: absolute; inset: 32%; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff2dc, #ffb070 45%, rgba(255, 140, 70, 0) 72%);
  filter: blur(2px); opacity: .9; animation: fb-glow 4s ease-in-out infinite;
}
.fb-eye { position: absolute; top: 44%; width: 9%; height: 13%; border-radius: 50%; background: #120e14; box-shadow: inset 2px 2px 0 -1px rgba(255, 255, 255, .85); animation: fb-blink 6s infinite; }
.fb-eye.l { left: 35%; } .fb-eye.r { right: 35%; }
@keyframes fb-breathe { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.015); } }
@keyframes fb-glow { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
@keyframes fb-blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.fb-title { margin: 0; font: italic 300 52px/1 var(--serif); font-variation-settings: 'opsz' 144; color: var(--amber); }
.fb-msg { margin: 0; max-width: 34ch; font: 300 17px/1.55 var(--serif); color: rgba(240, 236, 232, .82); }
.fb-status { margin: 0; max-width: 46ch; font: 400 12px/1.6 var(--mono); color: var(--dim); }
.fb-status:empty { display: none; }
.fb-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.fb-links a {
  font: italic 400 17px/1 var(--serif); color: var(--amber); text-decoration: none;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--hair);
  transition: border-color .3s, background .3s;
}
.fb-links a:hover { border-color: rgba(255, 207, 154, .3); background: rgba(255, 176, 112, .05); }

/* ---------- small screens */
@media (max-width: 560px) {
  /* keep glyphs.js's hint line clear of the corner chrome */
  .letters.nib-glyphs .hint { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); letter-spacing: .12em; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .links { grid-template-columns: 1fr; }
  .meta { font-size: 10px; letter-spacing: .03em; }
  .corner { gap: 10px; }
}
@media (max-width: 360px) {
  .meta #meta-text { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- reduced motion: fades only */
@media (prefers-reduced-motion: reduce) {
  .grain, .veil-dot, .pip.live, .pip.load, .fb-orb, .fb-heart, .fb-eye { animation: none !important; }
  .veil-word { animation: none; opacity: .82; }
  .sheet, .glass.open .sheet, .corner { transform: none !important; }
  .mark .q, .close, .links a, .mute { transition-property: color, border-color, background, opacity; }
}
