/* Nightshade UI: layout A (subtitle box over the live scene) in pixel type.
   Type: Jacquard 24 for titles, Pixelify Sans for text, Silkscreen for labels.
   Load the fonts with:
   https://fonts.googleapis.com/css2?family=Jacquard+24&family=Pixelify+Sans:wght@400;500&family=Silkscreen&display=swap */

:root {
  --night: #06070e; --box: rgba(8, 9, 20, 0.72); --text: #f1ecdf; --soft: rgba(241, 236, 223, 0.6); --frame: rgba(241, 236, 223, 0.7); --rule: rgba(241, 236, 223, 0.25);
  --warm: #ff8a4c; --rust: #9c3f22; --paper: #e9e1cc; --paper-2: #dfd6bf; --ink-paper: #1d2138; --pencil: #565d78;

  --display: "Jacquard 24", serif;
  --body: "Pixelify Sans", monospace;
  --label: "Silkscreen", monospace;

  /* Type scale (desktop / phone below) */
  --t-title: clamp(54px, 7vw, 92px);  /* room name, game title */
  --t-text: 22px;                       /* narration, dialogue, choices */
  --t-lh: 1.5;
  --t-card: 26px;                       /* clue titles, found note */
  --t-note: 14px;                       /* clue descriptions */
  --t-label: 10px;                      /* speaker, time, buttons */
  --t-track: 0.06em;
}
@media (max-width: 700px) { :root { --t-text: 19px; --t-card: 24px; --t-note: 13px; } }

body { font: 400 var(--t-text)/var(--t-lh) var(--body); -webkit-font-smoothing: none; font-smooth: never; }
.label { font: 400 var(--t-label)/1 var(--label); letter-spacing: var(--t-track); text-transform: uppercase; }

/* A pixel frame: a 2px line with notched corners. No rounding, no blur. */
.px-frame { position: relative; background: var(--box); }
.px-frame::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--frame), inset 0 0 0 4px rgba(8, 9, 20, 0.9);
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px); }

/* Room title: when a page opens */
.place { position: absolute; left: 50%; top: 9vh; transform: translateX(-50%); text-align: center; transition: opacity 1.4s; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); pointer-events: none; }
.place .name { display: block; font: 400 var(--t-title)/1 var(--display); }
.place .time { display: block; margin-top: 10px; color: var(--soft); }

/* The text box */
.box { position: absolute; left: 50%; bottom: 6vh; width: min(820px, calc(100% - 32px)); transform: translateX(-50%); padding: 26px 34px; min-height: 120px; }
.who { position: absolute; left: 22px; top: 0; transform: translateY(-55%); padding: 8px 12px 7px; color: var(--text); background: #0b0d1c; box-shadow: 0 0 0 2px var(--frame); }
.who:empty { display: none; }
.line { margin: 0; text-wrap: pretty; }
.line .w { opacity: 0; }
.line .w.in { opacity: 1; }
.more { position: absolute; right: 18px; bottom: 12px; font: 400 16px/1 var(--label); color: var(--text); opacity: 0; }
.more.in { opacity: 1; animation: ns-blink 0.9s steps(1) infinite; }
@keyframes ns-blink { 50% { opacity: 0; } }

/* Choices, inside the box, with a ▶ cursor */
.choices { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.choices:empty { display: none; }
.choice { position: relative; display: flex; padding: 3px 0 3px 30px; cursor: pointer; color: var(--soft); opacity: 0; }
.choice.in { opacity: 1; }
.choice::before { content: "\25B6"; position: absolute; left: 4px; top: 50%; transform: translateY(-52%); font-size: 0.62em; color: var(--warm); opacity: 0; }
.choice.sel { color: var(--text); }
.choice.sel::before { opacity: 1; animation: ns-nudge 0.8s steps(2) infinite; }
@keyframes ns-nudge { 50% { transform: translate(3px, -52%); } }
.choice .n { flex: none; color: var(--soft); margin-right: 10px; }

/* Sketchbook chip, and the note when a clue is found */
.chip { position: absolute; right: 24px; top: 22px; display: flex; gap: 10px; align-items: center; color: var(--text); padding: 11px 14px; cursor: pointer; border: 0; font: 400 var(--t-label)/1 var(--label); letter-spacing: var(--t-track); text-transform: uppercase; }
.chip .count { display: inline-grid; place-items: center; min-width: 20px; height: 18px; background: var(--text); color: var(--night); padding: 0 5px; }
.chip.bump .count { background: var(--warm); }
.found { position: absolute; right: 24px; top: 74px; width: 240px; background-color: var(--paper); background-image: repeating-conic-gradient(rgba(29, 33, 56, 0.06) 0 25%, transparent 0 50%); background-size: 4px 4px; color: var(--ink-paper); padding: 10px 12px 12px; box-shadow: 0 0 0 2px var(--ink-paper), 4px 4px 0 2px rgba(0, 0, 0, 0.45);
  transform: translateX(calc(100% + 48px)); transition: transform 0.5s steps(6), opacity 0.4s; }
.found.in { transform: none; }
.found.away { transform: translate(30px, -54px) scale(0.3); opacity: 0; transition: transform 0.4s steps(5), opacity 0.4s steps(5); }
.found .label { color: var(--rust); }
.found .t { display: block; font: 400 calc(var(--t-card) * 1.15)/1 var(--display); margin-top: 8px; }

/* The sketchbook: drawn in pixels like the rest. A dark cloth cover with a running stitch,
   dithered paper, dotted rules, cards with hard frames and stepped tape. Nothing tilts or blurs. */
.book-wrap { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4, 5, 10, 0.78); opacity: 0; pointer-events: none; transition: opacity 0.3s steps(4); }
.book-wrap.open { opacity: 1; pointer-events: auto; }
.book { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 0; width: min(1100px, calc(100% - 40px)); aspect-ratio: 1.6; max-height: calc(100% - 40px); padding: 18px;
  background: #241d2e; box-shadow: 0 0 0 4px #0c0a14, 10px 10px 0 4px rgba(0, 0, 0, 0.55);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px); }
/* running stitch around the cover */
.book::before { content: ""; position: absolute; inset: 8px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, #b99a5c 0 8px, transparent 8px 16px) top / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, #b99a5c 0 8px, transparent 8px 16px) bottom / 100% 2px no-repeat,
    repeating-linear-gradient(0deg, #b99a5c 0 8px, transparent 8px 16px) left / 2px 100% no-repeat,
    repeating-linear-gradient(0deg, #b99a5c 0 8px, transparent 8px 16px) right / 2px 100% no-repeat; }
.pg { --pc: var(--paper); position: relative; color: var(--ink-paper); padding: 30px 32px; overflow: hidden; background-color: var(--pc);
  /* a faint 2px dither, then dotted rules every 32px (paper-coloured gaps over solid rules) */
  background-image:
    repeating-conic-gradient(rgba(29, 33, 56, 0.06) 0 25%, transparent 0 50%),
    repeating-linear-gradient(90deg, var(--pc) 0 4px, transparent 4px 6px),
    linear-gradient(transparent 30px, rgba(29, 33, 56, 0.2) 30px);
  background-size: 4px 4px, auto, 100% 32px; }
.pg:first-child { box-shadow: inset -6px 0 0 rgba(29, 33, 56, 0.12), inset -2px 0 0 rgba(29, 33, 56, 0.35); }
.pg:last-child { --pc: var(--paper-2); box-shadow: inset 6px 0 0 rgba(29, 33, 56, 0.12); }
/* stitched spine */
.pg:last-child::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: repeating-linear-gradient(#7d6a47 0 6px, transparent 6px 12px); }
.pg h2 { margin: 2px 0 0; font: 400 calc(var(--t-card) * 1.75)/1 var(--display); }
.pg .label { color: var(--pencil); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; margin-top: 22px; }
.card { position: relative; background: #f6f0df; padding: 6px 6px 9px; box-shadow: 0 0 0 2px var(--ink-paper), 4px 4px 0 2px rgba(29, 33, 56, 0.28); }
/* tape with stepped (torn) ends */
.card::before { content: ""; position: absolute; left: 50%; top: -10px; width: 52px; height: 14px; margin-left: calc(-26px + var(--tx, 0px)); background: rgba(196, 176, 122, 0.9);
  clip-path: polygon(0 0, 4px 0, 4px 2px, 8px 2px, 8px 0, 100% 0, 100% 4px, calc(100% - 2px) 4px, calc(100% - 2px) 10px, 100% 10px, 100% 100%, calc(100% - 6px) 100%, calc(100% - 6px) calc(100% - 2px), 0 calc(100% - 2px), 0 10px, 2px 10px, 2px 4px, 0 4px); }
.card .img { aspect-ratio: 16 / 10; background-size: 400%; image-rendering: pixelated; box-shadow: inset 0 0 0 2px rgba(29, 33, 56, 0.5); }
.card .t { display: block; font: 400 var(--t-card)/1 var(--display); margin-top: 8px; }
.card .d { display: block; font: 400 var(--t-note)/1.35 var(--body); color: var(--pencil); margin-top: 4px; }
.card.new { animation: ns-pin 0.45s steps(4); }
@keyframes ns-pin { from { transform: translateY(-20px); opacity: 0; } }
.pocket { margin-top: 26px; padding-top: 14px; background: repeating-linear-gradient(90deg, rgba(29, 33, 56, 0.35) 0 4px, transparent 4px 8px) top / 100% 2px no-repeat; }
.pocket p { margin: 8px 0 0; font: 400 calc(var(--t-text) * 0.75)/1.3 var(--body); color: var(--pencil); }
.close { position: absolute; right: 18px; top: 16px; font: 400 var(--t-label)/1 var(--label); letter-spacing: var(--t-track); text-transform: uppercase; background: none; border: 0; color: var(--pencil); cursor: pointer; }

/* Title screen */
.title { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 28px; background: rgba(4, 5, 10, 0.35); transition: opacity 0.6s steps(6); }
.title.gone { opacity: 0; pointer-events: none; }
.title h1 { margin: 0; font: 400 clamp(84px, 13vw, 176px)/0.9 var(--display); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.55); }
.title .start { min-width: 240px; padding: 16px 22px; text-align: left; }
.title .start .choice { opacity: 1; }
.title .note { color: var(--soft); }

@media (max-width: 700px) {
  .box { padding: 22px 20px 26px; bottom: 3vh; }
  .place { top: 14vh; width: 90%; }
  .chip { right: 12px; top: 12px; }
  .found { right: 12px; top: 62px; width: 210px; }
  .book { grid-template-columns: 1fr; aspect-ratio: auto; height: calc(100% - 24px); overflow: auto; align-content: start; padding: 12px; }
  .pg { padding: 22px 18px; overflow: visible; } .pg:last-child { border-left: 0; border-top: 3px solid rgba(29, 33, 56, 0.35); }
  .pg:last-child h2, .pg:last-child > .label:first-of-type { display: none; }
}
@media (prefers-reduced-motion: reduce) { .more.in, .choice.sel::before { animation: none; } }
