/* The Harry Herald: newsprint calm, phone first. */

@font-face {
  font-family: "Unifraktur";
  src: url("fonts/UnifrakturMaguntia.woff2") format("woff2");
  font-display: swap;
}

:root {
  --paper: #f7f4ec;
  --paper-2: #efeadf;
  --ink: #1d1c19;
  --muted: #6f6a60;
  --rule: #d8d1c1;
  --cell: #fffdf8;
  --block: #24221e;
  --word: #f4e4ae;
  --cur: #efc457;
  --cross: #f7f0d8;
  --wrong: #b3261e;
  --reveal: #2a5fa8;
  --pencil: #8b8579;
  --good: #2f6b3a;
  --key: #fffdf8;
  --key-2: #e2dccd;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  --serif: ui-serif, "New York", "Iowan Old Style", Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --clue-size: 17px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #1b1a17;
  --paper-2: #24221e;
  --ink: #ece6d8;
  --muted: #a39d90;
  --rule: #3b3833;
  --cell: #4a463f;
  --block: #0f0e0c;
  --word: #6b5c30;
  --cur: #a8872f;
  --cross: #55504a;
  --wrong: #ff8a80;
  --reveal: #8fb6ff;
  --pencil: #8c877c;
  --good: #8fd19e;
  --key: #3a3732;
  --key-2: #2a2824;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

:root[data-size="large"] { --clue-size: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.view { min-height: 100dvh; }

/* ---------- front page ---------- */
#home { padding: calc(var(--safe-t) + 10px) 18px calc(var(--safe-b) + 24px); max-width: 680px; margin: 0 auto; }
.masthead { text-align: center; border-bottom: 3px double var(--ink); padding-bottom: 6px; }
.ears {
  display: flex; justify-content: space-between; align-items: center;
  font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--rule); padding-bottom: 6px;
}
.nameplate {
  font-family: "Unifraktur", var(--serif);
  font-weight: normal;
  font-size: clamp(38px, 11.5vw, 64px);
  line-height: 1.05;
  margin: 10px 0 4px;
  letter-spacing: .01em;
}
.dateline {
  border-top: 1px solid var(--ink); padding: 5px 0 0;
  font: italic 14px/1.3 var(--serif); color: var(--ink);
}
.front { padding-top: 18px; }
.kicker {
  font: 700 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.cards { display: grid; gap: 14px; }
@media (min-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
  display: block; width: 100%; text-align: left;
  background: var(--cell); border: 1px solid var(--rule); border-radius: 4px;
  padding: 16px 16px 14px; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.card:active { transform: scale(.985); }
.card h2 { font-size: 26px; margin: 0 0 2px; font-weight: 700; }
.card .sub { font: italic 15px/1.35 var(--serif); color: var(--muted); }
.card .status {
  margin-top: 14px; display: flex; align-items: center; gap: 10px;
  font: 600 13px/1 var(--sans); color: var(--muted);
}
.card .status .bar { flex: 1; height: 4px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.card .status .bar i { display: block; height: 100%; background: var(--ink); width: 0; transition: width .4s ease; }
.card.solved .status { color: var(--good); }
.card .mini { float: right; width: 54px; height: 54px; opacity: .9; }
.streak { font: 600 12px/1 var(--sans); color: var(--muted); margin-top: 8px; }

.family .feed { list-style: none; padding: 0; margin: 0; font-size: 16px; }
.feed li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dotted var(--rule); }
.feed .who { font-weight: 700; }
.feed .what { color: var(--muted); font-style: italic; }
.feed .t { font: 600 13px/1.6 var(--sans); color: var(--ink); white-space: nowrap; }
.archive-link { text-align: center; margin-top: 30px; }
.link-btn { font: italic 16px var(--serif); color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- solving ---------- */
#solve { display: flex; flex-direction: column; height: 100dvh; padding-top: var(--safe-t); }
.solve-bar {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 46px; padding: 0 6px; border-bottom: 1px solid var(--rule);
}
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 20px; }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:active { background: var(--paper-2); }
.solve-title { flex: 1; display: flex; gap: 8px; align-items: baseline; font-size: 18px; min-width: 0; }
.solve-title span { font: italic 14px var(--serif); color: var(--muted); white-space: nowrap; }
.timer { font: 600 14px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 48px; text-align: right; }

.solve-body { flex: 1; min-height: 0; display: flex; gap: 28px; justify-content: center; padding: 8px 0 0; }
.board-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.board { touch-action: manipulation; }
.board svg { display: block; }

/* grid */
.g-cell { fill: var(--cell); }
.g-block { fill: var(--block); }
.g-cell.cross { fill: var(--cross); }
.g-cell.word { fill: var(--word); }
.g-cell.cur { fill: var(--cur); }
.g-num { font: 600 9px var(--sans); fill: var(--ink); pointer-events: none; }
.g-let {
  font-family: var(--sans); font-weight: 600; fill: var(--ink);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}
.g-let.pencil { fill: var(--pencil); font-weight: 400; }
.g-let.revealed { fill: var(--reveal); }
.g-let.wrong { fill: var(--wrong); }
.g-slash { stroke: var(--wrong); stroke-width: 1.5; pointer-events: none; }
.g-tri { fill: var(--reveal); pointer-events: none; }
.g-line { stroke: var(--block); pointer-events: none; }
.g-break { stroke: var(--block); stroke-width: 3; pointer-events: none; }
.g-frame { fill: none; stroke: var(--block); stroke-width: 2; }
.g-cell.flash { animation: flash .6s ease; }
@keyframes flash { 40% { fill: #fff6cf; } }
:root[data-theme="dark"] .g-cell.flash { animation-name: flash-dark; }
@keyframes flash-dark { 40% { fill: #6d5f33; } }
.g-cell.ripple { animation: ripple .7s ease both; }
@keyframes ripple { 0% { fill: var(--cell); } 45% { fill: var(--cur); } 100% { fill: var(--cell); } }

/* clue bar */
.clue-bar {
  display: flex; align-items: stretch; width: 100%; margin-top: 8px;
  background: var(--word); border-radius: 6px; min-height: 58px;
}
.nav-btn { flex: none; width: 38px; font: 300 30px/1 var(--sans); color: var(--ink); opacity: .7; }
.nav-btn:active { opacity: 1; }
.clue-current {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 2px;
  font-size: var(--clue-size); line-height: 1.25; cursor: pointer;
}
.clue-current .num { font: 700 13px/1 var(--sans); flex: none; }
.clue-current .txt { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.def { text-decoration: underline; text-decoration-color: var(--reveal); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ctype { font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--reveal); margin-left: 6px; white-space: nowrap; }

.clue-cross {
  width: 100%; display: flex; gap: 8px; padding: 10px 40px 0; cursor: pointer;
  font-size: calc(var(--clue-size) - 2px); line-height: 1.3; color: var(--muted);
}
.clue-cross .num { font: 700 12px/1.6 var(--sans); flex: none; }
.clue-cross:empty { display: none; }
@media (min-width: 900px) and (pointer: fine) { .clue-cross { display: none; } }

/* clue lists (wide screens) */
.clue-lists { display: none; }
.clue-col h3 { font: 700 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.clue-col ol { list-style: none; margin: 0; padding: 0; }
.clue-item { display: flex; gap: 8px; padding: 5px 8px; border-radius: 4px; font-size: 16px; line-height: 1.3; cursor: pointer; border-left: 3px solid transparent; }
.clue-item .n { font: 700 13px/1.6 var(--sans); min-width: 20px; text-align: right; }
.clue-item.done { color: var(--muted); }
.clue-item.cur { background: var(--word); }
.clue-item.crossing { border-left-color: var(--cur); }

@media (min-width: 900px) and (pointer: fine) {
  .clue-lists { display: flex; gap: 22px; width: 520px; overflow-y: auto; padding: 0 4px 24px; }
  .clue-col { flex: 1; }
  .solve-body { padding-top: 20px; }
}

/* keyboard */
.keyboard {
  flex: none; padding: 6px 3px calc(var(--safe-b) + 6px); background: var(--paper-2);
  border-top: 1px solid var(--rule); touch-action: none;
}
.kb-row { display: flex; justify-content: center; gap: 5px; margin: 5px 0; }
.key {
  flex: 1 1 0; max-width: 44px; height: 46px; border-radius: 6px;
  background: var(--key); box-shadow: var(--shadow);
  font: 500 20px/46px var(--sans); text-align: center; color: var(--ink);
}
.key.wide { max-width: 66px; flex-grow: 1.5; font-size: 15px; }
.key.on { background: var(--ink); color: var(--paper); }
.key.down { background: var(--key-2); transform: translateY(1px); box-shadow: none; }
.key svg { width: 22px; height: 22px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
@media (pointer: fine) { .keyboard { display: none; } }

/* sheets & overlays */
.scrim { position: fixed; inset: 0; background: rgba(20, 18, 14, .35); z-index: 20; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--paper); border-radius: 14px 14px 0 0;
  padding: 10px 16px calc(var(--safe-b) + 16px); max-width: 560px; margin: 0 auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); animation: up .22s ease;
}
.sheet.tall { max-height: 82dvh; overflow-y: auto; }
.sheet h3 { font: 700 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--rule); margin: 0 auto 6px; }
.menu-btn {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 13px 4px; border-bottom: 1px solid var(--rule); font-size: 17px; text-align: left;
}
.menu-btn small { font: 13px var(--sans); color: var(--muted); }
.menu-btn:active { background: var(--paper-2); }
.menu-btn.danger { color: var(--wrong); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet.closing { animation: down .2s ease-in forwards; }
.scrim.closing, .overlay.closing { animation: fade-out .2s ease-in forwards; pointer-events: none; }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .overlay, .sheet.closing, .scrim.closing, .overlay.closing { animation: none; } }

.overlay {
  position: fixed; inset: 0; z-index: 30; background: var(--paper); overflow-y: auto;
  padding: calc(var(--safe-t) + 18px) 20px calc(var(--safe-b) + 30px); animation: fade .25s ease;
}
.overlay .inner { max-width: 560px; margin: 0 auto; }
.overlay h2 { font-size: 32px; margin: 6px 0 4px; }
.overlay .close { position: absolute; right: 12px; top: calc(var(--safe-t) + 10px); }
.done-time { font: 700 44px/1.1 var(--sans); font-variant-numeric: tabular-nums; margin: 14px 0 2px; }
.badge { display: inline-block; font: 700 11px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; padding: 5px 8px; border: 1.5px solid currentColor; border-radius: 3px; color: var(--good); margin-left: 6px; vertical-align: middle; }
.reveal-box { margin: 22px 0; padding: 14px 16px; border-left: 3px solid var(--ink); background: var(--cell); font-size: 18px; line-height: 1.45; }
.reveal-box b { font-family: var(--sans); letter-spacing: .02em; }
.primary { display: block; width: 100%; padding: 14px; border-radius: 8px; background: var(--ink); color: var(--paper); font: 600 17px var(--sans); margin-top: 12px; }
.secondary { display: block; width: 100%; padding: 13px; border-radius: 8px; border: 1px solid var(--ink); font: 600 16px var(--sans); margin-top: 10px; }
.explain-list { list-style: none; padding: 0; margin: 10px 0; }
.explain-list li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.explain-list .ans { font: 700 15px var(--sans); letter-spacing: .04em; }
.explain-list .clue { font-size: 17px; margin: 2px 0 4px; }
.explain-list .how { font-size: 15px; color: var(--muted); line-height: 1.4; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--kb-h, 0px) + var(--safe-b) + 18px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper); font: 600 15px var(--sans);
  padding: 10px 16px; border-radius: 20px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 40; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.field { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--rule); font-size: 17px; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; }
.seg button { padding: 6px 12px; font: 600 14px var(--sans); }
.seg button.on { background: var(--ink); color: var(--paper); }
.note { font-style: italic; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* joining */
.join { text-align: center; padding-top: 8vh; }
.join form { text-align: left; margin: 26px 0 18px; -webkit-user-select: text; user-select: text; }
.join label { display: block; font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 16px; }
.join input {
  display: block; width: 100%; margin-top: 6px; padding: 13px 12px; font: 19px var(--serif); color: var(--ink);
  background: var(--cell); border: 1px solid var(--rule); border-radius: 8px; -webkit-user-select: text; user-select: text;
}
.join input:focus { outline: 2px solid var(--cur); border-color: transparent; }
.join .err { color: var(--wrong); min-height: 1.2em; font: 15px var(--sans); margin: 0; }
.note.small { font-size: 13px; }

/* print: a clean newspaper page */
@media print {
  .solve-bar, .keyboard, .clue-bar, #home, .overlay, .sheet, .scrim, .toast { display: none !important; }
  #solve { height: auto; }
  .clue-lists { display: flex !important; width: auto; gap: 24px; }
  .solve-body { display: block; }
  .g-cell, .g-cell.word, .g-cell.cur, .g-cell.cross { fill: #fff !important; }
  .g-let { display: none; }
}
