/* Sammy Ahmed – an RPG in colour chapters. Jersey 10 for display, Jersey 20 for text: both pixel faces drawn on a grid, set at whole multiples so every pixel stays square. */

:root {
  --bone: #e6e0d2;
  --ink: #1a1a1a;
  --coral: #ed4b44;
  --coral-deep: #d63f39;
  --green: #18bc42;
  --yellow: #f2c21a;
  --yellow-deep: #dcae12;
  --night: #1a1a1a;
  --night-2: #2a2a33;
  --night-3: #3d3d4a;

  --font-display: "Jersey 10", "Arial Narrow", sans-serif;
  --font-text: "Jersey 20", "Arial Narrow", sans-serif;

  --step-small: 1.25rem;
  --step-body: 1.5rem;
  --step-lead: clamp(1.5rem, 0.8rem + 1.5vw, 2.25rem);
  --step-head: clamp(2.75rem, 1rem + 4.6vw, 5rem);
  --step-display: clamp(4rem, 13.2vw, 16rem);

  --bar: 2.875rem;
  --margin: clamp(1rem, 2.2vw, 2rem);
  --gutter: clamp(1rem, 2vw, 2rem);
  --section: clamp(5rem, 9vw, 9rem);

  --n: 4px;
  --n2: 8px;
  --notch: polygon(0 var(--n2), var(--n) var(--n2), var(--n) var(--n), var(--n2) var(--n), var(--n2) 0,
    calc(100% - var(--n2)) 0, calc(100% - var(--n2)) var(--n), calc(100% - var(--n)) var(--n), calc(100% - var(--n)) var(--n2), 100% var(--n2),
    100% calc(100% - var(--n2)), calc(100% - var(--n)) calc(100% - var(--n2)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n2)) calc(100% - var(--n)), calc(100% - var(--n2)) 100%,
    var(--n2) 100%, var(--n2) calc(100% - var(--n)), var(--n) calc(100% - var(--n)), var(--n) calc(100% - var(--n2)), 0 calc(100% - var(--n2)));

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms;
  --t-hover: 160ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: auto; }
body { font-synthesis: none; margin: 0; background: var(--bone); color: var(--ink); font-family: var(--font-text); font-size: var(--step-body); line-height: 1.5; overflow-x: clip; }
h1, h2, h3, p, figure, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:target { scroll-margin-top: calc(var(--bar) + 1rem); }
::selection { background: var(--yellow); color: var(--ink); }
:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--margin); top: -4rem; z-index: 40; padding: 0.6rem 1rem; background: var(--yellow); color: var(--ink); font-weight: 700; }
.skip:focus { top: 0.75rem; }
.nums { font-variant-numeric: tabular-nums; }

/* ---------- type ---------- */
.display, .head, h1 { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; hyphens: none; letter-spacing: 0.01em; }
.display { font-size: var(--step-display); line-height: 0.86; }
.head { font-size: var(--step-head); line-height: 0.92; }
.lead { font-size: var(--step-lead); line-height: 1.2; text-wrap: balance; }
p { max-width: 62ch; text-wrap: pretty; }
.role h3, .mini h3, .earlier h3 { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; letter-spacing: 0.01em; line-height: 1; }
.role h3, .mini h3 { font-size: var(--step-lead); }

/* ---------- the pixel shape: stepped corners on filled blocks, never an outline ---------- */
.notch { clip-path: var(--notch); --n: 6px; --n2: 12px; }
.box { background: var(--frame, var(--ink)); padding: 6px; clip-path: var(--notch); }
.box > .in { background: var(--panel, var(--bone)); color: var(--panel-ink, var(--ink)); padding: 1rem 1.25rem; clip-path: var(--notch); --n: 3px; --n2: 6px; position: relative; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 3.75rem; padding: 0 2.25rem; background: var(--ink); color: var(--bone); text-decoration: none; font-weight: 700; font-size: var(--step-body); white-space: nowrap; clip-path: var(--notch); transition: transform var(--t-press) steps(2, end), background-color var(--t-hover) steps(2, end), color var(--t-hover) steps(2, end); }
.button:active { transform: translateY(4px); }
.button:focus-visible { outline: none; background: var(--yellow); color: var(--ink); transform: translateY(3px); }
.shoot:focus-visible { background: var(--coral); }
@media (hover: hover) and (pointer: fine) { .button:hover { background: var(--coral); color: var(--ink); } }

/* ---------- HUD: the game's status bar. It sits in the page, so text scrolls beneath it, never behind it ---------- */
.hud { position: sticky; z-index: 30; top: 0; min-height: var(--bar); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 var(--margin); background: var(--night); color: var(--bone); font-size: var(--step-small); font-weight: 600; }
.xp { display: flex; gap: 3px; }
.xp i { width: 0.6rem; height: 1rem; background: var(--night-3); transition: background-color 160ms steps(2, end); }
.xp i.on { background: var(--yellow); }

/* ---------- chapters: one flat colour each, hard edges ---------- */
.chap { padding: var(--section) var(--margin); background: var(--bg); color: var(--fg); }
.chap .button { background: var(--btn, var(--ink)); color: var(--btn-ink, var(--bone)); }

/* ---------- title screen ---------- */
.hero { position: relative; isolation: isolate; min-height: calc(100svh - var(--bar)); display: grid; grid-template-rows: 1fr auto auto; padding: 2rem var(--margin) 2rem; color: var(--ink); }
.hero::before, .hero::after { content: ""; position: absolute; left: 0; right: 0; z-index: -1; }
.hero::before { top: 0; bottom: 50%; background: var(--bone); }
.hero::after { top: 50%; bottom: 0; background: var(--green); }
.hero-top { display: contents; }
.hero h1 { align-self: center; justify-self: center; text-align: center; font-size: var(--step-display); line-height: 0.86; position: relative; top: 0.42em; }
.lines .line { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.lines [data-line] { display: block; }
.walker { --px: 7px; height: calc(22 * var(--px)); position: relative; margin-top: 1.5rem; }
.sprite { position: absolute; left: 0; bottom: 0; width: calc(16 * var(--px)); height: calc(22 * var(--px)); overflow: hidden; --run: calc(100vw - 2 * var(--margin) - 16 * var(--px)); }
.sprite::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 200%; background: url("assets/player.svg") 0 0 / 100% 100% no-repeat; image-rendering: pixelated; }
.talk { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-top: 1.25rem; }
.dialog { --frame: var(--ink); --panel: var(--bone); --panel-ink: var(--ink); max-width: 46rem; width: 100%; }
.dialog .in { padding-bottom: 1.4rem; }
.who { font-weight: 700; margin-bottom: 0.25rem; }
.say { font-size: var(--step-body); line-height: 1.45; max-width: none; }
.say .off { visibility: hidden; }
.more { position: absolute; right: 1rem; bottom: 0.7rem; width: 0.8rem; height: 0.6rem; background: currentColor; clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* ---------- character sheet (night) ---------- */
.sheet { --bg: var(--night); --fg: var(--bone); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--gutter); align-items: start; }
.sheet-pic img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 38% 50%; }
.sheet-pic figcaption, .stick figcaption, .side-pic figcaption, .pad figcaption { margin-top: 0.9rem; font-size: var(--step-small); max-width: 46ch; }
.sheet-copy { display: grid; gap: 2.25rem; align-content: start; padding-left: clamp(0rem, 3vw, 3rem); }
.sheet-copy .lead { max-width: none; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2.75rem var(--gutter); }
.stats dt { font-family: var(--font-display); font-size: var(--step-head); line-height: 0.9; color: var(--yellow); }
.stats .plus { margin-left: 0.04em; }
.stats dd { margin-top: 0.4rem; max-width: 22ch; }
.base { font-weight: 700; }

/* ---------- quest log (coral) ---------- */
.quests { --bg: var(--coral); --fg: #0f0f0f; }
.quests-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--gutter); align-items: end; margin-bottom: clamp(3rem, 6vw, 5.5rem); }
.quests-head .lead { justify-self: end; max-width: 24ch; text-align: right; }
.quest { position: relative; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 4fr) minmax(0, 5fr); column-gap: var(--gutter); padding: 2rem 1.5rem 2rem 2.25rem; margin-inline: -1.5rem; transition: background-color var(--t-hover) steps(2, end); }
.quest + .quest { margin-top: 1rem; }
.when { display: grid; gap: 0.75rem; justify-items: start; align-content: start; font-weight: 600; }
.tag { display: inline-block; padding: 0.15rem 0.8rem; background: var(--night); color: var(--bone); clip-path: var(--notch); font-weight: 700; --n: 3px; --n2: 6px; }
.role { position: relative; display: grid; gap: 0.35rem; align-content: start; }
.role h3 { position: relative; }
.role h3::before { content: ""; position: absolute; left: -1.5rem; top: 0.32em; width: 0.8rem; height: 1rem; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); opacity: 0; }
.did { display: grid; gap: 0.7rem; }
.did li { position: relative; padding-left: 1.1rem; }
.did li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 0.45rem; height: 0.45rem; background: currentColor; }
.quest.is-active { background: var(--night); color: var(--bone); clip-path: var(--notch); --n: 6px; --n2: 12px; }
.quest.is-active .tag { background: var(--yellow); color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .quest:not(.is-active):hover { background: var(--coral-deep); }
  .quest:hover .role h3::before { opacity: 1; animation: cursor 700ms steps(1) infinite; }
}
.earlier { margin-top: clamp(4rem, 7vw, 6.5rem); display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); column-gap: var(--gutter); }
.earlier li { display: flex; justify-content: space-between; gap: 1.5rem; padding-block: 0.35rem; }
.earlier .yr { white-space: nowrap; font-weight: 600; }

/* ---------- spell book and equipment (yellow) ---------- */
.spells { --bg: var(--yellow); --fg: var(--ink); display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: clamp(2rem, 5vw, 6rem); align-items: start; }
.spell-list { margin-top: clamp(2rem, 4vw, 3.5rem); display: grid; gap: 2rem; }
.spell-list p { margin-top: 0.4rem; max-width: 46ch; }
.gear-col { display: grid; gap: 2rem; align-content: start; }
.slots { width: 100%; border-collapse: collapse; font-size: var(--step-lead); line-height: 1.25; }
.slots th, .slots td { padding: 0.7rem 0; text-align: left; font-weight: 400; vertical-align: baseline; transition: background-color var(--t-hover) steps(2, end); }
.slots th { width: 38%; font-family: var(--font-text); font-size: var(--step-body); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .slots tr:hover th, .slots tr:hover td { background: var(--yellow-deep); } }
.pack { max-width: 40ch; }
.stick img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; mix-blend-mode: multiply; clip-path: none; }

/* ---------- side quests (green) ---------- */
.side { --bg: var(--green); --fg: var(--ink); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: auto 1fr 1fr; grid-template-areas: "h pic" "a pic" "b pic"; gap: 1.5rem var(--gutter); }
.side-h { grid-area: h; margin-bottom: 1.5rem; }
.side-pic { grid-area: pic; }
.mini-a { grid-area: a; }
.mini-b { grid-area: b; }
.side-pic img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: 50% 62%; }
.mini { background: var(--bone); color: var(--ink); padding: 1.5rem 1.75rem 1.75rem; clip-path: var(--notch); display: grid; gap: 0.5rem; align-content: start; }
.mini p { max-width: 44ch; }

/* ---------- boss battle (night) ---------- */
.boss { --bg: var(--night); --fg: var(--bone); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--gutter); align-items: start; }
.boss-copy { display: grid; gap: 1.75rem; align-content: start; }
.boss-copy .lead { max-width: none; }
.boss .dialog { --frame: var(--bone); --panel: var(--night-2); --panel-ink: var(--bone); max-width: 30rem; }
.msg { font-size: var(--step-body); min-height: 3em; max-width: none; }
.score { font-family: var(--font-display); font-size: var(--step-head); line-height: 0.9; color: var(--yellow); }
.score .of { color: var(--bone); }
.best { font-weight: 600; }
.boss-stage { display: grid; gap: 1rem; }
.stage { --s: calc(100cqw / 130); container-type: inline-size; position: relative; aspect-ratio: 16 / 10; background: var(--night-2); overflow: clip; clip-path: var(--notch); --n: 8px; --n2: 16px; }
.floor { position: absolute; left: 0; right: 0; bottom: 0; height: 24%; background: var(--night-3); }
.enemy { position: absolute; left: 4%; top: 6%; --frame: var(--bone); --panel: var(--night); --panel-ink: var(--bone); min-width: 14rem; }
.enemy .in { padding: 0.6rem 1rem 0.8rem; }
.en-name { font-weight: 700; font-size: var(--step-small); }
.hp { display: flex; gap: 4px; margin-top: 0.45rem; }
.hp i { width: 2rem; height: 0.9rem; background: var(--coral); transition: transform 240ms steps(4, end), opacity 240ms steps(4, end); transform-origin: left center; }
.hp i.gone { transform: scaleX(0); opacity: 0; }
.hoop { position: absolute; right: 6%; top: 8%; width: calc(24 * var(--s) * 1.15); height: calc(24 * var(--s) * 1.15); background: url("assets/hoop.svg") 0 0 / 100% 100% no-repeat; image-rendering: pixelated; }
.hero-sprite { position: absolute; left: 8%; bottom: 20%; width: calc(16 * var(--s)); height: calc(22 * var(--s)); }
.still { width: 100%; height: 100%; background: url("assets/player-still.svg") 0 0 / 100% 100% no-repeat; image-rendering: pixelated; }
.ball { position: absolute; left: calc(8% + 12 * var(--s)); bottom: calc(20% + 3 * var(--s)); width: calc(4 * var(--s)); height: calc(4 * var(--s)); background: url("assets/ball.svg") 0 0 / 100% 100% no-repeat; image-rendering: pixelated; }
.meter { position: absolute; left: 4%; right: 4%; bottom: 5%; height: 2.5rem; background: var(--night); overflow: hidden; }
.zone { position: absolute; top: 0; bottom: 0; background: var(--yellow); }
.marker { position: absolute; top: 0; bottom: 0; left: 0; width: 0.6rem; background: var(--bone); will-change: transform; }
.shoot { --btn: var(--yellow); --btn-ink: var(--ink); width: 100%; min-height: 4.25rem; font-size: var(--step-lead); touch-action: manipulation; }
html:not(.js) .stage, html:not(.js) .shoot, html:not(.js) .score { display: none; }

/* ---------- continue? (coral) ---------- */
.cont { --bg: var(--coral); --fg: #0f0f0f; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--gutter); }
.cont-copy { display: grid; gap: 1.5rem; align-content: start; }
.cont-copy .lead { max-width: none; }
.count { line-height: 0.8; font-variant-numeric: tabular-nums; }
.pad img { width: 100%; mix-blend-mode: multiply; clip-path: none; }
.pad { justify-self: end; width: min(100%, 40rem); }

/* ---------- credits (bone) ---------- */
.foot { background: var(--bone); color: var(--ink); padding: var(--section) var(--margin) 1.75rem; }
.thanks { white-space: nowrap; }
.foot-row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--gutter); margin-top: 3.5rem; align-items: start; }
.foot-note { font-size: var(--step-lead); line-height: 1.2; font-weight: 600; }
.credits { font-size: var(--step-small); line-height: 1.55; max-width: 62ch; }
.foot-last { display: flex; justify-content: space-between; gap: 1rem; margin-top: 5rem; font-size: var(--step-small); font-weight: 600; }

/* ---------- tablet and below ---------- */
@media (max-width: 63.99em) {
  :root { --step-display: 14vw; }
  .thanks { white-space: normal; }
  .sheet, .spells, .boss, .foot-row { grid-template-columns: minmax(0, 1fr); row-gap: 2.5rem; }
  .side { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "h" "pic" "a" "b"; }
  .sheet-pic img { aspect-ratio: 4 / 3; }
  .sheet-copy { padding-left: 0; }
  .quests-head { grid-template-columns: minmax(0, 1fr); row-gap: 1rem; }
  .quests-head .lead { justify-self: start; text-align: left; max-width: 24ch; }
  .quest { grid-template-columns: minmax(0, 1fr); row-gap: 0.9rem; margin-inline: -1rem; padding: 1.5rem 1rem 1.5rem 1.75rem; }
  .role h3::before { display: none; }
  .when { grid-template-columns: auto auto; justify-content: space-between; width: 100%; }
  .earlier { grid-template-columns: minmax(0, 1fr); row-gap: 1rem; }
  .earlier li { flex-direction: column; gap: 0.1rem; }
  .cont { grid-template-columns: minmax(0, 1fr); }
  .pad { justify-self: start; }
}

/* ---------- phone ---------- */
@media (max-width: 47.99em) {
  .hero { grid-template-rows: auto 1fr; padding: 0 0 1.5rem; background: var(--green); }
  .hero::before, .hero::after { display: none; }
  .hero-top { display: block; background: var(--bone); padding: 2.25rem var(--margin) 0; }
  .hero h1 { top: 0; }
  .walker { --px: 6px; margin-top: 1.25rem; }
  .talk { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 1rem; margin: 1.5rem var(--margin) 0; }
  .talk .button { width: 100%; }
  .stats { gap: 2rem var(--gutter); }
  .slots th { width: 42%; }
  .count { font-size: 34vw; }
  .enemy { min-width: 0; left: 3%; }
  .hp i { width: 1.2rem; }
}

/* ---------- motion: transform, opacity and stepped frames; content stays visible without script ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .lines [data-line] { transform: translateY(105%); animation: line-up 800ms steps(9, end) forwards; animation-delay: calc(var(--i, 0) * 140ms + 150ms); }
  .js [data-rise] { opacity: 0; transform: translateY(22px); animation: rise 640ms steps(5, end) forwards; animation-delay: calc(var(--i, 0) * 160ms + 150ms); }
  .js [data-reveal] { opacity: 0; transform: translateY(32px); transition: opacity 520ms steps(5, end), transform 520ms steps(5, end); transition-delay: calc(var(--i, 0) * 100ms); }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
  .sprite::before { animation: frames 640ms steps(1) infinite; }
  .sprite { animation: patrol 26s infinite; animation-timing-function: steps(80); }
  .more { animation: cursor 800ms steps(1) infinite; }
  .count { animation: pulse 1s steps(1) infinite; }
}
@keyframes line-up { to { transform: none; } }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes frames { 0% { transform: translateX(0); } 50% { transform: translateX(-50%); } }
@keyframes patrol {
  0% { transform: translateX(0) scaleX(1); }
  47% { transform: translateX(var(--run)) scaleX(1); }
  50% { transform: translateX(var(--run)) scaleX(-1); }
  97% { transform: translateX(0) scaleX(-1); }
  100% { transform: translateX(0) scaleX(1); }
}
@keyframes cursor { 50% { opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: none; } 50% { transform: translateY(-4px); } }
