/* Jo Engine – site styles
   Palette taken from the Saturn itself: the deep indigo of the boot screen,
   the planet's amber ring, and the pale lilac of BIOS menu text. */

/* Fonts are self-hosted (SIL Open Font License): no request to third parties. */
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/chakra-petch-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/jetbrains-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  --night: #1a1745;      /* page background, boot-screen indigo */
  --deep: #120f33;       /* code panes, alt sections */
  --plane: #26226a;      /* raised surfaces */
  --line: #3b3690;       /* borders */
  --text: #ecebff;       /* body text */
  --muted: #a9a6d6;      /* secondary text */
  --ring: #f6b62f;       /* accent: the gold ring of the logo's O */
  --ring-soft: #ffe39a;
  --steel: #c9d0dc;      /* the logo's metal ring */
  --sky: #8cc4ff;        /* links */

  --font-display: "Chakra Petch", "Trebuchet MS", sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.7rem;
  --step-3: clamp(1.9rem, 3.2vw, 2.4rem);
  --step-4: clamp(2.4rem, 5.6vw, 4.1rem);

  --gutter: clamp(16px, 4vw, 40px);
  --radius-s: 4px;
  --radius-m: 10px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--sky); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: #fff; }

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5em;
  letter-spacing: -.005em;
}
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1em; }

code { font-family: var(--font-code); font-size: .88em; background: var(--plane); padding: .08em .35em; border-radius: var(--radius-s); }

.wrap { width: min(1160px, 100%); margin: 0 auto; padding: 0 var(--gutter); }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--ring); color: var(--deep); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--night) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { height: 38px; width: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-s); font-size: .97rem; }
.nav a:hover, .nav a[aria-current="true"] { color: var(--text); background: var(--plane); }
.lang {
  position: relative; display: inline-flex; align-items: center; margin-left: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--text);
}
.lang:hover, .lang:focus-within { border-color: var(--ring); }
.lang svg { position: absolute; left: 9px; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; pointer-events: none; }
.lang select {
  appearance: none; -webkit-appearance: none; background: transparent; color: inherit; border: 0;
  font: 600 .88rem var(--font-body); padding: 7px 28px 7px 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px top 50%, right 8px top 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.lang select:focus { outline: none; }
.lang:focus-within { outline: 2px solid var(--ring); outline-offset: 2px; }
.lang option { background: var(--deep); color: var(--text); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .menu-btn {
    display: grid; gap: 5px; place-content: center; width: 44px; height: 44px;
    background: transparent; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer;
  }
  .menu-btn span { display: block; width: 20px; height: 2px; background: var(--text); transition: transform .2s; }
  .menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .nav {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--deep); border-bottom: 1px solid var(--line); padding: 8px var(--gutter) 16px; display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px; }
  .lang { align-self: flex-start; margin: 8px 0 0 12px; }
}

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(12px, 2.5vw, 32px) 0 clamp(40px, 5vw, 72px); isolation: isolate; }

/* Three tiled layers drifting at different speeds: a nod to the VDP2's NBG scroll planes. */
.planes { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.plane { position: absolute; inset: -40px; }
.plane--3 { background-image: radial-gradient(circle, #ffffff22 1px, transparent 1.5px); background-size: 22px 22px; animation: drift 90s linear infinite; }
.plane--2 { background-image: radial-gradient(circle, #ffffff30 1.2px, transparent 1.8px); background-size: 61px 47px; animation: drift 55s linear infinite; }
.plane--1 {
  background:
    linear-gradient(to bottom, transparent 55%, var(--night) 100%),
    repeating-linear-gradient(90deg, transparent 0 63px, #3b369055 63px 64px),
    repeating-linear-gradient(0deg, transparent 0 63px, #3b369055 63px 64px);
  mask-image: linear-gradient(to bottom, transparent 40%, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 40%, #000 100%);
  transform: perspective(500px) rotateX(58deg) translateY(30%);
  transform-origin: bottom;
  animation: floor 4s linear infinite;
}
@keyframes drift { to { background-position: 440px 0; } }
@keyframes floor { to { background-position: 0 0, 0 0, 0 64px; } }

.hero__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(32px, 5vw, 64px); align-items: center; }

.planet { width: min(280px, 70%); margin: 0 0 4px -10px; overflow: visible; }

/* The one orchestrated moment: the ring draws itself around the planet on load. */
.planet .jo-sphere { animation: rise 1s cubic-bezier(.2,.7,.2,1) both; transform-box: fill-box; transform-origin: center; }
.planet .jo-ring { stroke-dasharray: 700; stroke-dashoffset: 700; animation: draw 1.6s .35s cubic-bezier(.6,0,.2,1) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.9); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

.hero h1 { font-size: var(--step-4); font-weight: 700; max-width: 13ch; margin-bottom: .35em; letter-spacing: -.02em; }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 36em; }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 28px; }
.btn {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px;
  font: 600 1rem var(--font-display); text-decoration: none; color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius-s); background: color-mix(in srgb, var(--plane) 70%, transparent);
}
.btn:hover { border-color: var(--text); color: #fff; }
.btn--primary { background: var(--ring); border-color: var(--ring); color: #2a1406; }
.btn--primary:hover { background: var(--ring-soft); border-color: var(--ring-soft); color: #2a1406; }

.facts { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: 0; font-family: var(--font-display); font-weight: 600; }

/* code card */
.code { container-type: inline-size; margin: 0; background: var(--deep); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 30px 60px -30px #00000099, 0 0 0 6px #ffffff06; overflow: hidden; }
.code__bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.code__file { font-family: var(--font-code); font-size: .85rem; color: var(--muted); }
.code__copy { font: 600 .82rem var(--font-display); color: var(--text); background: var(--plane); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 12px; cursor: pointer; }
.code__copy:hover { border-color: var(--ring); }
.code pre { margin: 0; padding: 20px 18px; overflow: hidden; white-space: pre; font: clamp(.66rem, 2.4cqi, .9rem)/1.7 var(--font-code); color: #dcdaf7; tab-size: 4; }
.code pre code { background: none; padding: 0; font-size: inherit; }
/* the longest line is 62 characters: the font scales with the card so it always fits;
   on very narrow screens long lines wrap instead of scrolling */
@container (max-width: 400px) {
  .code pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
.code .k { color: #ff9ec7; }
.code .s { color: var(--ring-soft); }
.code .t { color: #9fd0ff; }
.code .f { color: #b8f0c8; }
.code .n { color: #ffbe7a; }
.code figcaption { padding: 12px 18px 16px; font-size: var(--step--1); color: var(--muted); border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; }
  .planet { width: min(260px, 70%); }
}

/* ---------- sections ---------- */
.section { padding: clamp(44px, 6vw, 80px) 0; }
.section--alt { background: var(--deep); }
.section__head { max-width: 46rem; margin-bottom: clamp(24px, 3.5vw, 40px); }
.section__head p { color: var(--muted); font-size: var(--step-1); line-height: 1.5; }

/* engine: one tile per Saturn chip */
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.chip { padding: 26px 24px 22px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--plane) 35%, transparent); }
.chip:nth-child(3n) { border-right: 0; }
.chip:nth-last-child(-n+3) { border-bottom: 0; }
.chip h3 { display: flex; flex-direction: column; gap: 6px; font-size: var(--step-1); }
.chip__id {
  align-self: flex-start; font-family: var(--font-code); font-size: .8rem; font-weight: 600; color: var(--ring-soft);
  border: 1px solid #f2a33a77; padding: 2px 8px; border-radius: var(--radius-s); letter-spacing: .04em;
}
.chip ul { margin: 0; padding: 0; list-style: none; }
.chip__shot { margin-top: 16px; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; image-rendering: pixelated; border: 1px solid var(--line); }
.chip li { padding: 5px 0 5px 18px; position: relative; color: #d6d4f2; font-size: .98rem; line-height: 1.45; }
.chip li::before { content: ""; position: absolute; left: 0; top: .85em; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ring); }

@media (max-width: 900px) {
  .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip:nth-child(3n) { border-right: 1px solid var(--line); }
  .chip:nth-child(2n) { border-right: 0; }
  .chip:nth-last-child(-n+3) { border-bottom: 1px solid var(--line); }
  .chip:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 560px) {
  .chips { grid-template-columns: 1fr; }
  .chip, .chip:nth-child(n) { border-right: 0; border-bottom: 1px solid var(--line); }
  .chip:last-child { border-bottom: 0; }
}

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: center; margin-top: clamp(32px, 4vw, 56px); }
.editor__shot { margin: 0; border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--line); }
.editor.no-shot { grid-template-columns: 1fr; }
.editor__text { max-width: 34rem; }
.editor__text h3 { font-size: var(--step-2); }
.editor__text p { color: #d6d4f2; }
@media (max-width: 800px) { .editor { grid-template-columns: 1fr; } }

.link { font-family: var(--font-display); font-weight: 600; }

/* get started: a real sequence, so it is numbered */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.steps li { counter-increment: step; position: relative; padding: 64px 24px 8px 0; }
.steps li::before {
  content: counter(step); position: absolute; top: 0; left: 0;
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  font: 700 1.15rem var(--font-display); color: #2a1406; background: var(--ring);
}
.steps li::after { content: ""; position: absolute; top: 21px; left: 52px; right: 10px; height: 2px; background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px); }
.steps li:last-child::after { display: none; }
.steps p { color: #d6d4f2; font-size: .98rem; }
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; }
  .steps li { padding: 0 0 28px 64px; }
  .steps li::after { top: 50px; bottom: 4px; left: 20px; right: auto; width: 2px; height: auto; background: repeating-linear-gradient(180deg, var(--line) 0 8px, transparent 8px 14px); }
}

/* games */
.games { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.game {
  display: flex; flex-direction: column; padding: 0 24px 24px; border-radius: var(--radius-m); overflow: hidden;
  background: var(--plane); border-top: 3px solid var(--ring);
}
.game__shot { position: relative; margin: 0 -24px 20px; aspect-ratio: 4 / 3; background: #0d0b26; overflow: hidden; }
.game__shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* No screenshot yet: show the title on a dark "screen" instead of a broken image */
.game__shot.is-empty {
  display: grid; place-items: center; text-align: center; padding: 24px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, #ffffff08 2px 3px),
    radial-gradient(ellipse at 50% 40%, #2a2670, #0d0b26 75%);
}
.game__shot.is-empty::before { content: attr(data-title); font: 700 clamp(1.4rem, 3vw, 1.9rem)/1.1 var(--font-display); color: #ffffff2e; }
.game:nth-child(4n+2) { border-top-color: #8cc4ff; }
.game:nth-child(4n+3) { border-top-color: #b8f0c8; }
.game:nth-child(4n+4) { border-top-color: #ff9ec7; }
.game h3 { font-size: var(--step-2); margin-bottom: .2em; }
.game__meta { color: var(--muted); font-size: var(--step--1); margin-bottom: .9em; }
.game p:not(.game__meta) { color: #dcdaf7; flex: 1; font-size: .98rem; }
.note { margin-top: 32px; color: var(--muted); }

/* press */
.press { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(32px, 5vw, 64px); }
.press h3 { font-size: var(--step-1); color: var(--ring-soft); margin-bottom: 18px; }
.press__sub { margin-top: 40px; }
.book { display: grid; grid-template-columns: 18px 1fr; gap: 16px; padding: 18px 18px 18px 0; margin-bottom: 16px; background: var(--plane); border-radius: 0 var(--radius-m) var(--radius-m) 0; }
.book__spine { background: linear-gradient(90deg, #b8722a, var(--ring) 40%, #b8722a); border-radius: 2px 0 0 2px; }
.book--es .book__spine { background: linear-gradient(90deg, #4b63b8, var(--sky) 40%, #4b63b8); }
.book h4 { font-size: 1.12rem; margin-bottom: .35em; }
.book p { margin: 0; color: #dcdaf7; }
.press__meta { font-size: var(--step--1); color: var(--muted) !important; margin-top: 6px !important; }

.articles { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.articles li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 4px 14px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.articles a { text-decoration: none; color: var(--text); font-weight: 700; }
.articles a:hover { color: var(--ring-soft); text-decoration: underline; }
.src { color: var(--muted); font-size: var(--step--1); white-space: nowrap; }
.tag { font: 600 .72rem var(--font-code); color: var(--sky); border: 1px solid #8cc4ff66; border-radius: 3px; padding: 1px 5px; }
.yr { font-family: var(--font-display); font-size: var(--step--1); color: var(--muted); min-width: 2.6em; text-align: right; }
@media (max-width: 640px) {
  .articles li { grid-template-columns: auto auto 1fr; }
  .articles a { grid-column: 1 / -1; }
  .yr { text-align: left; }
}
.refs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.refs a { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .95rem; }
.refs a:hover { border-color: var(--sky); }
@media (max-width: 860px) { .press { grid-template-columns: 1fr; } }

/* learn */
.learn { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.learn__item { display: block; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-m); text-decoration: none; color: var(--text); }
.learn__item:hover { border-color: var(--sky); background: color-mix(in srgb, var(--plane) 50%, transparent); color: var(--text); }
.learn__item h3 { color: var(--sky); }
.learn__item p { margin: 0; color: #d6d4f2; font-size: .98rem; }
@media (max-width: 960px) { .learn { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .learn { grid-template-columns: 1fr; } }

/* community + about */
.community { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(40px, 6vw, 80px); }
.community > div > p { color: #d6d4f2; }
.comm { list-style: none; margin: 24px 0 0; padding: 0; }
.comm li { border-top: 1px solid var(--line); }
.comm li:last-child { border-bottom: 1px solid var(--line); }
.comm a { display: block; padding: 14px 0; text-decoration: none; color: var(--text); font-weight: 700; }
.comm a:hover { color: var(--ring-soft); }
.about p { color: #d6d4f2; max-width: 38em; }
.thanks { font-size: .95rem; color: var(--muted) !important; }
@media (max-width: 860px) { .community { grid-template-columns: 1fr; } }

/* footer */
.footer { border-top: 1px solid var(--line); padding: 24px 0 28px; color: var(--muted); font-size: var(--step--1); }
.footer p { margin: 0 0 6px; }

/* motion off */
@media (prefers-reduced-motion: reduce) {
  .plane, .planet .jo-sphere { animation: none !important; }
  .planet .jo-ring { animation: none; stroke-dashoffset: 0; }
}

/* Japanese and Chinese: the Latin fonts have no CJK glyphs, so fall back to good system fonts */
:lang(ja) { --font-body: "Atkinson Hyperlegible", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
            --font-display: "Chakra Petch", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif; }
:lang(zh) { --font-body: "Atkinson Hyperlegible", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
            --font-display: "Chakra Petch", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:lang(ja) body, :lang(zh) body { line-height: 1.75; }
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3, :lang(zh) h1, :lang(zh) h2, :lang(zh) h3 { letter-spacing: 0; line-height: 1.3; }
:lang(ja) .hero h1, :lang(zh) .hero h1 { max-width: 16ch; font-size: clamp(2.1rem, 4.6vw, 3.4rem); }
:lang(de) .hero h1 { max-width: 16ch; }
h1, h2 { text-wrap: balance; }
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3 { word-break: auto-phrase; }
