/* corridorchrisapp — interface styles. Dark, one accent, one system display face. */

:root {
  --bg: #0c0c0e;
  --bg-2: #16161a;
  --ink: #f1ede6;
  --muted: #8d8a84;
  --faint: rgba(241, 237, 230, 0.1);
  --accent: #ff5b2e;
  --accent-soft: rgba(255, 91, 46, 0.18);

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: dark;
}

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

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

body {
  background: radial-gradient(120% 90% at 50% 40%, var(--bg-2) 0%, var(--bg) 62%) fixed, var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Every scene is a fixed, full-viewport layer: nothing ever pushes anything else around. */
.scene {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

/* ───────────────────────── Gate ───────────────────────── */

html.unlocked #gate { display: none; }

.gate { z-index: 30; transition: opacity 0.6s ease, transform 0.7s var(--ease-out), filter 0.6s ease; }
.gate.leaving { opacity: 0; transform: scale(1.06); filter: blur(8px); pointer-events: none; }

.gate-form { width: min(100%, 360px); text-align: center; }

.gate-title {
  margin: 0 0 28px;
  font: 400 clamp(2.4rem, 9vw, 3.6rem)/1 var(--display);
  letter-spacing: -0.02em;
}
.gate-form.ok .gate-title { color: var(--accent); transition: color 0.25s ease; }

.gate-field { position: relative; }

.gate-input {
  width: 100%;
  height: 56px;
  padding: 0 56px 0 20px;
  border: 1px solid var(--faint);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 400 18px var(--sans);
  letter-spacing: 0.08em;
  caret-color: var(--accent);
  transition: border-color 0.2s ease, box-shadow 0.3s ease, background 0.2s ease;
}
.gate-input::placeholder { color: var(--muted); letter-spacing: 0; }
.gate-input:focus { outline: none; border-color: rgba(241, 237, 230, 0.28); background: rgba(255, 255, 255, 0.06); }
.gate-form.ok .gate-input { border-color: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); }

.gate-go {
  position: absolute; top: 6px; right: 6px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring), background 0.2s ease;
}
.gate-go:hover { transform: translateX(2px); }
.gate-go:active { transform: scale(0.92); }
.gate-form.ok .gate-go { background: var(--accent); }

/* Hint row reserves its height up front so revealing it never shifts layout. */
.gate-hint {
  height: 48px;
  margin-top: 18px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--muted);
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.gate-hint.show { opacity: 1; }
.gate-hint-text { min-width: 0; }

.thermo { display: inline-flex; gap: 3px; flex: none; }
.thermo i {
  width: 5px; height: 14px; border-radius: 3px;
  background: var(--faint);
  transition: background 0.4s ease, transform 0.4s var(--ease-spring);
}
.thermo i.on { background: var(--accent); transform: scaleY(1.15); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px) rotate(-1deg); }
  30% { transform: translateX(9px) rotate(1deg); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-2px); }
}
.gate-form.nope .gate-field { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ───────────────────────── Resume stack ───────────────────────── */

/* A centred column: the stack, its call to action, then the Corridor entry. */
.resume {
  z-index: 10;
  perspective: 1400px;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 2.4dvh, 24px);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.stack {
  /* Height left for the stack once the call to action and the Corridor entry have their room. */
  --w: min(78vw, calc((100dvh - 290px) * 0.773), 440px);
  flex: none;
  position: relative;
  width: var(--w);
  aspect-ratio: 1600 / 2070;
  padding: 0; border: 0; background: none;
  cursor: pointer;
  transform-style: preserve-3d;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.stack:focus-visible { outline-offset: 12px; border-radius: 4px; }

.page {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: #fbfaf7;
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 12px 28px -6px rgba(0, 0, 0, 0.55),
    0 40px 80px -20px rgba(0, 0, 0, 0.6);
  transform: translate(var(--tx, 0), var(--ty, 0)) rotate(var(--r, 0deg));
  transition: transform 0.5s var(--ease-out);
  backface-visibility: hidden;
  will-change: transform;
  pointer-events: none;
}

/* Fan opens a touch on hover / focus: an invitation, not a reveal. */
.stack:hover .page, .stack:focus-visible .page {
  transform: translate(calc(var(--tx, 0) * 1.6), calc(var(--ty, 0) * 1.6)) rotate(calc(var(--r, 0deg) * 1.7));
}
.stack:hover .page:first-child, .stack:focus-visible .page:first-child {
  transform: translate(0, -6px) rotate(var(--r, 0deg));
}

@keyframes deal {
  from { opacity: 0; transform: translate(0, 40px) rotate(calc(var(--r, 0deg) * 3)) scale(0.96); }
}
.page.dealing { animation: deal 0.7s var(--ease-out) backwards; animation-delay: var(--d, 0ms); }

@keyframes peek {
  0%, 82%, 100% { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  88% { transform: translate(0, -5px) rotate(calc(var(--r, 0deg) - 1.4deg)); }
  94% { transform: translate(0, -1px) rotate(calc(var(--r, 0deg) + 0.5deg)); }
}
.stack.ready:not(:hover) .page:first-child:not(.dealing) { animation: peek 3.2s ease-in-out 0.4s infinite; }

/* Resume call to action: an explicit, quiet pill under the stack. */
.cta {
  position: relative;
  flex: none;
  display: inline-flex; align-items: center; gap: 10px;
  height: 46px;
  padding: 0 18px 0 16px;
  border: 1px solid rgba(241, 237, 230, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font: 500 15px/1 var(--sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.6s var(--ease-spring), border-color 0.2s ease, background 0.2s ease;
  pointer-events: none;
}
.cta.show { opacity: 1; transform: none; pointer-events: auto; }
.cta.leaving { opacity: 0; transform: translateY(8px) scale(0.96); transition-duration: 0.2s; }
.cta:hover { border-color: var(--accent); background: var(--accent-soft); }
.cta-arrow { color: var(--accent); animation: cta-nudge 1.6s ease-in-out infinite; }
@keyframes cta-nudge {
  0%, 60%, 100% { transform: translateX(0); }
  30% { transform: translateX(4px); }
}
/* Hovering the stack lights the prompt too: they are one control. */
.stack.ready:hover ~ .cta { border-color: var(--accent); }

/* Entry to /corridor (CONTRACT.md, Corridor page item 1): Corridor's own nameplate, big, with the label
   under it. The nameplate (597x156) stays sharp at this size; the "C" favicon mark is only ~64px of real
   detail (Data). A plain link outside the stack button, so it can never start the flutter. */
.corridor-entry {
  flex: none;
  display: inline-flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: min(100%, 440px);
  margin-top: clamp(4px, 1.5dvh, 16px);
  padding: 12px 18px 14px;
  border: 1px solid rgba(241, 237, 230, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 500 15px/1.3 var(--sans);
  text-align: center;
  text-decoration: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease 0.15s, transform 0.6s var(--ease-out) 0.15s, border-color 0.2s ease, background 0.2s ease;
  pointer-events: none;
}
.corridor-entry img {
  flex: none;
  width: clamp(176px, 20vw, 228px); height: auto;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.corridor-entry.show { opacity: 1; transform: none; pointer-events: auto; }
.corridor-entry.leaving { opacity: 0; transform: translateY(8px); transition-duration: 0.2s; transition-delay: 0s; }
.corridor-entry:hover { border-color: var(--accent); background: var(--accent-soft); }
.corridor-entry:focus-visible { outline-offset: 4px; }
@media (max-width: 480px) {
  .corridor-entry { gap: 8px; padding: 10px 14px 12px; font-size: 14px; }
  .corridor-entry img { width: 168px; }
}

.nudge {
  position: absolute;
  left: 0; right: 0;
  bottom: max(28px, env(safe-area-inset-bottom));
  margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s var(--ease-out);
  pointer-events: none;
}
.nudge.show { opacity: 1; transform: none; }

.nudge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-soft);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 91, 46, 0.45); }
  100% { box-shadow: 0 0 0 12px rgba(255, 91, 46, 0); }
}

/* ───────────────────────── Shape ───────────────────────── */

.shape-scene { z-index: 5; overflow: hidden; }

.stage {
  position: relative;
  width: 100%; height: 100%;
  display: grid; place-items: center;
  perspective: 1600px;
  touch-action: none;
  cursor: grab;
  transition: transform 0.6s var(--ease-out);
}
.stage.dragging { cursor: grabbing; }

/* Make room for the detail panel: slide left on wide screens, up on narrow ones. */
body.detail-open .stage { transform: translateX(min(-12vw, -180px)); }
@media (max-width: 760px) {
  body.detail-open .stage { transform: translateY(-21dvh) scale(0.8); }
}

.shape {
  position: relative;
  width: 0; height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.face {
  position: absolute;
  left: 0; top: 0;
  width: var(--fw); height: var(--fh);
  /* Put the face's centre point (--cx, --cy of its box) on the solid's origin; JS's matrix3d does the rest. */
  margin-left: calc(var(--fw) * var(--cx) * -1);
  margin-top: calc(var(--fh) * var(--cy) * -1);
  transform-origin: calc(var(--cx) * 100%) calc(var(--cy) * 100%);
  padding: 0; border: 0;
  background: #222;
  overflow: hidden;
  cursor: pointer;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.9s var(--ease-out), opacity 0.6s ease;
  transition-delay: var(--d, 0ms);
}
/* Caps and tetrahedron faces: any convex polygon, clip computed in shape.js. */
.face.poly { clip-path: var(--clip); }
.face.side { border-radius: 2px; }

.face img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Scrim for legibility + per-face light, driven by --shade from JS. */
.face::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 55%),
    rgba(0, 0, 0, var(--shade, 0));
  pointer-events: none;
}
.face.poly::after {
  background:
    radial-gradient(closest-side at calc(var(--cx) * 100%) calc(var(--cy) * 100%), rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.1)),
    rgba(0, 0, 0, var(--shade, 0));
}
.face::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.face.poly::before { display: none; }

.face-word {
  position: absolute;
  z-index: 2;
  left: calc(var(--cx) * 100%);
  top: calc(var(--cy) * 100%);
  width: var(--ww, 84%);
  transform: translate(-50%, -50%);
  font: 400 var(--fs)/1.05 var(--display);
  letter-spacing: -0.01em;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.face.side .face-word { top: auto; bottom: 9%; transform: translateX(-50%); }

.face:focus-visible { outline: none; }
.face:focus-visible::before { box-shadow: inset 0 0 0 3px var(--accent); display: block; }
.face.active::before { box-shadow: inset 0 0 0 2px var(--accent); display: block; }
/* A clipped polygon can't show an inset ring, so poly faces brighten instead. */
.face.poly:focus-visible::after, .face.poly.active::after { background: rgba(255, 91, 46, 0.16); }

/* Entrance: faces start blown out along their normals, transparent, and fly home. */
.shape.assembling .face { opacity: 0; transform: var(--m) translateZ(var(--explode)) rotateZ(var(--spin)); }
.face { transform: var(--m); }

.shape-nudge { transition-delay: 0.2s; }

.shape-fallback { margin: 0; color: var(--muted); font: italic 400 1.4rem/1.3 var(--display); text-align: center; }

/* ───────────────────────── Detail panel ───────────────────────── */

.detail { position: fixed; inset: 0; z-index: 20; }

.detail-scrim {
  position: absolute; inset: 0;
  background: rgba(8, 8, 10, 0.35);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  padding: 72px 40px 40px;
  background: rgba(20, 20, 24, 0.94);
  border-left: 1px solid var(--faint);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.5s var(--ease-out);
  outline: none;
}

.detail.open .detail-scrim { opacity: 1; }
.detail.open .panel { transform: none; }

@media (max-width: 760px) {
  .panel {
    top: auto; left: 0;
    width: 100%;
    max-height: 62dvh;
    padding: 56px 24px max(32px, env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid var(--faint);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .panel::before {
    content: "";
    position: absolute; top: 10px; left: 50%;
    width: 40px; height: 4px; margin-left: -20px;
    border-radius: 2px; background: var(--faint);
  }
}

.panel-close {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--faint); border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), border-color 0.2s ease, color 0.2s ease;
}
.panel-close:hover { transform: rotate(90deg); border-color: var(--accent); color: var(--accent); }

.panel-index {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.panel-word {
  margin: 0 0 12px;
  font: 400 clamp(2.2rem, 8vw, 3.2rem)/1.02 var(--display);
  letter-spacing: -0.02em;
}

.panel-tagline {
  margin: 0 0 28px;
  font: italic 400 1.2rem/1.4 var(--display);
  color: var(--ink);
}

.panel-body { color: rgba(241, 237, 230, 0.82); font-size: 16px; line-height: 1.65; }
.panel-body p { margin: 0 0 1em; }

/* "Coming soon": a dashed placeholder that reads as intentional, not broken. */
.soon {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--muted);
  font: italic 400 1.05rem/1.4 var(--display);
}
.soon::before { content: ""; width: 22px; height: 1px; background: currentColor; opacity: 0.6; }
.panel-body .soon-card {
  margin-top: 4px;
  padding: 18px 20px;
  border: 1px dashed var(--faint);
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
}

/* Panel content arrives just behind the panel itself. */
.panel > * { opacity: 0; transform: translateY(8px); transition: opacity 0.4s ease, transform 0.5s var(--ease-out); }
.detail.open .panel > * { opacity: 1; transform: none; }
.detail.open .panel > :nth-child(2) { transition-delay: 0.12s; }
.detail.open .panel > :nth-child(3) { transition-delay: 0.16s; }
.detail.open .panel > :nth-child(4) { transition-delay: 0.22s; }
.detail.open .panel > :nth-child(5) { transition-delay: 0.28s; }

/* ───────────────────────── Reduced motion ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .gate.leaving { transform: none; filter: none; }
  .stack:hover .page, .stack:focus-visible .page { transform: translate(var(--tx, 0), var(--ty, 0)) rotate(var(--r, 0deg)); }
  .stack:hover .page:first-child { transform: rotate(var(--r, 0deg)); }
  .shape.assembling .face { transform: var(--m); }
  .face { transition: opacity 0.5s ease; transition-delay: 0ms; }
  .stage { transition: none; }
  .panel, .panel > * { transition: opacity 0.3s ease; transform: none !important; }
  .detail:not(.open) .panel { opacity: 0; }
  .nudge { transform: none; }
  .cta, .cta.show, .cta.leaving, .corridor-entry, .corridor-entry.show, .corridor-entry.leaving { transform: none; }
}
