@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("fonts/nunito.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fff7ea;
  --band: #ffefd6;
  --card: #ffffff;
  --ink: #2a2140;
  --muted: #625a7a;
  --line: #eadfca;
  --accent: #ff5d73;
  --accent-ink: #ffffff;
  --accent-2: #4d96ff;
  --yellow: #ffd23f;
  --teal: #2ec4b6;
  --radius: 22px;
  --shadow: 0 2px 0 rgba(42, 33, 64, 0.06), 0 12px 32px -12px rgba(42, 33, 64, 0.18);
  --head: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.12; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 4.4vw, 3.3rem); }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: inherit; }
q { quotes: "\201C" "\201D"; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2));
  background: rgba(255, 247, 234, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 600; font-size: 1.1rem; text-decoration: none; white-space: nowrap; }
.nav nav { display: flex; align-items: center; gap: 22px; font-weight: 700; font-size: 0.95rem; }
.nav nav a:not(.btn) { text-decoration: none; color: var(--muted); }
.nav nav a:not(.btn):hover { color: var(--ink); }
@media (max-width: 820px) {
  .nav nav a:not(.btn) { display: none; }
  .brand { font-size: 1rem; }
}
@media (max-width: 420px) {
  .brand { white-space: normal; line-height: 1.1; }
}

/* buttons */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font: 600 1rem/1.2 var(--head); text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, .chip:focus-visible, input:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.btn-ghost { background: var(--card); color: var(--ink); }
.btn-small { padding: 8px 16px; font-size: 0.9rem; box-shadow: 0 3px 0 var(--ink); }
.btn-small:hover { box-shadow: 0 4px 0 var(--ink); }
.cta-row { display: flex; flex-wrap: wrap; gap: 14px; }
.cta-row.center { justify-content: center; }

/* layout */
main > section { padding: 72px max(16px, calc((100vw - 1180px) / 2)); }
.band { background: var(--band); }
.section-head { max-width: 720px; margin-bottom: 28px; }
.section-head p { color: var(--muted); font-size: 1.1rem; }
.card { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }

/* hero */
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center;
  min-height: calc(100vh - 70px); min-height: calc(100svh - 70px);
  padding-top: 40px !important;
}
.eyebrow { font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--accent-2); }
.headline-box { display: flex; flex-direction: column; justify-content: flex-end; margin-bottom: 0.5em; }
.headline-box h1 { margin: 0; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 34em; margin-bottom: 28px; }
.hl { padding: 0 0.12em; border-radius: 0.25em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hl-1 { background: linear-gradient(transparent 55%, var(--yellow) 55%); }
.hl-2 { background: linear-gradient(transparent 55%, #9fe8df 55%); }
.hero-art { margin: 0; text-align: center; }
.hero-art .puzzle-svg { width: 100%; aspect-ratio: 1 / 1; max-height: 70vh; }
.hero-caption { font-family: var(--head); color: var(--muted); font-size: 1rem; margin: 4px 0 10px; }

/* hero carousel: a window of 5 square dots that slides along; the current one is wide and fills up over its turn */
.carousel { --dot: 14px; --dot-on: 40px; --dot-gap: 10px; display: inline-flex; align-items: center; gap: 10px; }
.car-window { overflow: hidden; width: calc(4 * var(--dot) + var(--dot-on) + 4 * var(--dot-gap)); padding: 6px 0; }
.car-track { display: flex; gap: var(--dot-gap); transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.2, 1); }
.car-dot {
  flex: none; position: relative; overflow: hidden; width: var(--dot); height: var(--dot); padding: 0;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--card); cursor: pointer;
  transition: width 0.4s cubic-bezier(0.3, 0.7, 0.2, 1), transform 0.4s, opacity 0.4s, background 0.2s;
}
.car-dot:hover { background: var(--yellow); }
.car-dot.active { width: var(--dot-on); }
.car-dot.edge:not(.active) { transform: scale(0.6); opacity: 0.55; }
.car-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); }
.car-arrow {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 10px; background: var(--card); color: var(--ink);
  box-shadow: 0 2px 0 var(--ink); transition: transform 0.12s, box-shadow 0.12s;
}
.car-arrow:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--ink); }
.car-arrow:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.car-arrow svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.car-dot:focus-visible, .car-arrow:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 8px; }
  .hero-art { order: -1; margin-bottom: 18px; }
  .hero-art .puzzle-svg { max-height: 46vh; }
}

/* puzzle svgs */
.puzzle-svg { display: block; width: 100%; user-select: none; -webkit-user-select: none; }
.piece .shape { stroke: var(--bg); stroke-width: 2.2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.card .piece .shape { stroke: var(--card); }
/* engraved line art, in mm like the outlines, so it scales with the piece */
.piece .art { fill: none; stroke: var(--ink); stroke-width: 0.42; stroke-linecap: round; stroke-linejoin: round; }
.piece .art.closed { fill: var(--ink); }
.piece .lift { transform-box: fill-box; transform-origin: center; transition: transform 0.18s, filter 0.18s; }
.explore .piece:hover .lift { transform: scale(1.07); filter: drop-shadow(0 3px 0 rgba(42, 33, 64, 0.35)); }
.fade { transition: opacity 0.6s; }
.fade.out { opacity: 0; }
.piece-label { font: 600 11px var(--head); fill: var(--muted); text-anchor: middle; pointer-events: none; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.chip {
  padding: 6px 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--card);
  font: 600 0.92rem var(--head); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.chip .dot { width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid var(--ink); }
.chip[aria-selected="true"], .chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip:hover { transform: translateY(-1px); }

/* viewer */
.viewer { position: relative; padding: 16px; }
.viewer .puzzle-svg { height: min(62vh, 560px); }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; padding: 12px 6px 2px; border-top: 2px dashed var(--line); margin-top: 8px; }
.viewer-title { flex: 1 1 240px; }
.viewer-title strong { font-family: var(--head); font-size: 1.15rem; }
.viewer-title span { color: var(--muted); }
.slider { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 0.9rem; color: var(--muted); flex: 1 1 260px; }
.slider input { flex: 1; accent-color: var(--accent); min-width: 80px; }
.hover-hint { margin: 6px 6px 0; font-size: 0.95rem; color: var(--muted); min-height: 1.6em; }
.hover-hint strong { color: var(--ink); }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.step { padding: 24px 22px 18px; position: relative; }
.step p { color: var(--muted); font-size: 1rem; margin: 0; }
.step-num {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-bottom: 12px;
  border: 2px solid var(--ink); border-radius: 12px; font: 600 1.2rem var(--head);
}
.step:nth-child(1) .step-num { background: var(--yellow); }
.step:nth-child(2) .step-num { background: #9fe8df; }
.step:nth-child(3) .step-num { background: #c8b6ff; }
.step:nth-child(4) .step-num { background: #ffb3c1; }
@media (max-width: 980px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }

/* signup */
.signup { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; padding: 36px; background: linear-gradient(135deg, #fff 0%, #fff 60%, #fff3d1 100%); }
.signup-text p { color: var(--muted); font-size: 1.08rem; }
.signup-text { display: flex; flex-direction: column; }
.signup-art { flex: 1; min-height: 220px; max-height: 360px; margin-top: 8px; }
@media (max-width: 860px) { .signup-art { min-height: 200px; height: 200px; } }
.signup-form { display: grid; gap: 14px; }
.signup-form > label { display: grid; gap: 6px; }
.signup-form .lbl, .signup-form legend { font-weight: 800; font-size: 0.95rem; }
.signup-form input[type="email"], .signup-form input[type="text"] {
  font: inherit; font-weight: 600; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 14px; background: var(--bg); color: var(--ink); width: 100%;
}
.signup-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
.signup-form legend { margin-bottom: 4px; padding: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.req { color: var(--accent); }
.opt { font-weight: 600; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.signup-form .btn { justify-self: start; }
.fineprint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.form-status { margin: 0; font-weight: 800; min-height: 1.6em; }
.form-status.ok { color: #138a63; }
.form-status.err { color: #c62842; }
@media (max-width: 860px) { .signup { grid-template-columns: 1fr; padding: 24px 20px; gap: 20px; } }

/* research */
.paper { padding: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.paper h3 { font-size: 1.6rem; margin-bottom: 0.3em; }
.authors { font-weight: 700; margin: 0; }
.affil, .venue { color: var(--muted); margin: 0; }
.venue { font-style: italic; }
.paper-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.link-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none;
  border: 2px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.link-tile:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
.link-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.link-tile:focus-visible, .copy-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.tile-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 12px; }
.tile-paper { background: var(--yellow); }
.tile-code { background: #9fe8df; }
.tile-icon svg, .ext, .copy-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon svg { width: 22px; height: 22px; }
.tile-text { display: grid; line-height: 1.25; }
.tile-text strong { font: 600 1.05rem var(--head); }
.tile-text small { color: var(--muted); font-size: 0.85rem; }
.ext { width: 16px; height: 16px; margin-left: auto; color: var(--muted); flex: none; }
.bibtex-box { border: 2px solid var(--ink); border-radius: 16px; overflow: hidden; min-width: 0; }
.bibtex-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 16px;
  background: var(--band); border-bottom: 2px solid var(--ink); font: 600 0.95rem var(--head);
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--card); color: var(--ink); font: 600 0.85rem var(--head);
}
.copy-btn:hover { background: var(--yellow); }
.copy-btn svg { width: 14px; height: 14px; }
.bibtex { margin: 0; padding: 14px 16px; background: var(--bg); font-size: 0.8rem; line-height: 1.55; overflow-x: auto; }
@media (max-width: 860px) { .paper { grid-template-columns: 1fr; padding: 22px 18px; } }
@media (max-width: 480px) { .paper-links { grid-template-columns: 1fr; } }

.footer { padding: 32px 16px 48px; text-align: center; color: var(--muted); font-size: 0.95rem; }
.footer p { margin: 0.3em 0; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .brand { font-size: 0.92rem; }
  .brand img { width: 24px; height: 24px; }
  /* one scrolling row of chips instead of many wrapped rows */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 4px 16px 8px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  main > section { padding-top: 52px; padding-bottom: 52px; }
  .viewer { padding: 10px; }
  .viewer .puzzle-svg { height: 58vh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .chip, .piece .lift, .car-track, .car-dot { transition: none; }
}
