/* ----------------------------------------------------------------------------
   Ristra design system — styleguide chrome.

   Two namespaces live here:
     .sg-*  page scaffolding for design.getristra.com (nav, sections, specimen
            frames). Never used by product surfaces.
     .rs-*  reference component implementations documented by the styleguide.
            These are the normative markup/CSS for web surfaces; Svelte and
            SwiftUI components map to them (see platform notes per section).

   Everything consumes tokens.css — this page is the first consumer of the
   system it documents.
   ------------------------------------------------------------------------- */

@font-face {
  font-family: 'Solitreo';
  src: url('assets/fonts/Solitreo-latin.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Jua';
  src: url('assets/fonts/Jua-latin.woff2') format('woff2');
  font-display: swap;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading-base);
}

/* --- Shell: sticky rail + fluid content ----------------------------------- */

.sg { display: grid; grid-template-columns: 264px 1fr; align-items: start; }

.sg-side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--earth-950); color: var(--earth-100);
  padding: var(--space-8) var(--space-6);
}

.sg-side-brand { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-3); }
.sg-side-brand img { width: 44px; height: 44px; }
.sg-side-brand .nm { font-family: var(--font-display); font-size: 26px; color: var(--turquoise-300); }
.sg-side-tagline {
  font-family: var(--font-tagline); font-size: 13px; color: var(--earth-300);
  margin: 0 0 var(--space-8); letter-spacing: 0.01em;
}

.sg-nav-group {
  font-size: 11px; font-weight: var(--weight-bold); text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--earth-500); margin: var(--space-7) 0 var(--space-3);
}
.sg-nav-link {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px;
  border-radius: 7px; border-left: 2px solid transparent;
  color: color-mix(in srgb, var(--earth-100) 72%, transparent);
  text-decoration: none; font-size: var(--text-sm);
}
.sg-nav-link:hover { color: var(--earth-100); background: rgba(255, 238, 214, 0.07); }
.sg-nav-link.is-active {
  background: color-mix(in srgb, var(--turquoise-500) 16%, transparent);
  color: #fff; border-left-color: var(--turquoise-300);
}
.sg-nav-link .n {
  font-family: var(--font-mono); font-size: 10px; min-width: 17px;
  color: color-mix(in srgb, var(--earth-100) 38%, transparent);
}

/* --- Content column -------------------------------------------------------- */

.sg-main { min-width: 0; padding: 0 var(--space-10) var(--space-12); }
.sg-wrap { max-width: 1080px; }

.sg-topbar {
  display: flex; justify-content: flex-end; padding: var(--space-5) 0;
}
.sg-theme-toggle {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font: inherit; font-size: var(--text-sm); color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 6px 14px; cursor: pointer;
}
.sg-theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }

/* --- Hero ------------------------------------------------------------------- */

.sg-hero {
  background:
    radial-gradient(120% 140% at 85% -10%, rgba(10, 156, 129, 0.24) 0%, transparent 55%),
    linear-gradient(150deg, var(--earth-950) 0%, #31251a 100%);
  color: var(--earth-100); border-radius: var(--radius);
  padding: var(--space-11) var(--space-10) var(--space-10);
  margin-bottom: var(--space-9);
}
.sg-hero img.logo { width: min(420px, 72%); display: block; margin-bottom: var(--space-8); }
.sg-hero h1 { font-size: clamp(30px, 4vw, 44px); font-weight: var(--weight-bold); letter-spacing: -0.02em; margin: 0 0 var(--space-4); }
.sg-hero .lead { font-size: var(--text-lg); line-height: var(--leading-lg); color: var(--earth-300); max-width: 62ch; margin: 0 0 var(--space-8); }
.sg-hero-meta { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.sg-hero-meta .m {
  padding: 7px 13px; border-radius: var(--radius-pill); font-size: var(--text-sm);
  background: rgba(255, 238, 214, 0.08); border: 1px solid rgba(255, 238, 214, 0.16);
}

/* --- Sections ---------------------------------------------------------------- */

.sg-section {
  padding: var(--space-10) 0 var(--space-4);
  border-top: 1px solid var(--border);
  scroll-margin-top: 12px;
}
.sg-eyebrow {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--title); margin-bottom: var(--space-3);
}
.sg-h2 { font-size: var(--text-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-bold); letter-spacing: -0.015em; margin: 0 0 var(--space-4); }
.sg-h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin: var(--space-9) 0 var(--space-4); }
.sg-lead { font-size: var(--text-lg); line-height: var(--leading-lg); color: var(--text-muted); max-width: 70ch; margin: 0 0 var(--space-8); }
.sg-note { font-size: var(--text-sm); color: var(--text-muted); max-width: 76ch; }
.sg-note code, .sg-table code, .sg-callout code {
  font-family: var(--font-mono); font-size: 0.92em;
  background: var(--surface-sunken); border-radius: 5px; padding: 1px 5px;
}

.sg-callout {
  border: 1px solid var(--border); border-left: 3px solid var(--title);
  border-radius: var(--radius-sm); background: var(--surface);
  padding: var(--space-5) var(--space-6); margin: var(--space-6) 0;
  font-size: var(--text-sm); color: var(--text-muted); max-width: 86ch;
}
.sg-callout strong { color: var(--text); }

.sg-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-6); margin: var(--space-6) 0; }
.sg-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-6); box-shadow: var(--shadow);
}
.sg-card h4 { margin: 0 0 var(--space-3); font-size: var(--text-base); }
.sg-card p { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }

/* --- Color presentation ------------------------------------------------------- */

.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-5); margin: var(--space-6) 0; }
.sg-swatch {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface); cursor: copy;
}
.sg-swatch .chip { height: 64px; }
.sg-swatch .meta { padding: 8px 10px; }
.sg-swatch .nm { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.sg-swatch .var, .sg-swatch .hex { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.sg-swatch .flag { font-size: 10px; color: var(--status-unavailable); font-weight: var(--weight-semibold); }
.sg-swatch.is-copied { outline: 2px solid var(--title); outline-offset: 1px; }

.sg-ramp { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: var(--space-5); margin: var(--space-3) 0; }
.sg-ramp .nm { font-family: var(--font-mono); font-size: var(--text-sm); }
.sg-ramp .steps { display: grid; grid-template-columns: repeat(12, 1fr); border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.sg-ramp .step { height: 46px; position: relative; cursor: copy; }
.sg-ramp .step.is-anchor::after {
  content: '●'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 8px; color: rgba(255, 255, 255, 0.9); text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}

.sg-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-5); margin: var(--space-6) 0; }
.sg-pair {
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: var(--space-5) var(--space-6); display: flex; justify-content: space-between;
  align-items: center; gap: var(--space-4); font-size: var(--text-sm);
}
.sg-pair .t { font-weight: var(--weight-semibold); }
.sg-pair .vars { font-family: var(--font-mono); font-size: 10px; opacity: 0.75; }
.sg-badge {
  font-family: var(--font-mono); font-size: 10px; padding: 3px 7px;
  border-radius: var(--radius-pill); background: rgba(0, 0, 0, 0.14); white-space: nowrap;
}

/* --- Brand fields (lockup display panels) --------------------------------------- */

.sg-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-6); margin: var(--space-6) 0; }
.sg-field { border-radius: var(--radius); border: 1px solid var(--border); padding: var(--space-9) var(--space-8); display: grid; place-items: center; min-height: 170px; }
.sg-field img { max-width: min(360px, 88%); max-height: 130px; }
.sg-field.on-sand { background: var(--earth-100); }
.sg-field.on-earth { background: var(--earth-950); }
.sg-field.on-white { background: #fff; }
.sg-field-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); text-align: center; margin-top: var(--space-3); }

/* --- Type, spacing, radius, motion specimens ------------------------------------- */

.sg-type-row {
  display: grid; grid-template-columns: 240px 1fr; gap: var(--space-8);
  align-items: baseline; padding: var(--space-5) 0; border-bottom: 1px dashed var(--border);
}
.sg-type-row .cls { font-family: var(--font-mono); font-size: var(--text-sm); }
.sg-type-row .det { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }

.sg-tiles { display: flex; flex-wrap: wrap; gap: var(--space-6); margin: var(--space-6) 0; }
.sg-tile {
  width: 150px; background: var(--surface); border: 1px solid var(--border);
  padding: var(--space-6); text-align: center; font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted);
}

.sg-space-row { display: grid; grid-template-columns: 110px 1fr; gap: var(--space-5); align-items: center; padding: 4px 0; }
.sg-space-row .nm { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.sg-space-row .bar { height: 14px; background: var(--title); border-radius: 3px; }

.sg-motion-chip {
  display: inline-block; width: 56px; height: 56px; border-radius: var(--radius-sm);
  background: var(--accent); cursor: pointer; margin-right: var(--space-6);
}
.sg-motion-chip.is-playing { transform: translateX(120px); }
.sg-motion-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) 0; }
.sg-motion-row .det { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); min-width: 300px; }

/* --- Tables ------------------------------------------------------------------------ */

.sg-table { width: 100%; border-collapse: collapse; margin: var(--space-6) 0; font-size: var(--text-sm); }
.sg-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); padding: 8px 12px; border-bottom: 2px solid var(--border);
}
.sg-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sg-table td.mono { font-family: var(--font-mono); font-size: 12px; }
.sg-table-scroll { overflow-x: auto; }

/* --- Specimen stage ------------------------------------------------------------------ */

.sg-spec {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-8); margin: var(--space-6) 0; box-shadow: var(--shadow);
}
.sg-spec + .sg-meta { margin-top: calc(-1 * var(--space-4)); }
.sg-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin: var(--space-3) 0 var(--space-6); }
.sg-spec-row { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: center; }
.sg-spec.on-bg { background: var(--bg); }

/* ==========================================================================
   .rs-* — reference components (the normative web implementations)
   ========================================================================== */

/* Buttons */
.rs-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  font: inherit; font-size: var(--text-base); font-weight: var(--weight-semibold);
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: var(--radius-pill); padding: 12px 22px;
  cursor: pointer; transition: background var(--dur-fast) var(--ease-out);
}
.rs-btn:hover { background: var(--accent-strong); }
.rs-btn:disabled { opacity: 0.45; cursor: default; }
.rs-btn--secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.rs-btn--secondary:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.rs-btn--quiet { background: transparent; color: var(--link); }
.rs-btn--quiet:hover { background: var(--surface-sunken); }
.rs-btn--sm { font-size: var(--text-sm); padding: 8px 15px; }

/* Inputs */
.rs-field { display: grid; gap: var(--space-3); max-width: 340px; }
.rs-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-muted); }
.rs-input {
  font: inherit; font-size: 16px; /* prevents iOS zoom */
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; width: 100%;
}
.rs-input::placeholder { color: var(--text-faint); }
.rs-input:focus { outline: none; border-color: var(--title); }
.rs-help { font-size: var(--text-xs); color: var(--text-muted); }

/* Pills & chips */
.rs-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  background: var(--pill-bg); color: var(--text-muted);
  border-radius: var(--radius-pill); padding: 5px 12px;
}
.rs-pill--qty { font-family: var(--font-mono); font-size: 12.5px; }
.rs-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.rs-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.rs-chip--incart { color: var(--status-incart); }
.rs-chip--bought { color: var(--status-bought); }
.rs-chip--unavailable { color: var(--status-unavailable); }

/* Segmented control (theme picker) */
.rs-seg { display: inline-flex; background: var(--surface-sunken); border-radius: var(--radius-pill); padding: 3px; }
.rs-seg button {
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  border: none; background: transparent; color: var(--text-muted);
  border-radius: var(--radius-pill); padding: 7px 16px; cursor: pointer;
}
.rs-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* List item row (flagship) */
.rs-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.rs-item { display: flex; align-items: center; gap: var(--space-5); padding: 13px var(--space-6); border-bottom: 1px solid var(--border); }
.rs-item:last-child { border-bottom: none; }
.rs-check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center;
  color: transparent; font-size: 14px; cursor: pointer; background: transparent;
  transition: all var(--dur-fast) var(--ease-out);
}
.rs-item .body { flex: 1; min-width: 0; }
.rs-item .name { font-weight: var(--weight-medium); }
.rs-item .sub { font-size: var(--text-xs); color: var(--text-muted); }
.rs-item--incart .rs-check { border-color: var(--status-incart); background: var(--status-incart); color: #fff; }
.rs-item--incart .name { color: var(--status-incart); }
.rs-item--bought .rs-check { border-color: var(--status-bought); background: var(--status-bought); color: var(--surface); }
.rs-item--bought .name { color: var(--text-faint); text-decoration: line-through; }
.rs-item--unavailable .rs-check { border-color: var(--status-unavailable); color: var(--status-unavailable); }
.rs-item--unavailable .name { color: var(--status-unavailable); }
.rs-item--unavailable .sub { color: var(--status-unavailable); }

/* Department section header */
.rs-dept {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-5) var(--space-6) var(--space-3);
  font-size: 12px; font-weight: var(--weight-bold); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); background: var(--bg);
}
.rs-dept .count { font-family: var(--font-mono); font-weight: var(--weight-regular); color: var(--text-faint); }

/* Banners */
.rs-banner {
  display: flex; align-items: center; gap: var(--space-4);
  border-radius: var(--radius-sm); padding: 11px var(--space-6); font-size: var(--text-sm);
}
.rs-banner--trip { background: var(--trip-wash); border: 1px solid var(--trip-border); color: var(--trip-text); }
.rs-banner--trip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--trip-dot); animation: rs-pulse 1.6s var(--ease-in-out) infinite; }
.rs-banner--offline { background: var(--surface-sunken); border: 1px solid var(--border); color: var(--text-muted); }

@keyframes rs-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Cards & sheets */
.rs-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-6); box-shadow: var(--shadow); }
.rs-sheet {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; padding: var(--space-6);
  box-shadow: 0 -8px 30px rgba(35, 26, 17, 0.14); max-width: 380px;
}
.rs-sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto var(--space-5); }

/* Mini app shell (pattern specimen) */
.rs-shell {
  width: 320px; border: 1px solid var(--border); border-radius: 22px; overflow: hidden;
  background: var(--bg); box-shadow: var(--shadow);
}
.rs-shell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.rs-shell-head .t { font-weight: var(--weight-bold); font-size: var(--text-lg); }
.rs-shell-compose { display: flex; gap: var(--space-3); padding: 12px 14px; background: var(--surface); border-top: 1px solid var(--border); }
.rs-shell-compose .rs-input { padding: 9px 12px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rs-banner--trip .dot { animation: none; }
}

/* --- Responsive --------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .sg { display: block; }
  .sg-side { position: static; height: auto; padding: var(--space-6); }
  .sg-side nav { display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .sg-nav-group { width: 100%; margin: var(--space-4) 0 var(--space-2); }
  .sg-main { padding: 0 var(--space-6) var(--space-10); }
  .sg-hero { padding: var(--space-8) var(--space-6); }
  .sg-type-row { grid-template-columns: 1fr; gap: var(--space-2); }
}
