/* ============================================================
   Chore Star — MVP stylesheet
   Two worlds live here:
   1. The APP chrome (controls, header) — screen only, hidden on print.
   2. The CHART (.chart) — the printable artefact. Print CSS at the
      bottom scales it to a clean A4 page.
   ============================================================ */

:root {
  /* Theme colour is driven by JS via --accent / --accent-soft */
  --accent: #6c5ce7;
  --accent-soft: #efeafe;
  --brand: #6c5ce7;                /* fixed brand purple — never changes with chart colour */
  --ink: #2b2b3a;
  --ink-soft: #6a6a7c;
  --line: #e6e6ef;
  --bg: #f4f3fb;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(40, 30, 90, 0.08);
  --header-h: 70px;                /* height of the pinned header */
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 14px);   /* so anchors clear the pinned header */
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, legend, .chart-title h2 { font-family: "Fredoka", "Nunito", sans-serif; }

/* ---------- Site header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(40, 30, 90, 0.05);
}
.site-header-inner {
  max-width: 1500px; margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: baseline; gap: 9px; text-decoration: none; }
.brand-name { font-family: "Fredoka", "Nunito", sans-serif; font-weight: 600; font-size: 30px; line-height: 1; letter-spacing: -.3px; white-space: nowrap; }
.brand-name .i { color: var(--ink); }
.brand-name .p { color: var(--brand); }
.brand-icon { width: 40px; height: auto; flex: 0 0 auto; transform: translateY(3px); }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 15px; white-space: nowrap; }
.site-nav a:hover { color: var(--brand); }
@media (max-width: 620px) { .site-nav { gap: 13px; } .site-nav a { font-size: 14px; } }
@media (max-width: 480px) { .site-nav { display: none; } }

/* ---------- Intro ---------- */
.intro { max-width: 1500px; margin: 0 auto; padding: 22px 28px 4px; }
.intro-title { margin: 0; font-size: 26px; font-weight: 700; }
.tagline { margin: 6px 0 0; color: var(--ink-soft); font-weight: 600; font-size: 15px; }

/* ---------- Site footer ---------- */
.site-footer { margin-top: 40px; background: var(--card); border-top: 1px solid var(--line); }
.site-footer-inner { max-width: 1500px; margin: 0 auto; padding: 24px 28px; color: var(--ink-soft); }
.brand-footer { margin-bottom: 14px; }
.footer-about { margin: 0 0 10px; font-size: 13px; font-weight: 600; max-width: 720px; line-height: 1.55; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.footer-links a { color: var(--ink-soft); font-weight: 700; font-size: 13px; text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { margin: 0; font-size: 13px; font-weight: 700; }

/* ---------- SEO content (how-to + FAQ) ---------- */
.content { max-width: 820px; margin: 0 auto; padding: 24px 28px 8px; }
.content h2 { font-size: 24px; margin: 0 0 14px; }
.content-lead { font-size: 16px; font-weight: 600; color: var(--ink-soft); line-height: 1.6; margin: 0 0 24px; }
.content-lead strong { color: var(--ink); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 18px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; font-size: 15px; margin-bottom: 10px; }
.steps h3 { font-size: 16px; margin: 0 0 6px; }
.steps p { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-soft); line-height: 1.55; }
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 0 18px; }
.faq summary { font-family: "Fredoka", "Nunito", sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); cursor: pointer; padding: 15px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--brand); font-size: 22px; font-weight: 700; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin: 0; padding: 0 0 16px; font-size: 14px; font-weight: 600; color: var(--ink-soft); line-height: 1.6; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
  padding: 16px 28px 60px;
  max-width: 1500px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: 16px; }

.card {
  position: relative;              /* anchor for the absolutely-placed legend */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 46px 18px 18px;         /* extra top padding leaves room for the heading */
  margin: 0;
}
/* Absolutely positioning the legend removes it from the fieldset's special
   layout, so the border draws unbroken (no notch) and the heading sits inside. */
legend {
  position: absolute;
  top: 18px;
  left: 18px;
  margin: 0;
  padding: 0;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
/* Extra breathing room below the heading. The Chores card is skipped because
   it already has a descriptive line directly under its heading. */
.controls fieldset:nth-of-type(-n+3) { padding-top: 56px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-weight: 700; font-size: 13px; color: var(--ink-soft); }

input[type="text"], input[type="number"] {
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fbfbff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.hint { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
small.hint { margin-top: 2px; }

/* ---------- Colour swatches ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1.5px var(--line);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--sw); transform: scale(1.08); }

/* ---------- Days toggle ---------- */
.days-toggle { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chip {
  font: inherit; font-weight: 700; font-size: 13px;
  padding: 8px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fbfbff; color: var(--ink-soft);
  cursor: pointer; transition: all .12s;
}
.day-chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---------- Chore list ---------- */
.chore-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.chore-row {
  display: grid;
  grid-template-columns: 22px 26px minmax(0, 1fr) auto 22px;
  align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 10px;
  border: 1.5px solid transparent;
}
.chore-row:hover { background: #fafaff; }
.chore-row.on { border-color: var(--accent-soft); background: var(--accent-soft); }
.chore-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.ic { display: block; object-fit: contain; }
.chore-emoji { display: flex; align-items: center; justify-content: center; }
.chore-emoji .ic { width: 24px; height: 24px; }
.chore-name { font-weight: 700; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Points-per-day dropdown in the chore list */
.chore-per { display: flex; align-items: center; gap: 4px; }
.per-unit { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.chore-perday {
  font: inherit; font-weight: 700; font-size: 13px;
  padding: 5px 4px 5px 8px; border: 1.5px solid var(--line);
  border-radius: 8px; background: #fbfbff; color: var(--ink); cursor: pointer;
}
.chore-perday:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* In the "add your own" row the grid stretches height; just set padding/size */
.add-row .chore-perday { padding: 0 4px 0 10px; font-size: 14px; }
.chore-del { border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: 15px; opacity: .5; }
.chore-del:hover { opacity: 1; color: #e2557b; }

/* ---------- Add chore ---------- */
.add-chore { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.add-title { font-weight: 800; font-size: 13px; margin: 0 0 8px; }
/* align-items: stretch makes every cell take the row's height (set by the
   text input), so the icon button, dropdown and Add button all match. */
.add-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 56px auto; gap: 8px; align-items: stretch; }
.icon-pick { display: flex; align-items: center; justify-content: center; width: 42px; border: 1.5px solid var(--line); border-radius: 10px; background: #fbfbff; cursor: pointer; }
.icon-pick .ic { width: 24px; height: 24px; }
.btn-add { font: inherit; font-weight: 800; padding: 9px 14px; border-radius: 10px; border: none; background: var(--accent); color: #fff; cursor: pointer; }
.btn-add:hover { filter: brightness(1.05); }
.icon-palette { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; padding: 8px; background: #fbfbff; border: 1.5px solid var(--line); border-radius: 10px; }
.icon-opt { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; background: none; border-radius: 8px; cursor: pointer; }
.icon-opt .ic { width: 24px; height: 24px; }
.icon-opt:hover { background: var(--accent-soft); }

/* ---------- Actions ---------- */
.actions { display: flex; gap: 10px; }
.btn-primary {
  flex: 1; font: inherit; font-weight: 800; font-size: 16px;
  padding: 14px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: var(--shadow); transition: filter .12s, transform .08s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { font: inherit; font-weight: 700; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer; }
.privacy-note { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-align: center; margin: 2px 4px 0; }

/* ============================================================
   THE CHART (printable artefact)
   ============================================================ */
.preview-wrap { display: flex; justify-content: center; }
.preview-scaler { width: 100%; max-width: 794px; /* A4 width @96dpi */ }
/* On desktop the chart rides along (sticky) as you scroll the controls, and
   stops at the bottom of the tool area — it can't leave .layout, so it never
   overlaps the "How it works" section below. */
@media (min-width: 901px) {
  .preview-wrap { position: sticky; top: calc(var(--header-h) + 16px); align-self: start; }
}

.chart {
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 22px;
  padding: 30px 34px 26px;
  box-shadow: var(--shadow);
  /* soft themed wash in the corners */
  background-image:
    radial-gradient(circle at 100% 0%, var(--accent-soft) 0%, transparent 32%),
    radial-gradient(circle at 0% 100%, var(--accent-soft) 0%, transparent 32%);
}

.chart-head { text-align: center; margin-bottom: 18px; }
.chart-stars { color: var(--accent); letter-spacing: 6px; font-size: 18px; }
.chart-title h2 { margin: 6px 0 2px; font-size: 34px; color: var(--accent); font-weight: 700; }
.chart-week { margin: 0; color: var(--ink-soft); font-weight: 700; font-size: 15px; }

.chart-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.chart-table th, .chart-table td { padding: 0; }

.chart-table thead th {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--ink-soft);
  padding: 6px 2px;
  text-align: center;
}
.chart-table thead th.col-chore { text-align: left; padding-left: 6px; }
.chart-table thead th.col-pts { color: var(--accent); }

.chart-table tbody tr td {
  border-top: 1.5px solid var(--line);
  height: 46px;
}
.chart-table tbody tr:first-child td { border-top: none; }

.cell-chore { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.cell-chore .emoji { width: 30px; height: 30px; flex: 0 0 auto; }
.cell-chore .label { font-weight: 700; font-size: 16px; }
.cell-day { text-align: center; vertical-align: middle; }
.tick {
  display: inline-block; width: 26px; height: 26px;
  border: 2px solid var(--accent);
  border-radius: 7px;
  opacity: .55;
}
.cell-pts { text-align: center; font-weight: 800; color: var(--accent); font-size: 16px; vertical-align: middle; }

.empty-hint { text-align: center; color: var(--ink-soft); font-weight: 700; padding: 30px 0; }

/* ---------- Chart footer ---------- */
.chart-foot { display: flex; gap: 16px; margin-top: 20px; align-items: stretch; flex-wrap: wrap; }
.reward-banner {
  flex: 1 1 300px;
  display: flex; align-items: center; gap: 14px;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  border-radius: 14px; padding: 14px 18px;
}
.reward-star { font-size: 30px; }
.reward-label { margin: 0; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.reward-value { margin: 2px 0 0; font-weight: 800; font-size: 17px; color: var(--ink); }

.score-box { flex: 1 1 200px; display: flex; flex-direction: column; justify-content: center; }
.score-label { margin: 0 0 6px; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.score-track { display: flex; flex-wrap: wrap; gap: 5px; }
.score-star {
  width: 22px; height: 22px; border-radius: 5px;
  border: 2px solid var(--accent); opacity: .4;
}

/* ============================================================
   PRINT — crisp vector A4. Only the chart survives.
   ============================================================ */
@page { size: A4 portrait; margin: 12mm; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .layout { display: block; padding: 0; margin: 0; max-width: none; }
  .preview-wrap { display: block; }
  .preview-scaler { max-width: none; width: 100%; }
  .chart {
    border-radius: 0;
    box-shadow: none;
    border: 2px solid var(--accent);
    padding: 10mm 12mm;
    /* keep the wash light so home printers don't drink ink */
    background-image: none;
  }
  .tick, .score-star { opacity: 1; }
  /* Keep the colourful icons colourful on paper */
  .ic { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Don't split a chore row across pages */
  .chart-table tbody tr { break-inside: avoid; }
  .chart-foot { break-inside: avoid; }
}
