/* The Week Eye. Two styles (data-style: fun default, modern) x light/dark (data-theme, or the OS).
   Every color comes from the tokens below; components never set a color directly. */
@font-face { font-family: "Bungee"; src: url("/assets/fonts/bungee-latin.woff2") format("woff2"); font-display: swap; font-weight: 400; }
@font-face { font-family: "Syne"; src: url("/assets/fonts/syne-800-latin.woff2") format("woff2"); font-display: swap; font-weight: 800; }

:root {
  /* Fun (Mall Poster), day */
  --bg: #fff6dc; --surface: #ffffff; --surface-2: #fff0c2; --ink: #2e1600; --muted: #6b4a1f; --line: #ecd9a6;
  --head: #8a3500; --link: #8a3500; --accent: #8a3500; --accent-ink: #ffffff;
  --band: #ffc845; --band-ink: #5c2300; --shadow-1: #e5317e; --shadow-2: #00b3a4;
  --ok: #1f6b34; --bad: #a32018; --focus: #2b1055; --dot: #2e1600;
  --display: "Bungee", Impact, "Arial Black", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 8px; --wrap: 1080px;
  color-scheme: light;
}
:root[data-style="modern"] {
  --bg: #eef0f6; --surface: #ffffff; --surface-2: #e4e7f1; --ink: #1a1c30; --muted: #535772; --line: #d5d8e6;
  --head: #1a1c30; --link: #0b6e6a; --accent: #0b6e6a; --accent-ink: #ffffff;
  --band: #1a1c30; --band-ink: #eef0f6; --shadow-1: transparent; --shadow-2: transparent;
  --ok: #1f6b34; --bad: #a32018; --focus: #0b6e6a; --dot: #1a1c30;
  --display: "Syne", "Trebuchet MS", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2b1055; --surface: #3a1d6e; --surface-2: #33175f; --ink: #ffffff; --muted: #d6c8f0; --line: #573a8c;
    --head: #ffc845; --link: #ffc845; --accent: #ffc845; --accent-ink: #2b1055;
    --band: #1f0b40; --band-ink: #ffc845; --shadow-1: #e5317e; --shadow-2: #00b3a4;
    --ok: #7ee2a0; --bad: #ff9b93; --focus: #ffc845; --dot: #ffffff; color-scheme: dark;
  }
  :root[data-style="modern"]:not([data-theme="light"]) {
    --bg: #12131f; --surface: #1b1d2d; --surface-2: #232638; --ink: #e8e9f3; --muted: #a3a6bd; --line: #2e3147;
    --head: #e8e9f3; --link: #3cc3bb; --accent: #3cc3bb; --accent-ink: #0b1a1a;
    --band: #0c0d17; --band-ink: #e8e9f3; --shadow-1: transparent; --shadow-2: transparent;
    --ok: #7ee2a0; --bad: #ff9b93; --focus: #3cc3bb; --dot: #e8e9f3; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #2b1055; --surface: #3a1d6e; --surface-2: #33175f; --ink: #ffffff; --muted: #d6c8f0; --line: #573a8c;
  --head: #ffc845; --link: #ffc845; --accent: #ffc845; --accent-ink: #2b1055;
  --band: #1f0b40; --band-ink: #ffc845; --shadow-1: #e5317e; --shadow-2: #00b3a4;
  --ok: #7ee2a0; --bad: #ff9b93; --focus: #ffc845; --dot: #ffffff; color-scheme: dark;
}
:root[data-style="modern"][data-theme="dark"] {
  --bg: #12131f; --surface: #1b1d2d; --surface-2: #232638; --ink: #e8e9f3; --muted: #a3a6bd; --line: #2e3147;
  --head: #e8e9f3; --link: #3cc3bb; --accent: #3cc3bb; --accent-ink: #0b1a1a;
  --band: #0c0d17; --band-ink: #e8e9f3; --shadow-1: transparent; --shadow-2: transparent;
  --ok: #7ee2a0; --bad: #ff9b93; --focus: #3cc3bb; --dot: #e8e9f3; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.6 var(--body); }
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r); font-weight: 700; }
.skip:focus { top: 8px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main { display: block; padding-block: 28px 56px; }
h1, h2, h3 { font-family: var(--display); color: var(--head); line-height: 1.15; text-wrap: balance; margin: 0 0 .5em; font-weight: 400; }
:root[data-style="modern"] h1, :root[data-style="modern"] h2, :root[data-style="modern"] h3 { font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4.6vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.75rem); }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
.prose { max-width: none; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.poster { text-shadow: .05em .05em 0 var(--shadow-1), .1em .1em 0 var(--shadow-2); }

/* header */
.site-head { background: var(--band); color: var(--band-ink); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding-block: 10px; }
.logo { display: inline-flex; align-items: center; color: var(--band-ink); text-decoration: none; margin-right: auto; }
.logo svg { display: block; height: 44px; width: auto; }
.icon-btn.nav-toggle { display: none; }
.nav ul { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; }
.nav a { color: var(--band-ink); text-decoration: none; font-weight: 650; padding: 6px 2px; display: inline-block; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: .3em; text-decoration-thickness: 3px; }
.head-tools { display: flex; align-items: center; gap: 10px; }
.icon-btn { background: transparent; border: 2px solid currentColor; color: var(--band-ink); border-radius: 999px; width: 40px; height: 40px; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.me { display: inline-flex; align-items: center; gap: 8px; color: var(--band-ink); font-weight: 650; text-decoration: none; }
.me img, .avatar { border-radius: 50%; background: var(--surface-2); object-fit: cover; }
@media (max-width: 760px) {
  .icon-btn.nav-toggle { display: inline-grid; }
  .logo svg { height: 36px; }
  .head-tools { gap: 8px; }
  .nav { order: 3; width: 100%; }
  .nav[data-open="false"] { display: none; }
  .nav ul { flex-direction: column; gap: 0; padding-bottom: 8px; }
  .nav a { padding: 10px 2px; }
}

/* buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: var(--r);
       border: 2px solid var(--accent); background: transparent; color: var(--accent); font: 700 1rem var(--body); text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-big { font-family: var(--display); font-size: 1.5rem; padding: 14px 40px; min-height: 64px; letter-spacing: .02em; font-weight: 400; }
:root[data-style="modern"] .btn-big { font-weight: 800; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; font: inherit; cursor: pointer; }
label { font-weight: 650; }
.field { display: grid; gap: 6px; }
.field small { color: var(--muted); font-weight: 400; }
input[type="text"], input[type="email"], input[type="search"], textarea, select {
  font: 1rem var(--body); color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 140px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--focus); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.switch { display: flex; gap: 12px; align-items: center; font-weight: 400; cursor: pointer; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; border: 2px solid var(--muted); margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px var(--muted); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { left: 22px; }
.form { display: grid; gap: 16px; max-width: 640px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.notice { border-radius: var(--r); padding: 12px 16px; background: var(--surface-2); border: 2px solid var(--line); }
.notice.ok { border-color: var(--ok); }
.notice.bad { border-color: var(--bad); }
.msg { min-height: 1.6em; margin: 0; font-weight: 650; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }

/* panels */
.panel { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line); border-radius: 999px; padding: 2px 12px; font-weight: 650; font-size: .9rem; background: var(--surface); }
.eyebrow { font: 700 .8rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }

/* difficulty meter: five steps, the current one filled and named */
.meter { display: inline-grid; gap: 6px; }
.meter ol { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.meter li { width: 34px; height: 10px; border-radius: 3px; background: var(--line); }
.meter li.on { background: var(--accent); }
.meter span { font-weight: 700; }

/* play */
.week-head { display: grid; gap: 10px; margin-bottom: 18px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.stage { display: grid; gap: 14px; justify-items: center; }
.start-box { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 36px 16px; border: 3px dashed var(--line); border-radius: var(--r); background: var(--surface); width: 100%; }
.figure { display: grid; gap: 8px; max-width: 100%; overflow-x: auto; }
.guides { position: relative; height: 14px; }
.guides span { position: absolute; top: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--dot); transform: translateX(-50%); }
.puzzle-img { display: block; max-width: none; image-rendering: pixelated; border-radius: 2px; }
.answer { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; max-width: 560px; }
.answer input { flex: 1 1 200px; font: 600 1.15rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.timer { font: 700 1.1rem var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.result { text-align: center; display: grid; gap: 8px; justify-items: center; }
.big-time { font: 400 clamp(2.4rem, 8vw, 4rem) var(--display); color: var(--head); line-height: 1; }
.rotate-hint { display: none; text-align: center; gap: 10px; justify-items: center; }
.panel > :last-child, .stack > :last-child { margin-bottom: 0; }
.panel h2, .stack h2 { margin-bottom: 0; }
.rotate-hint svg { width: 72px; height: 72px; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .rotate-hint svg { animation: tilt 2.4s ease-in-out infinite; }
  @keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}
.overlay { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: center; overflow: auto;
           padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.overlay[hidden] { display: none; }
.overlay .guides span { background: #fff; }
.overlay-close { position: fixed; top: max(8px, env(safe-area-inset-top, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); z-index: 51;
                 background: #fff; color: #000; border: 0; border-radius: 999px; min-height: 44px; padding: 8px 16px; font-weight: 700; cursor: pointer; }
.overlay-tip { position: fixed; bottom: max(8px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); text-align: center; color: #fff; background: rgba(0, 0, 0, .78); border-radius: 999px; padding: 4px 14px; font-size: .9rem; margin: 0; pointer-events: none; transition: opacity .6s; }
.overlay-tip.gone { opacity: 0; }

/* loaders */
.loader { display: inline-grid; justify-items: center; gap: 8px; color: var(--muted); }
.loader svg { width: 96px; height: 58px; }
@media (prefers-reduced-motion: no-preference) {
  .loader .lid { transform-origin: 60px 36px; animation: blink 2.6s infinite; }
  @keyframes blink { 0%, 84%, 100% { transform: scaleY(1); } 90% { transform: scaleY(.06); } }
  .loader .pupil { animation: look 2.2s ease-in-out infinite; }
  @keyframes look { 0%, 100% { transform: translateX(-10px); } 45%, 55% { transform: translateX(10px); } }
}

/* tables */
.table-wrap { overflow-x: auto; border: 2px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 700 .8rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.who { display: inline-flex; align-items: center; gap: 10px; }
.badge { font-size: .8rem; font-weight: 700; border: 2px solid var(--bad); color: var(--bad); border-radius: 999px; padding: 0 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs a { text-decoration: none; border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* stats and achievements */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 14px; }
.stat b { display: block; font: 400 1.7rem var(--display); color: var(--head); line-height: 1.1; }
:root[data-style="modern"] .stat b { font-weight: 800; }
.stat span { color: var(--muted); font-size: .9rem; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; list-style: none; padding: 0; margin: 0; }
.ach li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 12px; }
.ach li.locked { opacity: .62; }
.ach svg { width: 28px; height: 28px; flex: none; color: var(--accent); }
.ach strong { display: block; }
.ach small { color: var(--muted); }
.ladder { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; counter-reset: lv; }
.ladder li { border: 2px solid var(--line); border-radius: var(--r); padding: 8px; text-align: center; background: var(--surface); counter-increment: lv; }
.ladder li::before { content: "Level " counter(lv); display: block; font-size: .75rem; color: var(--muted); }
.ladder li.done { border-color: var(--ok); }
.ladder li.now { border-color: var(--accent); outline: 2px solid var(--accent); }

/* lessons */
.lesson { display: grid; gap: 12px; }
.lesson .figure { justify-self: start; }

/* footer */
.site-foot { border-top: 2px solid var(--line); padding-block: 28px 40px; color: var(--muted); font-size: .95rem; }
.site-foot .cols { display: flex; flex-wrap: wrap; gap: 18px 40px; justify-content: space-between; }
.site-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-foot a { color: var(--ink); }
.prefs { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.prefs select { width: auto; min-height: 40px; padding: 6px 10px; }
.disclosure { font-size: .9rem; }

/* admin */
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 18px; }
.preview-img { max-width: 100%; image-rendering: auto; border: 2px solid var(--line); border-radius: var(--r); }
.inline-form { display: inline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* SVG text and fills come from tokens through classes (CSP forbids style attributes). */
.logo text { font-family: "Bungee", Impact, "Arial Black", sans-serif; }
.lg-s1 { fill: var(--shadow-1); }
.lg-s2 { fill: var(--shadow-2); }
.av-bg { fill: var(--surface-2); }
.av-tx { fill: var(--muted); font-family: var(--body); }
.mt-40 { margin-top: 40px; }
.mt-28 { margin-top: 28px; }
.logo { order: 1; }
.nav { order: 2; }
.head-tools { order: 3; }
@media (max-width: 760px) { .nav { order: 4; } }
.msg:empty { min-height: 0; }
#ts-box:empty { display: none; }
.link-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 6px 24px; margin: 0; padding-left: 1.2em; }
.guide-body h2 { margin-top: .6em; }

/* Click-to-fullscreen: only the image (with its guide dots) fills the screen, at native size. */
.puzzle-img { cursor: zoom-in; }
.figure:fullscreen, .figure.pseudo-full {
  background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  overflow: auto; padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.figure.pseudo-full { position: fixed; inset: 0; z-index: 70; max-width: none; }
.figure:fullscreen .puzzle-img, .figure.pseudo-full .puzzle-img { cursor: zoom-out; max-width: none; flex: none; outline: 6px solid #3a3a46; outline-offset: 0; }
.figure:fullscreen .guides, .figure.pseudo-full .guides { align-self: stretch; flex: none; }
.figure:fullscreen .guides span, .figure.pseudo-full .guides span { background: #fff; }
.figure:fullscreen picture, .figure.pseudo-full picture { flex: none; }
figure.figure { margin: 0; }

.signup-push { text-align: left; border-color: var(--accent); max-width: 640px; }
.signup-push p { margin: 0; }

.cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: var(--surface); border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 18px rgba(0, 0, 0, .18); padding-bottom: env(safe-area-inset-bottom, 0px); }
.cookie-bar .wrap { padding-block: 12px; justify-content: space-between; }
.cookie-bar p { margin: 0; }
.cookie-bar #cookie-h { flex: 1 1 420px; }
