/* Pixal's homepage. The sky canvas behind everything is drawn by home.js with the game's own band palettes;
   the hero's ink follows it (--ink is set from the time of day). Below the hero, chapters sit on the game's paper. */
:root {
  --ink: #fff8ec;
  --ink-soft: rgba(255, 248, 236, .78);
  --paper: #f1e6cf;
  --paper-deep: #e6d6b5;
  --brown: #714c37;
  --brown-soft: #8f6b52;
  --night: #12152d;
  --gold: #f2b544;
  --leaf: #7cc26a;
  --px: 4px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--brown); background: var(--night);
  font: 22px/1.3 "VT323", ui-monospace, monospace;
  -webkit-font-smoothing: none; text-rendering: optimizeSpeed;
}
img, video { display: block; max-width: 100%; }
a { color: inherit; }

#sky { position: fixed; inset: 0; width: 100vw; height: 100lvh; image-rendering: pixelated; z-index: -1; }

/* A pixel border: hard steps, no radius. */
.px-border, .frame, .company-card, .slide-pic, .badge, .carousel-nav button {
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 currentColor, 0 var(--px) 0 0 currentColor,
    calc(-1 * var(--px)) 0 0 0 currentColor, var(--px) 0 0 0 currentColor;
}

/* ---------- bar ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  color: var(--ink); transition: background .4s steps(4), color .4s steps(4);
}
.bar.solid { background: rgba(18, 21, 45, .82); color: #fff8ec; backdrop-filter: blur(6px); }
.brand { font-family: Silkscreen, monospace; font-size: 15px; letter-spacing: 2px; text-decoration: none; }
.bar nav { display: flex; gap: 18px; font-family: Silkscreen, monospace; font-size: 11px; letter-spacing: 1px; }
.bar nav a { text-decoration: none; opacity: .85; }
.bar nav a:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 48px;
  padding: 110px max(24px, 6vw) 64px; color: var(--ink);
}
.hero-copy { max-width: 560px; }
.kicker { font-family: Silkscreen, monospace; font-size: 12px; letter-spacing: 2px; margin: 0 0 18px; color: var(--ink-soft); min-height: 1em; }
.hero h1 {
  font-family: Silkscreen, monospace; font-weight: 700; margin: 0; line-height: .9;
  font-size: clamp(72px, 13vw, 168px); letter-spacing: 4px;
  text-shadow: 6px 6px 0 rgba(0, 0, 0, .22);
}
.lede { font-size: clamp(24px, 2.3vw, 30px); line-height: 1.2; margin: 22px 0 28px; color: var(--ink); }
.badge { display: inline-block; margin: 0; padding: 8px 14px; font-family: Silkscreen, monospace; font-size: 12px; letter-spacing: 1.5px; color: var(--ink); }

.window { margin: 0; justify-self: center; width: min(400px, 100%, calc((100svh - 300px) * 9 / 16)); min-width: 260px; color: var(--ink); }
.frame { position: relative; aspect-ratio: 9 / 16; overflow: hidden; background: #000; color: #2a1f1a; box-shadow: 0 0 0 var(--px) #2a1f1a, 0 0 0 calc(2 * var(--px)) #c9a86a, 0 0 0 calc(3 * var(--px)) #2a1f1a, 14px 18px 0 calc(3 * var(--px)) rgba(0,0,0,.25); }
.frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; image-rendering: pixelated; }
.dial { margin-top: 54px; }
.dial input { width: 100%; -webkit-appearance: none; appearance: none; height: 24px; background: transparent; cursor: grab; }
.dial input:active { cursor: grabbing; }
.dial input::-webkit-slider-runnable-track { height: 8px; background: repeating-linear-gradient(90deg, currentColor 0 8px, transparent 8px 12px); opacity: .7; }
.dial input::-moz-range-track { height: 8px; background: repeating-linear-gradient(90deg, currentColor 0 8px, transparent 8px 12px); opacity: .7; }
.dial input::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border: 0; background: var(--thumb, #f2b544); box-shadow: 0 0 0 4px #2a1f1a, 4px 4px 0 4px rgba(0,0,0,.25); }
.dial input::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 0; background: var(--thumb, #f2b544); box-shadow: 0 0 0 4px #2a1f1a; }
.dial-labels { display: flex; justify-content: space-between; font-family: Silkscreen, monospace; font-size: 10px; letter-spacing: 1px; margin-top: 8px; color: var(--ink-soft); }

/* ---------- chapters on paper ---------- */
main { background: var(--paper); position: relative; }
main::before { /* a dithered edge where the sky meets the paper */
  content: ""; position: absolute; left: 0; right: 0; top: -16px; height: 16px;
  background:
    conic-gradient(var(--paper) 25%, transparent 0 50%, var(--paper) 0 75%, transparent 0) 0 0 / 8px 8px,
    linear-gradient(transparent 50%, var(--paper) 0);
}
.chapter { max-width: 1120px; margin: 0 auto; padding: 110px max(24px, 6vw); }
.eyebrow { font-family: Silkscreen, monospace; font-size: 12px; letter-spacing: 2px; color: var(--brown-soft); margin: 0 0 18px; }
h2 { font-family: Silkscreen, monospace; font-weight: 700; font-size: clamp(28px, 4vw, 46px); line-height: 1.1; margin: 0 0 34px; max-width: 20ch; }
h3 { font-family: Silkscreen, monospace; font-size: 16px; letter-spacing: 1px; margin: 0 0 12px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; font-size: 25px; }
.cols p { margin: 0; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 34px; }
.card { background: #fff8ec; padding: 30px 30px 26px; color: var(--brown); font-size: 23px; }
.card p { margin: 0; }
.glyph { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 18px; background: var(--brown); color: var(--paper); font-size: 26px; }

/* ---------- company + footer ---------- */
.company { background: var(--paper-deep); padding: 100px max(24px, 6vw); }
.company-card { max-width: 820px; margin: 0 auto; background: #fff8ec; padding: 40px 44px; color: var(--brown); font-size: 23px; }
.company-card h2 { margin-bottom: 20px; }
.company-card p { margin: 0 0 26px; }
.company-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0; }
.company-card dt { font-family: Silkscreen, monospace; font-size: 11px; letter-spacing: 1px; padding-top: 6px; color: var(--brown-soft); }
.company-card dd { margin: 0; }
.foot { background: var(--night); color: #d9cfe8; padding: 44px max(24px, 6vw) max(44px, env(safe-area-inset-bottom)); font-size: 20px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 22px; font-family: Silkscreen, monospace; font-size: 11px; letter-spacing: 1px; margin-bottom: 18px; }
.foot p { margin: 0; color: #a99fc0; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s steps(6), transform .6s steps(6); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  body { font-size: 21px; }
  .bar nav a:not(:last-child) { display: none; }
  .hero { grid-template-columns: 1fr; padding-top: 96px; gap: 36px; text-align: left; }
  .window { width: min(360px, 100%); min-width: 0; }
  .cols, .cards { grid-template-columns: 1fr; gap: 26px; }
  .chapter { padding: 80px 20px; }
  .company { padding: 70px 16px; }
  .company-card { padding: 28px 22px; }
  .company-card dl { grid-template-columns: 1fr; gap: 2px; }
  .company-card dd { margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- the home: the cabin pans past and furnishes itself as you scroll ---------- */
.home { position: relative; height: 760vh; background: var(--paper); }
.home-pin { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; justify-content: center; gap: 26px; padding: 70px 0 30px; overflow: hidden; }
.home-head { padding: 0 max(24px, 6vw); }
.home-head h2 { margin-bottom: 0; }
.pano { position: relative; height: clamp(180px, 46vh, 520px); overflow: hidden; background: #1d213c; }
.pano-track { position: absolute; top: 0; left: 0; height: 100%; aspect-ratio: 3400 / 524; will-change: transform; }
.pano-track img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; max-width: none; }
.pano-track .full, .pano-track .pet { clip-path: inset(0 calc(100% - var(--reveal, 0%)) 0 0); }
.pano-track .pet { opacity: 0; transition: opacity .35s steps(4); }
.pano-track .pet.on { opacity: 1; }
.wipe { position: absolute; top: 0; bottom: 0; left: var(--reveal, 0%); width: 6px; margin-left: -3px;
  background: repeating-linear-gradient(180deg, #fff8ec 0 8px, transparent 8px 14px); opacity: var(--wipe-on, 1); transition: opacity .3s steps(3); }
.rooms { list-style: none; margin: 0; padding: 0 max(24px, 6vw); display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; font-size: 20px; line-height: 1.15; }
.rooms li { opacity: .22; transition: opacity .4s steps(4), transform .4s steps(4); transform: translateY(8px); }
.rooms li.on { opacity: 1; transform: none; }
.rooms b { display: block; font: 700 11px Silkscreen, monospace; letter-spacing: 1px; margin-bottom: 6px; }
.home-foot { margin: 0; padding: 0 max(24px, 6vw); color: var(--brown-soft); font-size: 20px; max-width: 70ch; }
@media (max-width: 860px) {
  .home { height: 820vh; }
  .home-pin { gap: 18px; padding-top: 64px; }
  .pano { height: 34vh; }
  .rooms { grid-template-columns: 1fr; gap: 0; position: relative; min-height: 4.6em; }
  .rooms li, .rooms li.on { position: absolute; left: max(24px, 6vw); right: max(24px, 6vw); opacity: 0; }
  .rooms li.now { opacity: 1; transform: none; }
  .home-foot { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { .home { height: auto; } .home-pin { position: static; height: auto; } }

/* ---------- meet pixal ---------- */
.meet { display: grid; grid-template-columns: 1.2fr .8fr; gap: 60px; align-items: center; }
.meet-copy p { font-size: 25px; margin: 0 0 18px; max-width: 34ch; }
.pal { margin: 0; justify-self: center; text-align: center; }
.pal-stage img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; }
.pal-stage img.on { opacity: 1; animation: bob 1.2s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ---------- things you do together: a carousel ---------- */
.together { background: var(--paper-deep); padding: 100px 0 80px; }
.together-head { max-width: 1120px; margin: 0 auto; padding: 0 max(24px, 6vw); }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: min(1040px, 86vw); gap: 40px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 10px max(24px, calc((100vw - 1040px) / 2)) 26px; scrollbar-width: none; outline: none; align-items: start; }
.carousel::-webkit-scrollbar { display: none; }
.slide { scroll-snap-align: center; display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; background: #fff8ec; padding: 26px; box-shadow: 0 -4px 0 0 var(--brown), 0 4px 0 0 var(--brown), -4px 0 0 0 var(--brown), 4px 0 0 0 var(--brown); }
.slide-pic { position: relative; overflow: hidden; background: #1b120e; color: #2a1f1a; }
.slide-pic.wide { aspect-ratio: 16 / 7.5; }
.slide-pic.tall { aspect-ratio: 9 / 12; max-height: 62vh; justify-self: center; width: 100%; }
.slide-pic img, .slide-pic video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.cook-flow img { opacity: 0; transition: opacity .4s steps(5); }
.cook-flow img.on { opacity: 1; }
.beats { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.beats li { flex: 1; text-align: center; font: 10px Silkscreen, monospace; letter-spacing: 1px; padding: 5px 0; background: rgba(27,18,14,.7); color: #c9b9a6; }
.beats li.on { background: var(--gold); color: #2a1f1a; }
.slide-copy h3 { font-size: 28px; margin-bottom: 14px; }
.slide-copy p { margin: 0; font-size: 24px; }
.carousel-nav { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 18px; color: var(--brown); }
.carousel-nav button { background: #fff8ec; border: 0; color: var(--brown); font-size: 14px; width: 44px; height: 40px; cursor: pointer; }
.carousel-nav button:hover { background: var(--brown); color: var(--paper); }
.dots { display: flex; gap: 10px; list-style: none; margin: 0; padding: 0; }
.dots li { width: 12px; height: 12px; background: var(--paper); box-shadow: 0 0 0 3px var(--brown); }
.dots li.on { background: var(--brown); }

@media (max-width: 860px) {
  .meet { grid-template-columns: 1fr; gap: 30px; }
  .pal { order: -1; }
  .together { padding: 70px 0 60px; }
  .carousel { grid-auto-columns: 88vw; gap: 18px; padding: 8px 6vw 22px; }
  .slide { grid-template-columns: 1fr; gap: 18px; padding: 16px; }
  .slide-pic.tall { aspect-ratio: 1 / 1; max-height: none; }
  .slide-copy h3 { font-size: 22px; margin-bottom: 8px; }
  .slide-copy p { font-size: 20px; }
}

/* ---------- he says hello in the hero ---------- */
.hello { position: relative; display: block; width: clamp(96px, 8vw, 132px); text-decoration: none; margin: 0 0 6px 4px; }
.hello-pal { position: relative; display: block; aspect-ratio: 240 / 200; }
.hello-pal img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.hello-pal img:last-child { animation: wave 1.6s steps(1) infinite; }
@keyframes wave { 0%, 45% { opacity: 0; } 50%, 95% { opacity: 1; } }
.bubble { position: absolute; left: 104%; bottom: 58%; white-space: nowrap; padding: 6px 10px; background: #fff8ec; color: #2a1f1a;
  font: 700 12px Silkscreen, monospace; letter-spacing: 1px; box-shadow: 0 0 0 3px #2a1f1a; animation: pop 3.2s steps(1) infinite; }
.bubble::after { content: ""; position: absolute; left: 8px; top: 100%; width: 9px; height: 9px; background: #2a1f1a;
  clip-path: polygon(0 0, 100% 0, 0 100%); margin-top: 3px; }
.bubble::after { left: -12px; top: auto; bottom: 4px; clip-path: polygon(100% 0, 100% 100%, 0 100%); margin: 0; }
@keyframes pop { 0%, 8% { opacity: 0; transform: translateY(4px); } 10%, 85% { opacity: 1; transform: none; } 87%, 100% { opacity: 0; } }
@media (max-width: 860px) { .hello { width: 84px; } .bubble { font-size: 10px; } }
@media (prefers-reduced-motion: reduce) { .hello-pal img:last-child, .bubble { animation: none; } .hello-pal img:last-child { opacity: 0; } }

/* ---------- a phone: Pixal in Meet Pixal, and the real screens ---------- */
.device { position: relative; width: 100%; aspect-ratio: 780 / 1688; border-radius: 13% / 6%; border: 10px solid #16161d; background: #000;
  box-shadow: 0 0 0 2px #3a3a46, 14px 18px 0 0 rgba(42, 31, 26, .18); }
.device::before, .device::after { content: ""; position: absolute; width: 4px; background: #2b2b35; border-radius: 2px; }
.device::before { left: -16px; top: 17%; height: 7%; box-shadow: 0 30px 0 #2b2b35; }
.device::after { right: -16px; top: 22%; height: 11%; }
.device .screen { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 10% / 4.6%; object-fit: cover; object-position: top; overflow: hidden; }
.device.sideways { aspect-ratio: 1948 / 916; border-radius: 6% / 13%; }
.device.sideways .screen { border-radius: 4.6% / 10%; }
.device.sideways::before { left: 22%; top: -16px; width: 7%; height: 4px; box-shadow: none; }
.device.sideways::after { display: none; }
.status { position: absolute; top: 0; left: 0; right: 0; height: 7%; z-index: 4; display: flex; align-items: center; justify-content: space-between;
  padding: 0 11% 0 12%; color: #2a1f1a; font: 700 11px Silkscreen, monospace; letter-spacing: .5px; }
.island { position: absolute; left: 50%; top: 22%; width: 32%; height: 48%; transform: translateX(-50%); background: #000; border-radius: 20px; }
.bars { font-size: 9px; letter-spacing: 1px; }

/* Pixal's own screen, in the game's colours: sky bands over the paper, a patch of lawn */
.pal { width: min(320px, 74vw); }
.pal-screen { background: linear-gradient(#a6dcf0 0 18%, #b6e3ef 18% 30%, #cfe7e4 30% 44%, #f1e6cf 44% 70%, #f6d9bd 70%); }
.pal-name { position: absolute; top: 11%; left: 0; right: 0; margin: 0; text-align: center; font: 700 28px Silkscreen, monospace; letter-spacing: 4px; color: #2a1f1a; }
.pal-say { position: absolute; top: 18.5%; left: 0; right: 0; margin: 0; text-align: center; font: 12px Silkscreen, monospace; letter-spacing: 1px; color: #714c37; }
.pal-stage { position: absolute; left: 8%; right: 8%; top: 41%; aspect-ratio: 240 / 200; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pal-stage:focus-visible { outline: 3px dashed #714c37; outline-offset: 4px; }
.pal-stage.hop img.on { animation: hop .7s steps(7); }
@keyframes hop { 0% { transform: none; } 30% { transform: translateY(-22%) scaleY(1.04); } 55% { transform: translateY(-26%); } 80% { transform: translateY(0) scale(1.06, .94); } 100% { transform: none; } }
.hearts { position: absolute; inset: 0; pointer-events: none; }
.hearts i { position: absolute; top: 18%; font-style: normal; font: 700 18px Silkscreen, monospace; color: #e0525a; animation: float 1.1s steps(9) forwards; }
@keyframes float { to { transform: translate(var(--dx), -90px); opacity: 0; } }
.pal-tip { position: absolute; left: 0; right: 0; bottom: 6%; margin: 0; text-align: center; font: 10px Silkscreen, monospace; letter-spacing: 1px; color: #f1e6cf; opacity: .85; }
.pal-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; background:
  repeating-linear-gradient(90deg, #6fae4f 0 12px, #79b957 12px 24px); box-shadow: inset 0 8px 0 #5c9a42; }

/* ---------- a closer look: the screens fan out as they arrive ---------- */
.fan { display: grid; grid-template-columns: repeat(4, 1fr); gap: 34px; align-items: start; perspective: 1200px; }
.fan figure { margin: 0; }
.fan figcaption { margin-top: 22px; font-size: 21px; line-height: 1.2; }
.fan figcaption b { display: block; font: 700 12px Silkscreen, monospace; letter-spacing: 1px; margin-bottom: 6px; }
.fan figure { transition: transform .7s cubic-bezier(.2, .8, .2, 1), opacity .45s ease-out; will-change: transform, opacity; contain: layout paint; }
.fan:not(.open) figure { opacity: 0; }
.fan:not(.open) figure:nth-child(1) { transform: translateX(110%) rotate(-6deg); }
.fan:not(.open) figure:nth-child(2) { transform: translateX(40%) rotate(-2deg); }
.fan:not(.open) figure:nth-child(3) { transform: translateX(-40%) rotate(2deg); }
.fan:not(.open) figure:nth-child(4) { transform: translateX(-110%) rotate(6deg); }
.fan.open figure:nth-child(odd) { transform: translateY(18px); }
@media (max-width: 860px) {
  .fan { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 62vw; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 20px 20px; margin: 0 -20px; }
  .fan figure { scroll-snap-align: center; opacity: 1 !important; transform: none !important; }
  .device { border-width: 7px; }
  .pal-name { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .fan figure { opacity: 1 !important; transform: none !important; transition: none; } }

/* ---------- the dial says it can be dragged ---------- */
.dial-track { position: relative; }
.dial-hint { position: absolute; bottom: calc(100% + 10px); left: calc(var(--at, .33) * (100% - 28px) + 14px); transform: translateX(-50%);
  white-space: nowrap; padding: 6px 10px; background: #fff8ec; color: #2a1f1a; font: 700 11px Silkscreen, monospace; letter-spacing: 1px;
  box-shadow: 0 0 0 3px #2a1f1a; pointer-events: none; animation: nudge 1.2s steps(2) infinite; transition: opacity .3s steps(3); }
.dial-hint::after { content: ""; position: absolute; left: 50%; top: 100%; width: 10px; height: 8px; margin: 3px 0 0 -5px; background: #2a1f1a; clip-path: polygon(0 0, 100% 0, 50% 100%); }
@keyframes nudge { 50% { transform: translate(-50%, -4px); } }
.dial:not(.touched) input::-webkit-slider-thumb { animation: glint 1.2s steps(2) infinite; }
.dial:not(.touched) input::-moz-range-thumb { animation: glint 1.2s steps(2) infinite; }
@keyframes glint { 50% { box-shadow: 0 0 0 4px #2a1f1a, 0 0 0 10px rgba(255, 248, 236, .55), 4px 4px 0 4px rgba(0,0,0,.25); } }
.dial.touched .dial-hint { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .dial-hint, .dial input::-webkit-slider-thumb { animation: none !important; } }
