/* badges.css — badges, the school-week streak and the daily study goal (SPEC §8.6): the badge art (lib/badge-art.js),
   the speller's Home cards, summary extras and My badges page (lib/badges-kid.js, pages/student-badges.js), the parent's
   "Study habits and badges" section (lib/parent-badges.js) and the coordinator's stamp note preview. Loaded by
   student/index.html, practice.html and badges.html (after practice.css, BEFORE themes.css, which stays last),
   parent/speller.html and admin/origin.html. Colors come ONLY from the existing tokens of app.css :root, so every
   speller theme recolors everything; each glyph/fill pair is one tests/unit/themes.test.mjs already checks. No new tokens. */

/* ---------- Badge art: fills, glyphs and the hexagon edge (--forest on --card / --cream: 4.5:1 in every theme) ---------- */
.badge-art { flex: none; display: block; overflow: visible; }
.badge-art .ba-edge { stroke: var(--forest); stroke-width: 1.3; stroke-linejoin: round; }
.badge-art .ba-fill { fill: var(--card); }
.ba-level .ba-fill { fill: var(--cream-2); }                           /* empty part of the list */
.ba-level .ba-rise { fill: var(--forest-2); }                          /* --forest-2 on --cream-2: 3:1 (bar fill) */
.ba-level .ba-disc { fill: var(--card); stroke: var(--forest); stroke-width: .8; }
.ba-level .ba-num { fill: var(--pine); font-family: var(--display); font-weight: 800; font-size: 7px; }   /* --pine on --card */
.ba-level .ba-ink { fill: var(--pine); }
.ba-champion .ba-fill, .ba-keepsake .ba-fill { fill: var(--sun); }     /* --on-sun on --sun */
.ba-champion .ba-ink, .ba-keepsake .ba-ink { fill: var(--on-sun); }
.ba-keepsake .ba-line { stroke: var(--on-sun); }
.ba-comeback .ba-fill { fill: var(--mint); }                           /* --pine on --mint */
.ba-comeback .ba-line { stroke: var(--pine); }
.ba-comeback .ba-ink { fill: var(--pine); }
.ba-hive .ba-fill { fill: var(--sun-soft); }                           /* --sun-ink on --sun-soft */
.ba-hive .ba-ink { fill: var(--sun-ink); }
.ba-weeks .ba-fill { fill: var(--sage); }                              /* --forest on --sage */
.ba-weeks .ba-line { stroke: var(--forest); }
.ba-goal .ba-fill { fill: var(--forest-2); }                           /* --on-forest on --forest-2 */
.ba-goal .ba-line { stroke: var(--on-forest); }
.ba-stamp .ba-fill { fill: var(--card); }                              /* --pine / --forest on --card */
.ba-stamp .ba-line { stroke: var(--forest); }
.ba-stamp .ba-ink { fill: var(--pine); }
.ba-traveler .ba-fill { fill: var(--forest); }                         /* --on-forest on --forest */
.ba-traveler .ba-line { stroke: var(--on-forest); }

/* Lists: margin resets at zero specificity (:where), so .stack's spacing between siblings still applies. Paragraphs: only the
   bottom margin (app.css p { margin: 0 0 1em }), for the same reason. */
:where(.badge-rows, .badge-mini, .badge-grid, .how-list, .plan-list, .break-list, .pb-list) { margin: 0; }
.new-flag, .comeback-line, .goal-line, .season-numbers, .study-legend, .flush { margin-bottom: 0; }

/* ---------- Badge rows (Home, summaries) and the newest three ---------- */
.badge-rows { list-style: none; padding: 0; display: grid; gap: 14px; }
.badge-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: center; }
.badge-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.badge-name { color: var(--pine); font-size: 1.08rem; line-height: 1.25; }
.badge-text { line-height: 1.4; }
/* A stamp's tip (lib/origin-tips.js tipList): its lines as a short list in a soft box (--ink on --sage), across the whole
   row so a long tip (up to 5 lines, ~550 characters) never squeezes next to the art. */
.badge-note { margin: 2px 0 0; padding: 8px 12px 8px 30px; border-left: 3px solid var(--forest-2); border-radius: 6px; background: var(--sage);
  color: var(--ink); font-size: .95rem; line-height: 1.4; }
.badge-row > .badge-note { grid-column: 1 / -1; }
.new-flag { display: inline-block; padding: 2px 12px; border-radius: 999px; background: var(--sun-soft); color: var(--sun-ink); font-weight: 800; font-size: .9rem; }
.badge-mini { list-style: none; padding: 0; display: grid; gap: 8px; }
.badge-mini li { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--pine); line-height: 1.3; }
.shelf { display: flex; gap: 14px; align-items: center; }
.shelf p { margin: 0; }

/* ---------- Home: My practice (the goal ring, the streak, Hive Days) ---------- */
.habit-grid { align-items: start; }
.goal-row { display: flex; gap: 14px; align-items: center; }
.goal-row p { margin: 0; }
.goal-ring-wrap { position: relative; flex: none; display: grid; place-items: center; width: 64px; height: 64px; }
.goal-ring { position: absolute; inset: 0; }
/* The "not yet" track: a THIN --line-strong circle (3:1 on --card in every theme, the input-border pair), so the ring never
   disappears at 0 minutes; the arc is THICK --forest-2 (4.5:1 on --card): they differ in width, not only in color. */
.ring-track { stroke: var(--line-strong); }
.ring-arc { stroke: var(--forest-2); }
.ring-num { position: relative; font-family: var(--display); font-weight: 800; font-size: 1.1rem; line-height: 1; color: var(--pine); }
.goal-ring-wrap .hex { position: relative; color: var(--forest-2); }
.goal-text { font-weight: 800; color: var(--pine); font-size: 1.1rem; line-height: 1.3; }
.streak-lines { display: grid; gap: 4px; }
.streak-lines p { margin: 0; }
.streak-line { font-weight: 800; color: var(--pine); }
.streak-note { padding: 6px 10px; border-radius: var(--r-sm); background: var(--sage); color: var(--ink); }

/* ---------- Home: the Bee ticket (before the Bee) and the wrap-up (30 days after) ---------- */
.bee-ticket { display: flex; gap: 16px; align-items: center; padding-block: 16px; background: var(--sage); border: 2px dashed var(--forest-2); }
.bee-ticket p { margin: 0; }
.bee-ticket .hex { flex: none; color: var(--forest-2); }
.ticket-title { margin: 0 0 2px; }

/* ---------- Round / Study summary: New badge!, Comeback!, study time (never mid-word) ---------- */
.nb-card { padding: 14px 16px; border: 2px solid var(--sun-line); border-radius: var(--r); background: var(--sun-soft); animation: badge-pop .25s ease-out; }
.nb-card h2 { margin: 0; }
.nb-card a { color: var(--pine); }                                     /* --pine on --sun-soft */
@keyframes badge-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.goal-line { font-weight: 700; color: var(--pine); }
@media (max-width: 480px) {
  .badge-row .badge-art { width: 56px; height: 61px; }
}

/* ---------- My badges (/student/badges) ---------- */
.badge-groups > section + section { margin-top: 1.75rem; }
.badge-grid { list-style: none; padding: 0; display: grid; gap: 18px 12px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.badge-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.badge-tile .badge-name { font-size: .98rem; }
.badge-day { font-size: .85rem; color: var(--muted); }
.badge-tile.wide { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px 16px; text-align: left; }
.badge-tile.wide > .badge-note { grid-column: 1 / -1; }
@media (min-width: 600px) {
  .badge-tile.wide > .badge-art { grid-row: span 2; }
  .badge-tile.wide > .badge-note { grid-column: 2; }
}
.badge-tile.wide .badge-words { gap: 4px; }
.season-numbers { font-weight: 700; color: var(--pine); }
.how-list { padding-left: 1.2em; }
.how-list li + li { margin-top: 8px; }
@media (max-width: 480px) {
  .badge-tile.wide .badge-art { width: 72px; height: 78px; }
}

/* ---------- Parent: "Study habits and badges" (lib/parent-badges.js) ---------- */
.switch-row { display: flex; gap: 12px; align-items: center; font-weight: 800; color: var(--pine); cursor: pointer; }
.switch-row input { flex: none; width: 44px; height: 24px; margin: 0; accent-color: var(--forest); }
.plan-list { padding: 0; list-style: none; display: grid; gap: 12px; }
.plan-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.plan-list .hint { flex-basis: 100%; }
.break-list { padding: 0; list-style: none; display: grid; gap: 8px; }
.break-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.study-chart { position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; align-items: end; height: 160px; padding-top: 18px; }
.sc-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.sc-bar { position: relative; display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--forest-2); }
.sc-bar .hex { position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%); }
.sc-col.off .sc-bar { background: var(--line-strong); }                 /* days off: lighter (--line-strong on --card: 3:1) */
.sc-col .hex { color: var(--forest); }
.sc-goal { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--pine); pointer-events: none; }
.study-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--muted); }
.study-legend .k { display: inline-flex; align-items: center; gap: 6px; }
.study-legend .k-bar { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--forest-2); }
.study-legend .k-off { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--line-strong); }
.study-legend .k-goal { display: inline-block; width: 16px; border-top: 2px dashed var(--pine); }
.study-legend .hex { color: var(--forest); }
.pb-list { list-style: none; padding: 0; display: grid; }
.pb-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 4px 14px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.pb-row:first-child { border-top: 0; padding-top: 0; }
.pb-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.pb-head strong { color: var(--pine); }
.pb-rule, .pb-talk, .pb-note { grid-column: 2; margin: 0; font-size: .95rem; }
.pb-note { margin-top: 4px; }
@media (max-width: 599px) {
  .pb-row > .pb-note { grid-column: 1 / -1; }
}
.pb-talk { color: var(--muted); }
.pb-row .badge-art { grid-row: span 3; }
.dialog-days { display: grid; gap: 10px 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.dialog-days > .check { margin-top: 0; }
.season-lines { display: grid; gap: 4px; }
.note-state { white-space: normal; text-align: left; }

/* ---------- Coordinator: the stamp note card's preview (lib/stamp-note-card.js) ---------- */
.stamp-preview { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--cream); }
.stamp-preview p { margin: 0; }
.stamp-preview > .stack { flex: 1; min-width: 0; }
.new-suggestion { padding: 10px 14px; border: 2px solid var(--sun-line); border-radius: var(--r-sm); background: var(--sun-soft); color: var(--ink); }
.new-suggestion p { margin: 0; }
.new-suggestion summary { cursor: pointer; font-weight: 700; color: var(--pine); }
.new-suggestion .tip-lines { margin-top: 8px; }
.new-suggestion-chip { margin-left: 6px; }

@media (prefers-reduced-motion: reduce) {
  .nb-card { animation: none; }
}
@media (forced-colors: active) {
  .badge-art .ba-fill, .ba-level .ba-disc { fill: Canvas; }
  .badge-art .ba-rise { fill: Highlight; }
  .badge-art .ba-ink, .ba-level .ba-num { fill: CanvasText; }
  .badge-art .ba-line, .badge-art .ba-edge, .ba-level .ba-disc { stroke: CanvasText; }
  .ring-track { stroke: CanvasText; } .ring-arc { stroke: Highlight; }
  .sc-bar, .sc-col.off .sc-bar { background: Highlight; }
  .nb-card, .bee-ticket, .badge-note, .stamp-preview { border: 2px solid CanvasText; }
}
