/* Morning Crossword: one stylesheet for every page. Tokens come from DESIGN.md; light is the default, dark only when chosen. */
@font-face { font-family: "Bricolage Grotesque"; src: url(/fonts/bricolage-grotesque.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(/fonts/atkinson-hyperlegible-next.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --yellow: #F8C21E;
  --ink: #26241F;
  --sheet: #FBFCFD;
  --soft-ink: #6B675F;
  --highlight: #FDEDB0;
  --green: #2E7A57;
  --rose: #E8707E;
  --rose-text: #B03A4C;
  --mist: #EEF1F4;
  --ink-on-yellow: #4A463F;
  --key: #E6E9ED;
  --accent: var(--green);

  --page: var(--mist);
  --surface: var(--sheet);
  --text: var(--ink);
  --muted: var(--soft-ink);
  --line: var(--ink);
  --cell: var(--sheet);
  --cell-text: var(--ink);
  --block: var(--ink);
  --word: var(--highlight);
  --word-text: var(--ink);
  --border: #D5DAE0;

  --display: "Bricolage Grotesque", Arial, sans-serif;
  --body: "Atkinson Hyperlegible Next", Arial, sans-serif;
  --shadow: 0 20px 50px rgba(38, 36, 31, .18);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #1C1A16;
  --surface: #2B2924;
  --text: var(--sheet);
  --muted: #C9C4BA;
  --line: #0E0D0B;
  --cell: #3A3731;
  --cell-text: var(--sheet);
  --block: #0E0D0B;
  --word: #5E5226;
  --word-text: var(--sheet);
  --key: #45423B;
  --border: #45423B;
  --rose-text: #F2A0AA;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); scrollbar-color: var(--soft-ink) var(--page); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 400 1.125rem/1.5 var(--body); -webkit-font-smoothing: antialiased; caret-color: var(--ink); }
::selection { background: var(--highlight); color: var(--ink); }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }

/* Header band: Sunrise Yellow owns the top of every page. */
.band { background: var(--yellow); color: var(--ink); padding-top: env(safe-area-inset-top, 0px); }
.band .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.logo { display: block; line-height: 0; }
.logo img { height: 40px; width: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .icon-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 6px;
  font: 700 1rem/1 var(--body); text-decoration: none; color: var(--ink); background: none; border: 0; cursor: pointer; }
.nav a:hover, .icon-btn:hover { background: rgba(38, 36, 31, .08); }
.nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
.icon-btn svg { width: 22px; height: 22px; }
@media (max-width: 520px) { .logo img { height: 32px; } .nav .wide { display: none; } }

/* Puzzle heading line */
.play { padding-block: 16px 24px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.head h1 { font-size: 1.75rem; font-weight: 800; }
.head .sub { color: var(--muted); font-size: 1rem; }
.head-tools { display: flex; align-items: center; gap: 8px; }
.head-tools .btn { min-height: 44px; padding: 0 16px; }
.timer { font: 700 1.125rem/1 var(--body); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  background: none; border: 0; padding: 0 4px; cursor: pointer; }
.ribbon { display: inline-block; background: var(--accent); color: var(--sheet); border-radius: 6px; padding: 4px 14px; font-weight: 700; font-size: 1rem; margin-bottom: 12px; }
.replay-note { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 1rem; }

/* Board: grid on the left, clue lists on the right on wide screens. */
.board { display: grid; gap: 16px 40px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .board { grid-template-columns: auto minmax(0, 1fr); align-items: start; } }
.left { display: flex; flex-direction: column; gap: 12px; width: var(--size); max-width: 100%; justify-self: center; }
@media (min-width: 900px) { .left { justify-self: start; } }
:root { --size: clamp(220px, min(calc(100vw - 32px), calc(100dvh - 400px)), 420px); }
@media (min-width: 900px) { :root { --size: clamp(320px, calc(100dvh - 260px), 500px); } }

.grid { display: grid; gap: 3px; padding: 3px; background: var(--line); width: var(--size); aspect-ratio: 1; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.cell { position: relative; background: var(--cell); color: var(--cell-text); display: grid; place-items: center; cursor: pointer; overflow: hidden;
  font: 700 calc(var(--size) / var(--n) * .55)/1 var(--body); text-transform: uppercase; }
.cell.block { background: var(--block); cursor: default; }
.cell .num { position: absolute; top: 3px; left: 4px; font: 700 max(11px, calc(var(--size) / var(--n) * .19))/1 var(--body); }
.cell.word { background: var(--word); color: var(--word-text); }
.cell.active { background: var(--yellow); color: var(--ink); box-shadow: inset 0 0 0 4px var(--ink); }
.cell:focus { outline: none; }
.cell:focus-visible { box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 7px var(--sheet); }
/* Wrong: rose stripe under the cell, rose letter, struck through. */
.cell.wrong .ch { color: var(--rose-text); text-decoration: line-through; text-decoration-thickness: 3px; }
.cell.wrong::after, .cell.good::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8%; background: var(--rose); }
.cell.good::after { background: var(--green); }
/* Hinted: a Sunrise Yellow corner fold in the top right. */
/* An ink edge keeps the fold visible on the yellow active square and the pale active word. */
.cell.hinted::before { content: ""; position: absolute; top: 0; right: 0; width: 32%; height: 32%;
  background: linear-gradient(225deg, var(--yellow) 0 47%, var(--ink) 47% 55%, transparent 55%); }
.cell.hinted.active::before { background: linear-gradient(225deg, var(--sheet) 0 47%, var(--ink) 47% 55%, transparent 55%); }
.cell.locked { cursor: default; }
.solved .cell.active { background: var(--cell); color: var(--cell-text); box-shadow: none; }
.solved .cell.word { background: var(--cell); color: var(--cell-text); }

.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width .3s var(--ease); }

.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0; cursor: pointer;
  font: 700 1.05rem/1 var(--body); text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--sheet); }
:root[data-theme="dark"] .btn.primary { background: var(--sheet); color: var(--ink); }
.btn.secondary { background: var(--yellow); color: var(--ink); }
.btn.plain { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn:hover { filter: brightness(.96); }

/* Clue bar: the clue for the active word, directly above the keyboard on phones. */
.cluebar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; background: var(--highlight); color: var(--ink); border-radius: 12px; min-height: 60px; }
.cluebar button { min-height: 56px; background: none; border: 0; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.cluebar button svg { width: 20px; height: 20px; }
.cluebar .text { padding: 8px 4px; font: 400 1.125rem/1.3 var(--body); text-align: left; cursor: pointer; }
.cluebar .text b { margin-right: 8px; }

/* Clue lists (wide screens) */
.lists { display: none; gap: 24px; grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .lists { display: grid; } }
.lists h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--text); }
.lists ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lists li { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 1.125rem; line-height: 1.35; border-left: 6px solid transparent; }
.lists li b { min-width: 1.6em; }
.lists li.on { background: var(--highlight); color: var(--ink); }
.lists li.cross { border-left-color: var(--highlight); }
.lists li.done { color: var(--muted); }

/* On-screen keyboard: shown on touch screens, fixed to the bottom with the clue bar. */
.dock { display: contents; }
.kbd { display: none; }
body.touch .dock { display: flex; flex-direction: column; gap: 6px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--page); padding: 8px max(6px, env(safe-area-inset-left, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }
body.touch .dock .cluebar { width: 100%; max-width: 640px; margin: 0 auto; }
body.touch .kbd { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 640px; margin: 0 auto; }
body.touch { padding-bottom: 250px; }
/* Phones: a compact header and heading so the grid, clue bar and keyboard fit one screen (app.js sizes the grid to fit). */
body.touch .band .wrap { min-height: 48px; }
body.touch .logo img { height: 30px; }
body.touch .play { padding-top: 10px; }
body.touch .head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; margin-bottom: 10px; }
body.touch .head > div:first-child { display: contents; }
body.touch .head h1 { grid-column: 1 / -1; font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch .head .sub { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch .head-tools { gap: 2px; }
body.touch .kbd button { height: 46px; }
body.touch .cluebar { min-height: 56px; }
body.touch .cluebar button { min-height: 52px; }
.kbd div { display: flex; gap: 5px; justify-content: center; }
.kbd button { flex: 1 1 0; max-width: 58px; height: 48px; border: 0; border-radius: 6px; background: var(--key); color: var(--text); font: 700 1.2rem/1 var(--body); cursor: pointer; padding: 0;
  touch-action: manipulation; }
.kbd button.wide { flex: 1.6 1 0; max-width: 90px; }
.kbd button svg { width: 24px; height: 24px; }
.kbd button:active { background: var(--yellow); color: var(--ink); }

/* Sheets and dialogs */
dialog { border: 0; padding: 0; border-radius: 24px; box-shadow: var(--shadow); max-width: min(480px, calc(100vw - 32px)); width: 100%; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(38, 36, 31, .45); }
.sheet { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.sheet h2 { font-size: 1.75rem; font-weight: 800; }
.sheet .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.close { min-width: 44px; min-height: 44px; border-radius: 6px; background: none; border: 0; cursor: pointer; display: grid; place-items: center; }
.close svg { width: 22px; height: 22px; }
.hint-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint-list .btn { width: 100%; }
.small { font-size: 1rem; color: var(--muted); }

/* Solved card: the share card in DESIGN.md. */
.win { background: var(--yellow); color: var(--ink); }
.win .small { color: var(--ink-on-yellow); }
.win .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.win .stats div { background: var(--sheet); border-radius: 12px; padding: 12px 8px; text-align: center; }
.win .stats b { display: block; font: 800 1.75rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.win .stats span { font-size: 1rem; color: var(--ink-on-yellow); }
.win .btn.primary { background: var(--ink); color: var(--sheet); }
.win .btn.plain { background: var(--sheet); color: var(--ink); border: 0; }
.win .close { color: var(--ink); }

.toast { position: fixed; left: 50%; top: calc(76px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -8px); opacity: 0; pointer-events: none; z-index: 20;
  width: max-content; background: var(--ink); color: var(--sheet); padding: 12px 18px; border-radius: 12px; font-weight: 700; transition: opacity .2s, transform .2s var(--ease); max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* Phones: just above the clue bar, clear of the grid. */
body.touch .toast { top: auto; bottom: calc(var(--dock, 240px) + 10px); }

/* Text sections below the puzzle */
.info { padding-block: 40px; display: flex; flex-direction: column; gap: 40px; }
.info section { display: flex; flex-direction: column; gap: 12px; max-width: 70ch; }
.info h2 { font-size: 1.75rem; font-weight: 700; }
.info h3 { font-size: 1.25rem; font-weight: 700; margin-top: 8px; }
.info ul, .info ol { margin: 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 6px; }
.info.prose { gap: 12px; max-width: 70ch; padding-bottom: 56px; }
.info.prose h2 { margin-top: 20px; }
.info.prose h2:first-child { margin-top: 0; }
.info.prose ul, .info.prose ol { gap: 10px; }
.info.prose .btn { align-self: flex-start; }
.info.prose code { padding: 1px 5px; border-radius: 4px; background: var(--surface); border: 1px solid var(--border); }
.info.prose.contact { padding-top: 12px; }
.contact-address { font-size: 1.25rem; overflow-wrap: anywhere; }
.contact-tools { display: flex; flex-wrap: wrap; gap: 12px; }
.info.prose .contact-tools .btn { align-self: auto; }
table.keys { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.keys th, table.keys td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.keys th { font-weight: 700; }
table.keys td:first-child { font-weight: 700; width: 38%; }
.faq details { border-top: 1px solid var(--border); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 8px; }
.faq details p { margin-top: 8px; }
.info .recent, .recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; max-width: none; }
.recent a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; min-height: 64px; }
.recent a:hover { border-color: var(--text); }
.recent b { font-family: var(--display); font-size: 1.15rem; }
.recent span { color: var(--muted); font-size: 1rem; }
.recent .mark { color: var(--green); font-weight: 700; }

.page-title { padding-block: 32px 8px; display: flex; flex-direction: column; gap: 8px; }
.page-title h1 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.crumbs { font-size: 1rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.archive-month { display: flex; flex-direction: column; gap: 12px; }

footer { border-top: 1px solid var(--border); padding-block: 24px calc(24px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 1rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; }
footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
