/* ============================================================
   SGELA — COMPONENTS.  Direction B.

   Every value is a var(). Not one raw hex, size, radius or
   duration below. If something seems to need a value with no
   token, the system is missing a TOKEN — add it to tokens.css.

   The language, in one line: a 2px ink stroke and a flat offset
   shadow. If you find yourself writing a blur radius, stop.
   ============================================================ */

/* ─────────── Type roles ─────────── */
.sg-h1 { font-family: var(--font-display); font-size: var(--text-h1);
         line-height: var(--lh-heading); letter-spacing: var(--track-display);
         margin: 0; text-wrap: balance; }
.sg-h2 { font-family: var(--font-display); font-size: var(--text-h2);
         line-height: var(--lh-heading); letter-spacing: var(--track-heading);
         margin: 0; text-wrap: balance; }
.sg-h3 { font-family: var(--font-display); font-size: var(--text-h3);
         line-height: var(--lh-heading); letter-spacing: var(--track-heading); margin: 0; }
.sg-lead { font-size: var(--text-lead); line-height: var(--lh-body); margin: 0; max-width: 46ch; }
.sg-body { font-size: var(--text-body); line-height: var(--lh-body); margin: 0; max-width: 64ch; }
.sg-caption { font-size: var(--text-caption); color: var(--grey);
              line-height: var(--lh-body); margin: 0; }

/* The micro-label. Lexend 600 uppercase — this is where the system
   gets the weight Varela Round cannot give it. */
.sg-label { font-family: var(--font-body); font-weight: 600; font-size: var(--text-label);
            letter-spacing: var(--track-caps); text-transform: uppercase;
            display: block; margin: 0; }

/* The big number. Streak, XP, stat. */
.sg-stat { font-family: var(--font-display); font-size: var(--text-stat);
           line-height: var(--lh-tight); letter-spacing: var(--track-stat);
           display: block; }

/* ─────────── Button ───────────
   The signature: hover lifts up-left and the shadow GROWS;
   press moves down-right and the shadow collapses. The control
   visibly presses into its own shadow. */
.sg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-ui);
  line-height: 1; text-decoration: none; cursor: pointer;
  background: var(--indigo); color: var(--on-indigo);
  border: var(--stroke); border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--drop-sm);
  transition: transform var(--dur-ui) var(--ease),
              box-shadow var(--dur-ui) var(--ease),
              background var(--dur-ui) var(--ease);
}
.sg-btn:hover  { transform: translate(var(--nudge), var(--nudge)); box-shadow: var(--drop-lg); }
.sg-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink);
                 background: var(--indigo-deep); }
.sg-btn:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; }
 /* Not opacity: .45 measured 2.65:1. A learner should be able to READ
    what they cannot press, so disabled is a real fill, like everything
    else in this system. */
.sg-btn[disabled] { background: var(--paper-warm); color: var(--ink-soft);
                    border-color: var(--ink-soft); box-shadow: none;
                    pointer-events: none; }
.sg-btn--ink   { background: var(--ink);   color: var(--on-ink); }
.sg-btn--spark { background: var(--spark); color: var(--on-spark);
                 border-color: var(--ink-fixed); box-shadow: 3px 3px 0 var(--ink-fixed); }
.sg-btn--plain { background: var(--white); color: var(--ink); }
.sg-btn--wide  { width: 100%; }

/* ─────────── Pill ───────────
   Tags, chips, counters, filters. Outlined, never floating. */
.sg-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-label);
  letter-spacing: var(--track-caps); text-transform: uppercase;
  background: var(--white); color: var(--ink);
  border: var(--stroke-thin); border-radius: var(--radius-pill);
  padding: 5px var(--space-1); white-space: nowrap; cursor: default;
}
.sg-pill--spark  { background: var(--spark);  color: var(--on-spark);
                   border-color: var(--ink-fixed); }
.sg-pill--indigo { background: var(--indigo); color: var(--on-indigo); }
.sg-pill--growth { background: var(--growth); color: var(--on-growth); }
.sg-pill--danger { background: var(--danger); color: var(--on-danger); }
.sg-pill--quiet  { background: transparent; }

button.sg-pill { cursor: pointer;
  transition: background var(--dur-ui) var(--ease), color var(--dur-ui) var(--ease); }
button.sg-pill:hover { background: var(--indigo-soft); }
button.sg-pill[aria-pressed="true"] { background: var(--indigo); color: var(--on-indigo); }
button.sg-pill[aria-pressed="true"]:hover { background: var(--indigo-deep); }
button.sg-pill:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }

/* ─────────── Block ───────────
   The card. Fill carries the meaning, the stroke carries the edge.
   NEVER place two dark blocks flush — leave --space-1 of paper
   between them, or the strokes disappear into each other. */
.sg-block {
  background: var(--white); color: var(--ink);
  border: var(--stroke); border-radius: var(--radius-md);
  padding: var(--space-2);
  box-shadow: var(--drop-sm);
  display: flex; flex-direction: column; gap: 6px;
}
.sg-block--indigo { background: var(--indigo); color: var(--on-indigo); }
/* Light-filled blocks pin their stroke to --ink-fixed. In dark mode the
   stroke flips to near-white, which measures 1.78:1 on spark — invisible.
   The rule: the stroke is always the opposite of the fill it encloses. */
.sg-block--spark  { background: var(--spark);  color: var(--on-spark);
                    border-color: var(--ink-fixed); box-shadow: 3px 3px 0 var(--ink-fixed); }
.sg-block--growth { background: var(--growth); color: var(--on-growth); }
.sg-block--danger { background: var(--danger); color: var(--on-danger); }
.sg-block--paper  { background: var(--paper-warm); }
.sg-block--flat   { box-shadow: none; }
.sg-block--lg     { padding: var(--space-3); border-radius: var(--radius-lg); }

/* Interactive block — same press signature as the button. */
.sg-block--tap { cursor: pointer; text-align: left; width: 100%; font: inherit;
                 color: inherit;
                 transition: transform var(--dur-ui) var(--ease),
                             box-shadow var(--dur-ui) var(--ease); }
.sg-block--tap:hover  { transform: translate(var(--nudge), var(--nudge));
                        box-shadow: var(--drop-lg); }
.sg-block--tap:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.sg-block--tap:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; }

/* ─────────── Input ─────────── */
.sg-input {
  width: 100%; background: var(--white); color: var(--ink);
  font-family: var(--font-body); font-size: var(--text-ui); line-height: var(--lh-body);
  border: var(--stroke); border-radius: var(--radius-sm);
  padding: var(--space-2); box-shadow: var(--drop-sm);
  transition: box-shadow var(--dur-ui) var(--ease), transform var(--dur-ui) var(--ease);
}
.sg-input::placeholder { color: var(--grey); }
.sg-input:focus-visible { outline: none; transform: translate(var(--nudge), var(--nudge));
                          box-shadow: var(--drop-lg); }
.sg-input[aria-invalid="true"] { background: var(--danger-soft); }
select.sg-input { appearance: none; cursor: pointer; }

/* ─────────── Meter ───────────
   Outlined track, solid ink fill. No gradient, no glow. */
.sg-meter { display: flex; flex-direction: column; gap: 5px; }
.sg-meter__row { display: flex; justify-content: space-between; align-items: baseline;
                 gap: var(--space-1); }
.sg-meter__track { height: 10px; border: var(--stroke-thin); border-radius: var(--radius-pill);
                   background: var(--paper); overflow: hidden; }
.sg-meter__fill { height: 100%; background: var(--ink); display: block;
                  transition: width var(--dur-entrance) var(--ease); }

/* ─────────── Nav ─────────── */
.sg-nav { display: flex; align-items: center; gap: var(--space-3);
          background: var(--white); border: var(--stroke); border-radius: var(--radius-pill);
          padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
          box-shadow: var(--drop-sm); }
.sg-nav__brand { font-family: var(--font-display); font-size: var(--text-lead);
                 letter-spacing: var(--track-heading); margin-right: auto; }
.sg-nav__link { font-size: var(--text-ui); color: var(--ink); text-decoration: none;
                font-weight: 500;
                transition: opacity var(--dur-ui) var(--ease); }
.sg-nav__link:hover { opacity: .55; }
.sg-nav__link[aria-current] { text-decoration: underline;
                              text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Bottom tab bar, for the platform. */
.sg-tabs { display: flex; background: var(--white); border-top: var(--stroke); }
.sg-tabs button { flex: 1 1 0; background: none; border: none; cursor: pointer;
                  padding: var(--space-1) 0 var(--space-2);
                  display: flex; flex-direction: column; align-items: center; gap: 3px;
                  font-family: var(--font-body); font-weight: 600; font-size: 9px;
                  letter-spacing: var(--track-caps); text-transform: uppercase;
                  color: var(--grey); }
.sg-tabs svg { width: 21px; height: 21px; stroke: currentColor; fill: none;
               stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.sg-tabs button[aria-current] { color: var(--ink); }
.sg-tabs button[aria-current] svg { stroke-width: 2.75; }
.sg-tabs button:focus-visible { outline: 3px solid var(--indigo); outline-offset: -3px; }

/* ─────────── Links ─────────── */
.sg-link { color: var(--ink); text-decoration: underline;
           text-decoration-thickness: 2px; text-underline-offset: 3px;
           transition: color var(--dur-ui) var(--ease); }
.sg-link:hover { color: var(--indigo); }

/* ─────────── Motion ───────────
   Expressive motion is not pressure. Loss aversion is — no
   countdowns, no decaying streaks, nothing that shames. */
.sg-pop { animation: sg-pop var(--dur-reward) var(--ease-pop) both; }
@keyframes sg-pop { from { transform: scale(.92); opacity: 0 } to { transform: none; opacity: 1 } }
.sg-rise { animation: sg-rise var(--dur-entrance) var(--ease) both; }
@keyframes sg-rise { from { transform: translateY(var(--space-2)); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .sg-pop, .sg-rise { animation: none; }
  .sg-btn, .sg-block--tap, .sg-input { transition: none; }
}
