/* ==========================================================================
   WeekYear — design system
   The year, in weeks. Light + dark, print-friendly, no dependencies.
   ========================================================================== */

:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --ink: #191a20;
  --muted: #5d6470;
  --faint: #8b919c;
  --border: #e3e3dd;
  --border-strong: #cfcfc7;
  --accent: #4640d9;
  --accent-ink: #372fc4;
  --accent-contrast: #ffffff;
  --accent-soft: #eceaff;
  --accent-softer: #f5f4ff;
  --good: #157f3d;
  --good-soft: #e4f5ea;
  --warn-soft: #fdf3d8;
  --warn-ink: #8a6116;
  --shadow: 0 1px 2px rgba(20, 20, 43, 0.05), 0 8px 24px -12px rgba(20, 20, 43, 0.12);
  --shadow-lift: 0 2px 4px rgba(20, 20, 43, 0.06), 0 16px 32px -12px rgba(20, 20, 43, 0.18);
  --radius: 14px;
  --radius-sm: 8px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Code", Menlo, Consolas,
    monospace;
  --page-max: 72rem;
  --text-max: 46rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #16181d;
    --surface-2: #1d2026;
    --ink: #e9eaee;
    --muted: #9aa1ac;
    --faint: #6f7681;
    --border: #262a31;
    --border-strong: #363b44;
    --accent: #8f8aff;
    --accent-ink: #a5a1ff;
    --accent-contrast: #14122e;
    --accent-soft: #262458;
    --accent-softer: #1b1a33;
    --good: #4cc57e;
    --good-soft: #14301f;
    --warn-soft: #33290f;
    --warn-ink: #d9b45c;
    --shadow: none;
    --shadow-lift: none;
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  font-weight: 800;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 750;
  margin-top: 2.2em;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 1.8em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  white-space: nowrap;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

img,
svg {
  max-width: 100%;
  vertical-align: middle;
}

ul,
ol {
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.35em;
}

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

::selection {
  background: var(--accent-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sr-only:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  width: auto;
  height: auto;
  clip: auto;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.wrap {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.prose {
  max-width: var(--text-max);
}

main {
  padding-block: clamp(1.5rem, 4vw, 3rem) 4rem;
}

.section {
  margin-top: clamp(2.5rem, 6vw, 4rem);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand .glyph {
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex: none;
}

.brand em {
  font-style: normal;
  color: var(--accent-ink);
}

.site-nav {
  display: flex;
  gap: 0.2rem;
  margin-left: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
  text-decoration: none;
}

.site-nav a[aria-current="page"],
.site-nav a.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

/* --------------------------------------------------------------------------
   Hero (homepage)
   -------------------------------------------------------------------------- */

.hero {
  text-align: center;
  padding-block: clamp(1.5rem, 5vw, 3.5rem) 0;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.kicker .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.hero h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0;
}

.hero .big-week {
  font-size: clamp(5.5rem, 22vw, 12rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  margin: 0.05em 0 0.1em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--accent) 20%, #9a4fd9 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent);
}

.hero .week-meta {
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.hero .week-meta .sep {
  color: var(--faint);
  padding-inline: 0.4em;
}

/* --------------------------------------------------------------------------
   Chips, badges, buttons
   -------------------------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.chips.start {
  justify-content: flex-start;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.chip .lbl {
  color: var(--muted);
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}

.btn:active {
  transform: translateY(0);
}

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn.small {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Year strip — the year as a row of weeks
   -------------------------------------------------------------------------- */

.yearstrip-card {
  margin-top: clamp(2rem, 5vw, 3rem);
}

.yearstrip {
  display: flex;
  gap: 3px;
  height: 38px;
}

.yearstrip span {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
}

.yearstrip span.past {
  background: var(--border-strong);
  border-color: transparent;
}

.yearstrip span.now {
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.yearstrip-caption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Cards & grids
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.6rem);
  box-shadow: var(--shadow);
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.grid.wide {
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
}

a.card {
  display: block;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

a.card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-strong);
}

a.card h3 {
  margin: 0 0 0.3em;
  font-size: 1.05rem;
  color: var(--accent-ink);
}

a.card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.stat {
  text-align: center;
}

.stat .n {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.stat .l {
  font-size: 0.85rem;
  color: var(--muted);
}

.answer-box {
  background: var(--accent-softer);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin: 1.2rem 0 1.6rem;
}

.answer-box > :last-child {
  margin-bottom: 0;
}

.answer-box strong {
  color: var(--accent-ink);
}

.note {
  background: var(--warn-soft);
  border-radius: var(--radius-sm);
  color: var(--warn-ink);
  padding: 0.8rem 1.1rem;
  font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 80vh;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--surface-2);
}

tr.is-now,
tbody tr.is-now:hover {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

tr.is-now td:first-child {
  font-weight: 800;
  color: var(--accent-ink);
}

td .tag,
th .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  margin-left: 0.5em;
  letter-spacing: 0.03em;
}

/* --------------------------------------------------------------------------
   Forms / calculators
   -------------------------------------------------------------------------- */

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.6rem);
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
}

.tool h2,
.tool h3 {
  margin-top: 0;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="date"],
input[type="number"],
select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  min-width: 9.5rem;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.result {
  border-top: 1px dashed var(--border-strong);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.result-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.result-item {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}

.result-item .l {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.result-item .v {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}

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

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  margin-bottom: 0.6rem;
}

.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 1.1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--faint);
  line-height: 1;
  transition: transform 0.15s ease;
}

.faq details[open] summary::after {
  transform: rotate(45deg);
}

.faq details > div {
  padding: 0 1.1rem 1rem;
  color: var(--muted);
}

.faq details > div > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Breadcrumbs, page headers, TOC
   -------------------------------------------------------------------------- */

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--faint);
  margin-bottom: 1.2rem;
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs .sep {
  padding-inline: 0.45em;
}

.page-head {
  max-width: var(--text-max);
  margin-bottom: 2rem;
}

.page-head .lede {
  font-size: 1.15rem;
  color: var(--muted);
  text-wrap: pretty;
}

.updated {
  font-size: 0.85rem;
  color: var(--faint);
}

.toc {
  border-left: 3px solid var(--accent-soft);
  padding: 0.2rem 0 0.2rem 1.2rem;
  margin: 1.5rem 0 2rem;
  font-size: 0.95rem;
}

.toc strong {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.toc a {
  display: block;
  padding: 0.15rem 0;
}

/* --------------------------------------------------------------------------
   Pills (week / year link lists)
   -------------------------------------------------------------------------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  list-style: none;
}

.pills a {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.pills a:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pills a.now {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Printable calendar layouts
   -------------------------------------------------------------------------- */

.print-title {
  display: none;
}

.printable {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}

.printable table {
  font-size: 0.85rem;
}

.printable th,
.printable td {
  padding: 0.28rem 0.7rem;
}

@media (max-width: 44rem) {
  .printable {
    grid-template-columns: 1fr;
  }
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 4rem;
  padding-block: 2.5rem 2rem;
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  margin-bottom: 2rem;
}

.footer-grid h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-grid li {
  margin-bottom: 0.4rem;
}

.footer-grid a {
  color: var(--ink);
}

.footer-grid a:hover {
  color: var(--accent-ink);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  color: var(--faint);
  border-top: 1px solid var(--border);
  padding-top: 1.2rem;
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #f2f2f2;
    --ink: #000;
    --muted: #444;
    --border: #bbb;
    --shadow: none;
    --shadow-lift: none;
  }

  body {
    font-size: 9pt;
  }

  .site-header,
  .site-footer,
  .breadcrumbs,
  .btn-row,
  .btn,
  .no-print,
  .faq,
  .pager,
  .toc {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .print-title {
    display: block;
    text-align: center;
    margin-bottom: 0.5rem;
  }

  .page-head .lede,
  .updated {
    display: none;
  }

  .table-wrap,
  .card,
  .tool {
    border: 0;
    box-shadow: none;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  thead th {
    position: static;
  }

  .printable table {
    font-size: 7.5pt;
  }

  .printable th,
  .printable td {
    padding: 1.5pt 6pt;
    border-bottom: 0.5pt solid #ccc;
  }

  tr.is-now {
    box-shadow: none;
    background: #eee;
  }

  a {
    color: inherit;
  }
}
