/* Nonogram. The top part is the shared paper-and-ink look of the other sections (copied from
   ../hangman/styles.css: header, intro, tabs, buttons, article, footer); the puzzle and the diagrams are at the bottom. */
:root {
  --paper: #faf8f2;
  --ink: #292d28;
  --muted: #697064;
  --line: #dfdfd3;
  --accent: #bd5f3e;
  --teal: #24878b;
  --pad: #fffdf8;
  --dot: #d5d3c4;
  --ink-mark: #bd5f3e;
  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
    --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
  --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 0; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.crumbs { flex: 1; color: var(--muted); font-size: 15px; min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--line); }
.crumbs [aria-current] { color: var(--ink); }
.theme-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.langs { display: flex; gap: 2px; }
.langs a { padding: 5px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); background: var(--line); }

/* ---------- intro ---------- */
.intro { padding: 34px 0 22px; }
.intro h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.02em;
}
.lede { margin: 12px 0 0; font-size: 18px; color: var(--muted); max-width: 58ch; }

.durations { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.durations a {
  padding: 7px 16px; border: 1.5px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 15px; color: var(--muted);
}
.durations a:hover { border-color: var(--ink); color: var(--ink); }
.durations a[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }

.mode-switch { display: inline-flex; margin: 0 0 18px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stop-row { margin: 14px 0 0; min-height: 0; }
.stop-row:has([hidden]) { margin: 0; }

.challenge {
  margin: 0 0 20px; padding: 12px 16px; border-left: 4px solid var(--accent);
  background: var(--pad); font-weight: 600;
}

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }
.btn {
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ---------- article ---------- */
.prose { max-width: 70ch; margin: 56px 0 0; font-size: 17px; line-height: 1.7; }
.prose h2 { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.2; margin: 44px 0 10px; letter-spacing: -0.01em; }
.prose h3 { font-size: 19px; margin: 26px 0 6px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 0 0 16px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 9px 12px 9px 0; text-align: left; vertical-align: top; }
.prose th { border-bottom: 2px solid var(--ink); font-weight: 700; }
.prose td:first-child { font-weight: 700; white-space: nowrap; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq-answer { padding: 8px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 64px; padding: 22px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.site-footer a { text-decoration: none; color: var(--ink); }
.site-footer a:hover { color: var(--accent); }
.site-footer a[aria-current] { color: var(--muted); }
.site-footer .footer-site { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.site-footer p { margin: 10px 0 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0; }
.toolbar .label { color: var(--muted); font-size: 15px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }


/* ---------- small screens (shared) ---------- */
@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { gap: 12px; padding: 14px 0; }
  .crumbs { display: none; }
  .brand { flex: 1; }
  .intro { padding: 24px 0 16px; }
  .lede { font-size: 16px; }
  .durations { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .durations::-webkit-scrollbar { display: none; }
  .durations a { white-space: nowrap; flex: none; }
  .prose { font-size: 16px; margin-top: 40px; }
  .prose h2 { font-size: 23px; }
  .prose table { display: block; overflow-x: auto; }
}

/* ---------- nonogram ---------- */
.ng-game { --grid: rgba(41, 45, 40, .22); --fill: #292d28; --cross: #8a8f84; --bad: #d9483b; max-width: 820px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ng-game { --grid: rgba(236, 235, 227, .2); --fill: #ecebe3; --cross: #8f9488; } }
:root[data-theme="dark"] .ng-game { --grid: rgba(236, 235, 227, .2); --fill: #ecebe3; --cross: #8f9488; }
.ng-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.ng-top .seg button { display: inline-flex; align-items: center; gap: 7px; }
.ng-ico-fill, .ng-ico-cross { display: inline-block; width: 13px; height: 13px; border-radius: 2px; }
.ng-ico-fill { background: currentColor; }
.ng-ico-cross { background: linear-gradient(45deg, transparent 43%, currentColor 43% 57%, transparent 57%), linear-gradient(-45deg, transparent 43%, currentColor 43% 57%, transparent 57%); }
.ng-timer { font: 700 22px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--muted); }
.ng-wrap { overflow-x: auto; padding: 2px 0 6px; }
.ng-board {
  --c: 28px; display: grid; grid-template-columns: auto repeat(var(--n), var(--c)); grid-template-rows: auto repeat(var(--n), var(--c));
  width: max-content; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none;
}
.ng-corner { border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.ng-cc, .ng-rc { display: flex; color: var(--ink); font: 700 max(10px, calc(var(--c) * .5))/1.12 system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
.ng-cc { flex-direction: column; justify-content: flex-end; align-items: center; gap: 1px; padding: 6px 0 5px; border-bottom: 2px solid var(--ink); border-right: 1px solid transparent; }
.ng-rc { justify-content: flex-end; align-items: center; gap: max(4px, calc(var(--c) * .3)); padding: 0 7px 0 6px; border-right: 2px solid var(--ink); border-bottom: 1px solid transparent; }
.ng-cc.b5r { border-right-color: transparent; }
.ng-cc.is-done, .ng-rc.is-done { color: var(--muted); opacity: .45; }
.ng-cc.is-hot, .ng-rc.is-hot { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ng-cc.is-flash, .ng-rc.is-flash { background: color-mix(in srgb, #ffd34d 55%, transparent); opacity: 1; color: var(--ink); }
.ng-cell {
  position: relative; display: block; box-sizing: border-box; width: var(--c); height: var(--c); padding: 0; margin: 0; border: 0;
  border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); border-radius: 0; background: var(--pad); cursor: pointer; color: inherit;
}
.ng-cell.b5r { border-right: 2px solid var(--ink); }
.ng-cell.b5b { border-bottom: 2px solid var(--ink); }
.ng-cell.er { border-right: 2px solid var(--ink); }
.ng-cell.eb { border-bottom: 2px solid var(--ink); }
@media (hover: hover) { .ng-cell:hover { background: color-mix(in srgb, var(--accent) 14%, var(--pad)); } }
.ng-cell:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; z-index: 1; }
.ng-cell.is-fill { background: var(--fill); }
.ng-cell.is-cross::before, .ng-cell.is-cross::after {
  content: ""; position: absolute; left: 22%; right: 22%; top: 50%; height: max(1.5px, calc(var(--c) * .07)); margin-top: -1px; background: var(--cross); border-radius: 2px;
}
.ng-cell.is-cross::before { transform: rotate(45deg); }
.ng-cell.is-cross::after { transform: rotate(-45deg); }
.ng-cell.is-wrong.is-fill { background: var(--bad); }
.ng-cell.is-wrong.is-cross::before, .ng-cell.is-wrong.is-cross::after { background: var(--bad); }
.ng-cell.is-flash { box-shadow: inset 0 0 0 3px #f2b400; }
.ng-board.is-solved .ng-cell { cursor: default; }
.ng-board.is-solved .ng-cell.is-fill { animation: ng-pop .5s ease-out; }
@keyframes ng-pop { 50% { transform: scale(.82); } }
.ng-status { margin: 12px 0 0; min-height: 1.6em; font-weight: 600; }
.ng-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 0; }
.ng-result { margin: 18px 0 0; padding: 16px 18px; border-left: 4px solid var(--teal); background: var(--pad); }
.ng-result .btn { margin: 0 8px 6px 0; }
.ng-result-head { margin: 0; font: 800 26px/1.2 var(--display); }
.ng-result-sub { margin: 6px 0 12px; color: var(--muted); }
.ng-bar { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.ng-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ng-note { margin: 12px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- diagrams in the articles ---------- */
.ng-fig { margin: 22px 0; }
.ng-fig-row { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.ng-fig-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
.ng-fig-item span { color: var(--muted); font-size: 14px; font-weight: 600; }
.ng-fig svg { display: block; max-width: 100%; height: auto; }
.ng-fig figcaption { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.ng-fig .cl { fill: var(--ink); font: 700 13px system-ui, sans-serif; }
.ng-fig .bx { fill: var(--pad); stroke: rgba(105, 112, 100, .45); stroke-width: 1; }
.ng-fig .fl { fill: var(--ink); }
.ng-fig .nw { fill: var(--accent); }
.ng-fig .x { stroke: #8a8f84; stroke-width: 2; stroke-linecap: round; }
.ng-fig .nx { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.ng-fig .b0 { fill: #24878b; } .ng-fig .b1 { fill: #e0a23a; } .ng-fig .b2 { fill: #bd5f3e; }
.ng-fig .lb { fill: var(--muted); font: 600 12px system-ui, sans-serif; }
.ng-fig .ol { fill: none; stroke: var(--ink); stroke-width: 2; }

@media (max-width: 760px) {
  .ng-actions .btn { padding: 8px 14px; font-size: 15px; }
  .ng-bar { gap: 8px 10px; }
  .ng-bar .label { font-size: 13px; }
  .ng-bar .seg button { padding: 5px 10px; font-size: 14px; }
  .ng-timer { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { .ng-board.is-solved .ng-cell.is-fill { animation: none; } }
