/* ============================================================
   toolshed-common.css — shared theme tokens + chrome styles
   Used by: site, morning-work, math-playground, work-cycle-timer

   Import once per page (before first paint):
     <link rel="stylesheet" href="https://swankymcgee.github.io/toolshed-common/css/toolshed-common.css">

   This file defines:
     - CSS custom properties for all 11 themes (via [data-theme] blocks)
       Including site-specific: --dim, --why-bg, --why-border, --hold-bg, --hold-text, --hold-border
     - Base reset, typography, links
     - Header/footer chrome styles (.site-head, .brand, .site-nav, .site-foot)
     - Hold button styles (.hold-btn, .hold-track, .hold-fill, .holding)
     - Palette picker styles (.theme-wrap, .theme-btn, .theme-panel, .theme-opt, .theme-chip)
     - Motif toggle styles (.motif-btn, .motif-state)
     - Card base styles (.card, .card:hover)
     - Button base styles (.btn, .ghost-btn)
     - Focus-visible outlines (using --accent)
     - .lbl utility for exact on-screen wording

   Each tool adds its own stylesheet AFTER this one for tool-specific
   components (dials, games, morning parts, etc.).
   ============================================================ */

/* ---------- Theme tokens ----------
   11 palettes. chips = [bg, surface, text, accent, accent2].
   Keep in step with THEMES array in toolshed-common.js.
   Site-specific additions: --dim (alias for --text-dim with per-theme tweaks),
   --why-bg/--why-border (card highlights), --hold-bg/--hold-text/--hold-border (hold button). */
:root {
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-2: #e9eff3;
  --text: #33414d;
  --text-dim: #6b7c8a;
  --dim: #6b7c8a;
  --border: #d5dfe6;
  --border-strong: #b9c8d3;
  --accent: #4d84a6;
  --accent2: #628f5d;
  --why-bg: #e9eff3;
  --why-border: #d5dfe6;
  --hold-bg: #fdf3dd;
  --hold-text: #7a5c1e;
  --hold-border: #eeddb3;
}

[data-theme="calm"] {
  --bg: #f2f6f8; --surface: #ffffff; --surface-2: #e9eff3;
  --text: #33414d; --text-dim: #6b7c8a; --dim: #6b7c8a;
  --border: #d5dfe6; --border-strong: #b9c8d3;
  --accent: #4d84a6; --accent2: #628f5d;
  --why-bg: #e9eff3; --why-border: #d5dfe6;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/calm.jpg");
}
[data-theme="lavender"] {
  --bg: #f5f3fb; --surface: #ffffff; --surface-2: #ece8f7;
  --text: #3d3a52; --text-dim: #75708f; --dim: #75708f;
  --border: #ddd7ef; --border-strong: #c5bce6;
  --accent: #7a6fc0; --accent2: #6a9a76;
  --why-bg: #ece8f7; --why-border: #ddd7ef;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/lavender.jpg");
}
[data-theme="mint"] {
  --bg: #eef8f3; --surface: #ffffff; --surface-2: #e0f0e8;
  --text: #2f4640; --text-dim: #648076; --dim: #648076;
  --border: #cfe6dc; --border-strong: #aed2c3;
  --accent: #35837e; --accent2: #6f9a58;
  --why-bg: #e0f0e8; --why-border: #cfe6dc;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/mint.jpg");
}
[data-theme="peach"] {
  --bg: #fdf6ef; --surface: #fffdfb; --surface-2: #f9ece0;
  --text: #4d3f34; --text-dim: #8a7566; --dim: #8a7566;
  --border: #f0e0d0; --border-strong: #e0c9b4;
  --accent: #c26a3c; --accent2: #7a9a5a;
  --why-bg: #f9ece0; --why-border: #f0e0d0;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/peach.jpg");
}
[data-theme="rose"] {
  --bg: #fdf4f6; --surface: #ffffff; --surface-2: #f9e7ec;
  --text: #4f3540; --text-dim: #8c6b78; --dim: #8c6b78;
  --border: #f2dae1; --border-strong: #e4c2cd;
  --accent: #c25f7e; --accent2: #6f9466;
  --why-bg: #f9e7ec; --why-border: #f2dae1;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/rose.jpg");
}
[data-theme="ocean"] {
  --bg: #eef8fa; --surface: #ffffff; --surface-2: #dff0f4;
  --text: #2c4750; --text-dim: #5f7f89; --dim: #5f7f89;
  --border: #cfe6eb; --border-strong: #aed3dc;
  --accent: #2f87a3; --accent2: #5f9a6a;
  --why-bg: #dff0f4; --why-border: #cfe6eb;
  --hold-bg: #fdf3dd; --hold-text: #7a5c1e; --hold-border: #eeddb3;

  --foot-img: url("../img/footers/ocean.jpg");
}
[data-theme="low"] {
  --bg: #eef1f3; --surface: #f6f8f9; --surface-2: #eaedef;
  --text: #5b6570; --text-dim: #838d97; --dim: #838d97;
  --border: #e2e6e9; --border-strong: #d3d9dd;
  --accent: #94b4c3; --accent2: #a9c5a5;
  --why-bg: #eaedef; --why-border: #e2e6e9;
  --hold-bg: #f4efe3; --hold-text: #8a8172; --hold-border: #e8e0cf;

  --foot-img: url("../img/footers/low.jpg");
}
[data-theme="high"] {
  --bg: #000000; --surface: #0b0d10; --surface-2: #16191e;
  --text: #ffffff; --text-dim: #d0d6dc; --dim: #d0d6dc;
  --border: #ffffff; --border-strong: #ffffff;
  --accent: #56e0ff; --accent2: #b7ff5e;
  --why-bg: #16191e; --why-border: #ffffff;
  --hold-bg: #2a2105; --hold-text: #ffe066; --hold-border: #ffe066;

  --foot-img: url("../img/footers/high.jpg");
}
[data-theme="dark"] {
  --bg: #151a20; --surface: #1e242b; --surface-2: #252c34;
  --text: #e7edf2; --text-dim: #9aa7b3; --dim: #9aa7b3;
  --border: #323b45; --border-strong: #46525e;
  --accent: #6fa9c7; --accent2: #8fbf88;
  --why-bg: #252c34; --why-border: #323b45;
  --hold-bg: #3a3320; --hold-text: #f0dca6; --hold-border: #5c5030;

  --foot-img: url("../img/footers/dark.jpg");
}
[data-theme="midnight"] {
  --bg: #0a0f1e; --surface: #121a30; --surface-2: #1a2440;
  --text: #e3e9f7; --text-dim: #9aa6c4; --dim: #9aa6c4;
  --border: #2c3a5e; --border-strong: #415480;
  --accent: #6fa8ff; --accent2: #67d6a5;
  --why-bg: #1a2440; --why-border: #2c3a5e;
  --hold-bg: #1c2745; --hold-text: #a9c6f5; --hold-border: #3d5585;

  --foot-img: url("../img/footers/midnight.jpg");
}
[data-theme="warm"] {
  --bg: #211a14; --surface: #2b221a; --surface-2: #352a20;
  --text: #f0e6da; --text-dim: #b3a291; --dim: #b3a291;
  --border: #4a3c2e; --border-strong: #63513e;
  --accent: #d9a05f; --accent2: #93b877;
  --why-bg: #352a20; --why-border: #4a3c2e;
  --hold-bg: #3a3020; --hold-text: #f0dca6; --hold-border: #5c4c2e;

  --foot-img: url("../img/footers/warm.jpg");
}

/* Motifs off switch (home page background patterns) */
.motifs-off .hero-art::before,
.motifs-off .hero-art::after {
  display: none;
}

/* ---------- Base reset ---------- */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background-color .35s ease, color .35s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

/* ---------- Header / nav ---------- */
.site-head, .app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.2rem;
  align-items: center;
}
.brand { display: flex; flex-direction: column; gap: .1rem; }
.brand-link { text-decoration: none; color: inherit; }
.brand h1 { font-weight: 800; font-size: 1.1rem; margin: 0; }
.brand-sub { font-size: .7rem; color: var(--dim); }
.site-nav, .header-tools nav.site-nav {
  display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .92rem;
}
.site-nav a { color: var(--accent); }
.site-nav a:hover, .site-nav a:focus-visible { text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }

.header-tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.header-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }

/* ---------- Hold button ---------- */
.hold-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .4rem .8rem .4rem .6rem;
  min-height: 40px;
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.hold-btn:hover { border-color: var(--accent); }
.hold-btn.holding { border-color: var(--accent); color: var(--accent); }
.hold-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hold-track { position: relative; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--surface-2); overflow: hidden; flex-shrink: 0; }
.hold-fill { display: block; width: 100%; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left center; border-radius: 50%; }
.hold-icon { display: inline-flex; align-items: center; }
.hold-icon svg { display: block; }

/* ---------- Footer (shared across every Toolshed page) ----------
   Scene on top — a little workbench vignette drawn purely in the
   active palette's variables — then the phrase, one rotating line of
   shed wisdom, and the page's meta line. */
.site-foot, .app-foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0 1.2rem 1.4rem;
  font-size: .85rem;
  color: var(--dim);
  text-align: center;
}
.foot-scene {
  position: relative;
  display: block;
  width: min(100%, 1080px);
  aspect-ratio: 1100 / 160;
  margin: 0 auto;
  padding-top: .4rem;
  /* One generated panorama per palette, painted from --foot-img so it
     tracks the theme switch. The twinkles stay inline SVG on top. */
  background: var(--foot-img) center / cover no-repeat;
}
.foot-scene svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.foot-phrase { margin: .3rem 0 0; font-size: .95rem; font-weight: 700; color: var(--text); }
.foot-phrase a { color: var(--accent); }
.foot-wisdom {
  margin: .35rem 0 0;
  min-height: 1.4em;
  font-style: italic;
  color: var(--dim);
  transition: opacity .6s ease;
}
.foot-wisdom.fading { opacity: 0; }
.foot-meta { margin: .55rem 0 0; font-size: .8rem; }
.foot-meta a { color: var(--accent); }

/* Scene life: tools sway on their pegs, the sprout nods, the two
   twinkles breathe — all slow, and all switched off entirely when
   the visitor prefers reduced motion. */
.foot-scene .sway { transform-box: fill-box; transform-origin: 50% 0%; }
.foot-scene .nod { transform-box: fill-box; transform-origin: 50% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .foot-scene .sway { animation: toolSway 6s ease-in-out infinite alternate; }
  .foot-scene .nod { animation: sproutNod 7s ease-in-out infinite alternate; }
  .foot-scene .glow { animation: twinkle 4.5s ease-in-out infinite alternate; }
}
@keyframes toolSway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
@keyframes sproutNod { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes twinkle { from { opacity: .3; } to { opacity: .85; } }
@media (prefers-reduced-motion: reduce) {
  .foot-wisdom { transition: none; }
}

/* ---------- Cards ---------- */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h3 { margin: 0 0 .3rem; color: var(--accent); font-size: 1.05rem; }
.card p { margin: 0; font-size: .93rem; color: var(--dim); }
.card .go { display: inline-block; margin-top: .6rem; font-weight: 700; color: var(--accent); font-size: .93rem; }

/* Primary card variant (hero door) */
.card.primary { border: 2px solid var(--accent); background: linear-gradient(160deg, var(--surface-2), var(--surface)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .6rem 1rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.ghost-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.ghost-btn:hover { background: var(--surface-2); border-color: var(--accent); }

/* ---------- Palette picker ---------- */
.theme-wrap { position: relative; }
.theme-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; padding: .4rem .8rem;
  color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-panel {
  position: absolute; top: calc(100% + .4rem); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: .6rem; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 220px; max-height: 70vh; overflow: auto; z-index: 100;
}
.theme-opt {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; padding: .5rem .7rem; text-align: left; cursor: pointer;
}
.theme-opt:hover { background: var(--surface-2); border-color: var(--accent); }
.theme-opt.active { border-color: var(--accent); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.theme-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-name { flex: 1; font-size: .85rem; color: var(--text); }
.theme-chips { display: flex; gap: 2px; }
.theme-chip { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ---------- Motif toggle ---------- */
.motif-btn {
  display: inline-flex; align-items: center; gap: .5rem; width: 100%;
  background: transparent; border: none; padding: .4rem 0;
  color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.motif-btn:hover { color: var(--accent); }
.motif-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.motif-state { font-weight: 700; color: var(--accent); margin-left: auto; }

/* ---------- .lbl utility ----------
   Exact on-screen wording — used for button labels in prose. */
.lbl {
  font-weight: 700;
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .05rem .42rem;
  white-space: nowrap;
}

/* ---------- Form controls ---------- */
input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem;
}
input[type="range"] { accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; }
th, td { padding: .5rem .7rem; border: 1px solid var(--border); text-align: left; }
th { background: var(--surface-2); color: var(--accent); font-weight: 700; }

/* ---------- Lists ---------- */
ol.steps > li::marker { font-weight: 800; color: var(--accent); }

/* ---------- Visually hidden ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}