/* Equilux — daily sun & moon logic puzzle.
 *
 * Two themes drawn from the subject itself: "day" (pale dawn sky, gold sun,
 * indigo moon) and "night" (deep indigo sky, warm gold, silver moon). The site
 * follows the visitor's local clock by default — day theme from 6am–6pm,
 * night otherwise — with a manual horizon toggle. Balance of light and dark
 * is the whole identity: equilux.
 */

:root {
  --bg: #edf0f7;
  --surface: #ffffff;
  --surface-dim: #f5f7fb;
  --ink: #1b2240;
  --ink-soft: #5a6284;
  --sun: #e8a23c;
  --sun-deep: #b97a1e;
  --moon: #5566c0;
  --moon-deep: #3f4da0;
  --line: #ccd2e2;
  --line-soft: #e2e6f0;
  --error: #cf4b3f;
  --focus: #3f4da0;
  --shadow: 0 1px 2px rgba(27, 34, 64, 0.06), 0 6px 24px rgba(27, 34, 64, 0.07);
  --radius: 12px;
  --radius-cell: 8px;
  --display: 'Bricolage Grotesque', 'Avenir Next', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Helvetica Neue', system-ui, sans-serif;
}

[data-theme='night'] {
  --bg: #10162a;
  --surface: #1a2140;
  --surface-dim: #161d37;
  --ink: #e8ecfa;
  --ink-soft: #97a0c3;
  --sun: #f1b44c;
  --sun-deep: #f1b44c;
  --moon: #9fabdd;
  --moon-deep: #b9c3ec;
  --line: #333d66;
  --line-soft: #262f52;
  --error: #ff7a6e;
  --focus: #9fabdd;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  transition: background 0.4s ease, color 0.4s ease;
}

a { color: var(--moon-deep); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.04em;
}
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 8px;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-dim); }
.site-nav a[aria-current='page'] { color: var(--ink); }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle:hover { border-color: var(--ink-soft); }

/* ---------- Page scaffolding ---------- */

main { padding: 28px 0 64px; }

.eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
}
h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.15;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(20px, 3.6vw, 26px);
  margin: 2.2em 0 0.5em;
}
h3 { font-size: 18px; margin: 1.6em 0 0.4em; }
p { margin: 0.6em 0; }
.lede { color: var(--ink-soft); font-size: 18px; max-width: 60ch; }

/* ---------- Game area ---------- */

.game-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.game-title h1 { margin-bottom: 2px; }
.game-meta { color: var(--ink-soft); font-size: 15px; }
.game-meta strong { color: var(--ink); }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 20px;
  color: var(--ink-soft);
}

.board-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(10px, 3vw, 22px);
  max-width: 480px;
  margin: 0 auto;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  touch-action: manipulation;
}

.cell {
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-cell);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cell svg { width: 62%; height: 62%; }
.cell:hover { border-color: var(--ink-soft); }
.cell.given { background: var(--surface-dim); cursor: default; }
.cell.given:hover { border-color: var(--line); }
.cell.error { border-color: var(--error); box-shadow: inset 0 0 0 1.5px var(--error); }
.cell.hint-flash { animation: hintPulse 0.9s ease 3; }
@keyframes hintPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--sun) 55%, transparent); }
}

.edge {
  position: absolute;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.sun-glyph { fill: var(--sun); }
.moon-glyph { fill: var(--moon); }
[data-theme='night'] .moon-glyph { fill: var(--moon); }

/* ---------- Controls ---------- */

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { opacity: 0.9; border-color: var(--ink); }
[data-theme='night'] .btn-primary { background: var(--sun); border-color: var(--sun); color: #10162a; }

.hint-note {
  max-width: 480px;
  margin: 14px auto 0;
  background: var(--surface-dim);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--sun);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--ink-soft);
  display: none;
}
.hint-note.visible { display: block; }

.mistake-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ---------- Win overlay ---------- */

.win-panel {
  max-width: 480px;
  margin: 18px auto 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
  display: none;
}
.win-panel.visible { display: block; animation: rise 0.45s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.win-panel h2 { margin: 0 0 4px; }
.win-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 14px 0;
}
.win-stats div { display: grid; gap: 2px; }
.win-stats .num {
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.win-stats .lbl { font-size: 13px; color: var(--ink-soft); }
.win-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.countdown { margin-top: 12px; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- Content sections ---------- */

.content { max-width: 720px; margin: 56px auto 0; }
.content ul { padding-left: 1.2em; }
.content li { margin: 0.35em 0; }

.rule-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}
.rule-cards li {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0;
  font-size: 15px;
}
.rule-cards strong { display: block; margin-bottom: 4px; }

.app-cta {
  margin: 40px auto 0;
  max-width: 720px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--sun) 14%, var(--surface)), color-mix(in srgb, var(--moon) 14%, var(--surface)));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.app-cta p { margin: 0; }
.app-cta .title { font-family: var(--display); font-weight: 700; font-size: 19px; }
.app-cta .sub { color: var(--ink-soft); font-size: 15px; }

.archive-strip { margin-top: 40px; }
.archive-strip .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.archive-chip {
  text-decoration: none;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
}
.archive-chip:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ---------- Archive calendar ---------- */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 14px 0 28px;
  max-width: 480px;
}
.month-grid a, .month-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
}
.month-grid span { opacity: 0.3; border-style: dashed; }
.month-grid a:hover { border-color: var(--ink-soft); }
.month-grid a.done { background: color-mix(in srgb, var(--sun) 22%, var(--surface)); border-color: var(--sun); }

/* ---------- Difficulty picker ---------- */

.diff-row { display: flex; gap: 8px; margin: 0 0 16px; justify-content: center; }
.diff-row .btn[aria-pressed='true'] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
[data-theme='night'] .diff-row .btn[aria-pressed='true'] { background: var(--sun); border-color: var(--sun); color: #10162a; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 28px 0 40px;
  color: var(--ink-soft);
  font-size: 14px;
}
.site-footer .wrap { display: grid; gap: 8px; }
.site-footer a { color: var(--ink-soft); }
.site-footer .disclaimer { max-width: 72ch; }

/* ---------- FAQ ---------- */

details {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 18px;
  margin: 10px 0;
}
summary { font-weight: 700; cursor: pointer; }
details p { color: var(--ink-soft); }

/* ---------- Responsive & a11y ---------- */

@media (max-width: 560px) {
  .site-nav a { padding: 8px 7px; font-size: 14px; }
  .board { gap: 4px; }
  .edge { width: 15px; height: 15px; font-size: 10px; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
