/* Chime68's site. Light and dark follow the system setting. */

@font-face {
  font-family: "Chime68";
  src: url("fonts/chime68.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #fafaf8;
  --bg-alt: #f1f0ec;
  --surface: #ffffff;
  --text: #16161a;
  --text-2: #55555f;
  --text-3: #6f6f79;
  --line: #e3e2dd;
  --accent: #c94d22;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7de;
  --code-bg: #f1f0ec;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 12px 40px -12px rgba(20, 20, 30, 0.22);
  --radius: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  --pixel: "Chime68", ui-monospace, monospace;
  --wide: 1120px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --bg-alt: #141418;
    --surface: #18181d;
    --text: #ececef;
    --text-2: #a5a5b0;
    --text-3: #8a8a94;
    --line: #2a2a31;
    --accent: #ff7a45;
    --accent-ink: #160a04;
    --accent-soft: #2c1a12;
    --code-bg: #1f1f25;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 60px -20px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

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

a { color: inherit; }

p { margin: 0 0 1em; }

code, pre, kbd { font-family: var(--mono); font-size: 0.87em; }

code { padding: 0.1em 0.35em; background: var(--code-bg); border-radius: 5px; }

pre {
  margin: 0 0 1em;
  padding: 16px 18px;
  background: var(--code-bg);
  border-radius: 12px;
  overflow-x: auto;
  line-height: 1.55;
}

pre code { padding: 0; background: none; font-size: 0.92em; }

kbd {
  display: inline-block;
  padding: 0.1em 0.5em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82em;
  white-space: nowrap;
}

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }

/* The emulator's own font, kept to small labels */

.eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  color: var(--accent);
  font: 12px/1 var(--pixel);
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img { width: 32px; height: 32px; image-rendering: pixelated; }

.site-nav { display: flex; align-items: center; gap: 24px; margin-left: auto; font-size: 15px; }

.site-nav a { color: var(--text-2); text-decoration: none; }

.site-nav a:hover { color: var(--text); }

/* Buttons */

.buttons { display: flex; flex-wrap: wrap; gap: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, filter 0.15s;
}

.button:hover { transform: translateY(-1px); border-color: var(--text-3); }

.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.button.primary:hover { filter: brightness(1.08); }

.button svg { width: 18px; height: 18px; }

.site-nav .button { height: 36px; padding: 0 16px; font-size: 14px; color: var(--text); }

/* Hero */

.hero { padding: 80px 0 48px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 56px;
  align-items: center;
}

.hero h1 {
  margin: 0 0 22px;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
}

.hero h1 em { font-style: normal; color: var(--accent); }

.hero .lede { margin: 0 0 32px; color: var(--text-2); font-size: 20px; line-height: 1.55; max-width: 34em; }

.hero .note { margin: 20px 0 0; color: var(--text-3); font-size: 14px; }

.shot {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  outline: 1px solid var(--line);
}

.hero .shot { border-radius: var(--radius); transform: rotate(1.2deg); }

/* Numbers under the hero */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 64px auto 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.stats li { padding: 22px 24px; background: var(--bg); }

.stats strong { display: block; font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }

.stats span { color: var(--text-2); font-size: 14px; }

/* Sections */

section { padding: 96px 0; }

section.alt { background: var(--bg-alt); }

.section-head { max-width: 720px; margin: 0 0 44px; }

.section-head h2 {
  margin: 0 0 14px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.section-head p { margin: 0; color: var(--text-2); font-size: 19px; }

h3 { margin: 0 0 8px; font-size: 19px; line-height: 1.3; letter-spacing: -0.01em; }

/* Cards */

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.card {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card p { margin: 0; color: var(--text-2); font-size: 16px; }

.card .icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card .icon svg { width: 22px; height: 22px; }

/* The Macs */

.families { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.family { padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* An odd one out takes the whole row. */
.family:last-child:nth-child(odd) { grid-column: 1 / -1; }

.family header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.family header h3 { margin: 0; font-size: 22px; }

.family header span { color: var(--accent); font: 12px/1 var(--pixel); white-space: nowrap; }

.family > p { color: var(--text-2); font-size: 15px; margin: 0 0 16px; }

.machines { margin: 0; padding: 0; list-style: none; }

.machines li {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr);
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.machines strong { font-weight: 600; }

.machines span { color: var(--text-2); }

/* Grid items may shrink below their content (a long line of code
   scrolls instead of widening the page). */
.split > *, .families > * { min-width: 0; }

/* Downloads */

.downloads { margin: 18px 0 22px; padding: 0; list-style: none; }

.downloads li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.downloads a { color: var(--accent); font-weight: 600; text-decoration: none; }

.downloads a:hover { text-decoration: underline; }

.downloads span { color: var(--text-2); text-align: right; }

/* Systems */

.systems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

.systems .card h3 { font-size: 22px; }

.systems .card p { font-size: 15px; }

.systems-note { margin: 0 0 56px; color: var(--text-2); font-size: 16px; max-width: 760px; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

.gallery figure { margin: 0; }

.gallery figcaption { margin-top: 12px; color: var(--text-2); font-size: 14px; }

/* Two columns */

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.split .card { padding: 32px; }

.split .card > p { margin-bottom: 18px; }

.split .card > :last-child { margin-bottom: 0; }

/* Keys */

.keys-title { margin: 56px 0 4px; }

.keys { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 40px; }

.keys li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }

.keys li span:last-child { color: var(--text-2); text-align: right; }

.keys-note { margin: 20px 0 0; color: var(--text-2); font-size: 15px; }

/* ROMs */

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  padding: 28px;
  margin-bottom: 32px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.callout svg { width: 28px; height: 28px; color: var(--accent); }

.callout h3 { margin-top: 2px; }

.callout p { margin: 0; color: var(--text-2); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th, td { padding: 13px 20px; text-align: left; vertical-align: top; }

th { color: var(--text-3); font: 12px/1 var(--pixel); padding-top: 18px; }

tbody tr { border-top: 1px solid var(--line); }

td:last-child { color: var(--text-2); }

.after { margin: 24px 0 0; color: var(--text-2); font-size: 15px; }

/* Footer */

.site-footer { padding: 48px 0 56px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 14px; }

.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 40px; }

.site-footer p { margin: 0; max-width: 560px; }

.site-footer nav { display: flex; gap: 20px; }

.site-footer a { text-decoration: none; }

.site-footer a:hover { color: var(--text); }

/* Narrower screens */

@media (max-width: 960px) {
  .cards, .systems { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .site-nav a:not(.button) { display: none; }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .hero { padding: 44px 0 24px; }
  .hero-grid, .families, .split { grid-template-columns: 1fr; gap: 40px; }
  .split, .families { gap: 16px; }
  .hero .shot { transform: none; }
  .hero .lede { font-size: 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); margin-top: 44px; }
  .stats li { padding: 18px; }
  .stats strong { font-size: 22px; }
  section { padding: 64px 0; }
  .section-head { margin-bottom: 32px; }
  .section-head p { font-size: 17px; }
  .cards, .systems, .gallery, .keys { grid-template-columns: 1fr; }
  .family, .split .card, .card { padding: 22px; }
  .machines li { grid-template-columns: 1fr; gap: 2px; }
  .callout { grid-template-columns: 1fr; gap: 12px; padding: 22px; }
  th, td { padding: 12px 14px; }
}

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

/* Motion. Everything here is off with prefers-reduced-motion, and the
   scroll reveals only hide things once script.js is running. */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(32px) rotate(4deg) scale(0.96); }
  to { opacity: 1; transform: rotate(1.2deg); }
}

@keyframes float {
  0%, 100% { transform: rotate(1.2deg) translateY(0); }
  50% { transform: rotate(0.6deg) translateY(-8px); }
}

@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .hero-grid > div > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .hero-grid > div > :nth-child(2) { animation-delay: 0.08s; }
  .hero-grid > div > :nth-child(3) { animation-delay: 0.16s; }
  .hero-grid > div > :nth-child(4) { animation-delay: 0.24s; }
  .hero-grid > div > :nth-child(5) { animation-delay: 0.32s; }

  .hero .shot {
    animation:
      settle 1s 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both,
      float 7s 1.2s ease-in-out infinite;
  }

  .stats li { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(0.45s + var(--i, 0) * 0.08s); }

  /* The hero's label types itself out, with a blinking cursor. */
  .typing { position: relative; }
  .typing::after {
    content: "";
    display: inline-block;
    width: 0.6em;
    height: 1em;
    margin-left: 3px;
    vertical-align: -0.1em;
    background: currentColor;
    animation: blink 1s steps(1) infinite;
  }

  .js [data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: calc(var(--i, 0) * 70ms);
  }

  .js [data-reveal].in { opacity: 1; transform: none; }

  .card, .family, .gallery .shot {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  }

  .card:hover, .family:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--text-3); }

  .gallery figure:hover .shot { transform: translateY(-4px) scale(1.02); }

  .card .icon { transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }

  .card:hover .icon { transform: rotate(-8deg) scale(1.1); }

  .button.primary svg { transition: transform 0.25s ease; }

  .button.primary:hover svg { transform: translateY(2px); }

  /* Once revealed, a card's hover transition shouldn't wait out its stagger. */
  .js [data-reveal].in.card, .js [data-reveal].in.family { transition-delay: 0s; }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 760px) {
  .hero .shot { animation: rise 0.8s 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
}
