/* ==========================================================================
   Homebelts — shared design system ("family toolbelt")
   Warm paper · pine-green brand · honey accent · system type + mono utility.
   Tokens live on :root so they also reach inside <hub-nav>'s Shadow DOM
   (custom properties inherit through shadow boundaries).
   ========================================================================== */

/* ---- Design tokens: light (default) ---------------------------------- */
:root {
  --bg:        #ECEDE6;   /* sage-warm paper                     */
  --bg-2:      #E2E4DA;   /* rails, sidebar, insets              */
  --surface:   #FBFBF8;   /* cards                               */
  --ink:       #23261F;   /* warm near-black text                */
  --ink-soft:  #4C5145;   /* secondary text                     */
  --muted:     #737A68;   /* captions, meta                      */
  --line:      #D5D8CB;   /* hairlines / stitching               */
  --brand:     #2E6B4E;   /* pine green                          */
  --brand-ink: #1E4A36;   /* pine for text/icons on light        */
  --accent:    #D9950F;   /* honey / amber                       */
  --danger:    #A8412B;   /* brick (destructive)                 */
  --on-brand:  #F6F8F2;   /* text on brand fills                 */

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --fs-display: clamp(2.1rem, 1.4rem + 3vw, 3.6rem);
  --fs-h2:      clamp(1.25rem, 1.05rem + 0.9vw, 1.7rem);
  --fs-body:    1rem;
  --fs-sm:      0.875rem;
  --fs-xs:      0.75rem;

  /* Space, radius, shadow */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;  --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.5rem;  --sp-6: 2rem;  --sp-8: 3rem;
  --r-sm: 8px;  --r: 14px;  --r-lg: 22px;  --r-pill: 999px;
  --shadow: 0 1px 2px rgba(30, 34, 24, .06), 0 8px 24px -12px rgba(30, 34, 24, .22);
  --shadow-lift: 0 2px 4px rgba(30, 34, 24, .08), 0 18px 40px -16px rgba(30, 34, 24, .30);

  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

/* ---- Dark: applied when the system is dark (unless forced light),
        or when the theme toggle forces dark. ------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14160F;
    --bg-2:      #1B1E15;
    --surface:   #22261B;
    --ink:       #ECEDE2;
    --ink-soft:  #C6CAB8;
    --muted:     #929A80;
    --line:      #333828;
    --brand:     #63B98A;
    --brand-ink: #8FD4AC;
    --accent:    #EDB343;
    --danger:    #E0765A;
    --on-brand:  #0F1A13;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:        #14160F;
  --bg-2:      #1B1E15;
  --surface:   #22261B;
  --ink:       #ECEDE2;
  --ink-soft:  #C6CAB8;
  --muted:     #929A80;
  --line:      #333828;
  --brand:     #63B98A;
  --brand-ink: #8FD4AC;
  --accent:    #EDB343;
  --danger:    #E0765A;
  --on-brand:  #0F1A13;
  color-scheme: dark;
}

/* ---- Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }  /* beat component display rules (.btn, etc.) */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; }

/* ---- Focus & a11y ----------------------------------------------------- */
:focus-visible {
  outline: 2.5px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.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;
}

/* ---- Layout shell (offsets for the fixed <hub-nav>) ------------------- */
.hub-shell {
  min-height: 100vh;
  transition: padding-left .28s var(--ease);
}
@media (min-width: 860px) {
  .hub-shell { padding-left: var(--hub-nav-w, 248px); }
}
@media (max-width: 859px) {
  .hub-shell { padding-top: var(--hub-nav-top, 56px); }
}
.container {
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  padding: clamp(var(--sp-5), 3vw, var(--sp-8)) clamp(var(--sp-4), 3vw, var(--sp-6));
}

/* ---- Shared bits: eyebrow, chip -------------------------------------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0.6rem 1.05rem;
  min-height: 44px;                 /* comfortable tap target */
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  transition: transform .06s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.btn--primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-2); border-color: transparent; }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Card ------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---- Signature: punch-hole "tag" card --------------------------------
   Each tag can set its own --accent (from apps.json) inline.            */
.tag {
  --accent: var(--brand);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  padding-left: calc(var(--sp-5) + 10px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              border-color .18s var(--ease), background .18s var(--ease);
}
/* accent spine down the left edge */
.tag::before {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 6px;
  background: var(--accent);
  opacity: .9;
}
/* stitched inset border */
.tag::after {
  content: "";
  position: absolute; inset: 7px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: calc(var(--r-lg) - 7px);
  pointer-events: none;
  opacity: .55;
}
.tag:hover, .tag:focus-visible {
  transform: scale(1.02);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent),
    0 12px 32px -16px color-mix(in srgb, var(--accent) 60%, transparent);
}
/* brighten the accent details on hover for the "light up" feel */
.tag:hover::before, .tag:focus-visible::before { opacity: 1; }
.tag:hover .tag__hole, .tag:focus-visible .tag__hole {
  border-color: var(--accent);
}
/* hang-hole, ringed in the accent */
.tag__hole {
  position: absolute;
  top: var(--sp-4); right: var(--sp-4);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid color-mix(in srgb, var(--accent) 65%, var(--line));
}
.tag__name { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.tag__desc { color: var(--ink-soft); font-size: var(--fs-sm); }
.tag__meta { margin-top: auto; padding-top: var(--sp-3); }

/* ---- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
