/**
 * TERRARIUM DESIGN TOKENS v1.0
 * Where Pragmatic Capability Meets Mythic Beauty
 *
 * Three-Layer Visual System:
 * - Layer 1: Pragmatic Capability (entry, orientation, measurement)
 * - Layer 2: Aspirational Homestead (heart, beauty, desire)
 * - Layer 3: Mythic Depth (soul, meaning, movement)
 */

:root {
  /* ============================================
     LAYER 1: PRAGMATIC CAPABILITY COLORS
     Purpose: Trust, clarity, progress tracking
     ============================================ */
  --color-sky-blue: #4A90E2;
  --color-grass-green: #7CB342;
  --color-slate-grey: #546E7A;
  --color-soft-white: #F7F5F0;
  --color-graphite: #37474F;

  /* ============================================
     LAYER 2: ASPIRATIONAL HOMESTEAD COLORS
     Purpose: Warmth, community, abundance
     ============================================ */
  --color-sage-green: #A8B89A;
  --color-mustard-gold: #D9A441;
  --color-terracotta-rust: #C2703D;
  --color-moss-grey: #8C8F78;
  --color-ceramic-cream: #E8E2D5;
  --color-wheat-linen: #D6CBB8;
  --color-honey-amber: #E0A85B;

  /* ============================================
     LAYER 3: MYTHIC DEPTH COLORS
     Purpose: Archetypal resonance, sacred patterns
     ============================================ */
  --color-deep-cedar: #1B3828;
  --color-matte-charcoal: #3D3C37;
  --color-ember-gold: #E0A85B;
  --color-moss-shadow: #2C3E2E;
  --color-moonstone: #D4D8DC;

  /* ============================================
     SEMANTIC COLOR ASSIGNMENTS
     ============================================ */
  --color-primary: var(--color-sage-green);
  --color-secondary: var(--color-mustard-gold);
  --color-accent: var(--color-honey-amber);

  --color-success: var(--color-grass-green);
  --color-info: var(--color-sky-blue);
  --color-warning: var(--color-mustard-gold);
  --color-error: var(--color-terracotta-rust);

  --color-text-primary: var(--color-graphite);
  --color-text-secondary: var(--color-slate-grey);
  --color-text-light: var(--color-moss-grey);
  --color-text-inverse: var(--color-soft-white);

  --color-background-primary: #FFFFFF;
  --color-background-secondary: var(--color-soft-white);
  --color-background-tertiary: var(--color-ceramic-cream);
  --color-background-dark: var(--color-deep-cedar);

  --color-border-light: #E5E5E5;
  --color-border-medium: var(--color-moss-grey);
  --color-border-dark: var(--color-slate-grey);

  /* ============================================
     TYPOGRAPHY - FONT FAMILIES
     ============================================ */
  /* Primary Sans (Pragmatic Layer) */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Display Serif (Aspirational Layer) */
  --font-serif: 'Cormorant Garamond', Georgia, serif;

  /* Body Serif (Storytelling) — Google Fonts ships this family as
     'Source Serif 4' now; keep the old name as a fallback alias. */
  --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;

  /* Monospace (Data & Metrics) */
  --font-mono: 'Roboto Mono', 'Courier New', monospace;

  /* Mythic Display (Archetypal Layer) */
  --font-mythic: 'Cinzel', 'Cormorant Garamond', serif;

  /* ============================================
     TYPOGRAPHY - TYPE SCALE
     ============================================ */
  /* Headlines & Heroes */
  --text-hero: clamp(2.5rem, 5vw, 3.5rem);      /* 40-56px */
  --text-h1: clamp(2rem, 4vw, 3rem);            /* 32-48px */
  --text-h2: clamp(1.5rem, 3vw, 2.25rem);       /* 24-36px */
  --text-h3: clamp(1.25rem, 2.5vw, 1.75rem);    /* 20-28px */
  --text-h4: clamp(1.125rem, 2vw, 1.375rem);    /* 18-22px */

  /* Body & Interface */
  --text-body-lg: 1.25rem;    /* 20px */
  --text-body: 1rem;          /* 16px */
  --text-small: 0.875rem;     /* 14px */
  --text-xs: 0.75rem;         /* 12px */

  /* Special */
  --text-metric: 1.5rem;      /* 24px */
  --text-cta: 1.125rem;       /* 18px */

  /* ============================================
     TYPOGRAPHY - LINE HEIGHTS
     ============================================ */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;
  --line-height-loose: 2;

  /* ============================================
     TYPOGRAPHY - FONT WEIGHTS
     ============================================ */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ============================================
     SPACING SCALE
     ============================================ */
  --space-xs: 0.25rem;    /* 4px */
  --space-sm: 0.5rem;     /* 8px */
  --space-md: 1rem;       /* 16px */
  --space-lg: 1.5rem;     /* 24px */
  --space-xl: 2rem;       /* 32px */
  --space-2xl: 3rem;      /* 48px */
  --space-3xl: 4rem;      /* 64px */
  --space-4xl: 6rem;      /* 96px */
  --space-5xl: 8rem;      /* 128px */

  /* ============================================
     LAYOUT - RESPONSIVE BREAKPOINTS
     ============================================ */
  --breakpoint-mobile: 320px;
  --breakpoint-mobile-lg: 428px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1024px;
  --breakpoint-desktop-lg: 1440px;
  --breakpoint-desktop-xl: 1920px;

  /* ============================================
     LAYOUT - CONTAINERS
     ============================================ */
  --container-sm: 40rem;      /* 640px - Forms, narrow content */
  --container-md: 48rem;      /* 768px - Standard content */
  --container-lg: 64rem;      /* 1024px - Wide content */
  --container-xl: 80rem;      /* 1280px - Full-width sections */
  --container-max: 90rem;     /* 1440px - Maximum width */

  /* ============================================
     LAYOUT - GRID
     ============================================ */
  --grid-columns: 12;
  --grid-gap: 1.5rem;         /* 24px */
  --grid-gap-mobile: 1rem;    /* 16px */

  /* ============================================
     BORDERS & RADIUS
     ============================================ */
  --border-width-thin: 1px;
  --border-width-medium: 2px;
  --border-width-thick: 4px;

  --radius-sm: 0.25rem;       /* 4px */
  --radius-md: 0.5rem;        /* 8px */
  --radius-lg: 0.75rem;       /* 12px */
  --radius-xl: 1rem;          /* 16px */
  --radius-full: 9999px;      /* Circular */

  /* ============================================
     SHADOWS
     ============================================ */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
               0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
               0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
               0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* ============================================
     TRANSITIONS
     ============================================ */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ============================================
     Z-INDEX SCALE
     ============================================ */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;

  /* ============================================
     COMPONENT VARIABLES - BUTTONS
     ============================================ */
  --button-padding-x: var(--space-lg);
  --button-padding-y: var(--space-md);
  --button-font-size: var(--text-cta);
  --button-font-weight: var(--font-weight-semibold);
  --button-border-radius: var(--radius-md);
  --button-transition: var(--transition-base);

  /* ============================================
     COMPONENT VARIABLES - CARDS
     ============================================ */
  --card-padding: var(--space-xl);
  --card-border-radius: var(--radius-lg);
  --card-background: var(--color-background-primary);
  --card-border: var(--border-width-thin) solid var(--color-border-light);
  --card-shadow: var(--shadow-md);
  --card-shadow-hover: var(--shadow-lg);

  /* ============================================
     COMPONENT VARIABLES - FORMS
     ============================================ */
  --input-padding-x: var(--space-md);
  --input-padding-y: var(--space-sm);
  --input-font-size: var(--text-body);
  --input-border-radius: var(--radius-md);
  --input-border: var(--border-width-medium) solid var(--color-border-medium);
  --input-border-focus: var(--border-width-medium) solid var(--color-sky-blue);
  --input-background: var(--color-background-primary);
  --input-background-disabled: var(--color-background-secondary);

  /* ============================================
     ACCESSIBILITY - FOCUS STATES
     ============================================ */
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;
  --focus-ring-color: var(--color-sky-blue);

  /* ============================================
     LAYER 4: THE NIGHT SKY (Warm Bioluminescence)
     The constellation's world — where the mycelium is visible.
     Deep indigo-violet night (never true black); ember/firefly
     amber-golds for trust and certainty; brightest whites reserved
     for rare peak states. No cyan, no electric hologram — this is
     a neighborhood at night, not a dashboard.
     ============================================ */
  --night-deep: #171232;        /* sky at zenith */
  --night-soft: #241d4a;        /* sky at horizon */
  --night-edge: #3a3266;        /* borders, dividers on night */
  --night-panel: #1d1740;       /* cards and panels on night */
  --ember-high: #ffc76a;        /* brightest belief */
  --ember-core: #e8a94e;        /* warm accent, buttons, links */
  --ember-deep: #b97a2e;        /* pressed/active ember */
  --mist: #8d84c0;              /* the cloud of unknowing */
  --moon-text: #cfc8ef;         /* body text on night */
  --parchment: #e8dcc0;         /* headings on night */
  --bond-warm: #f0b45a;         /* living connection */
  --bond-cold: #6c6494;         /* strained connection: quiet, never alarming */

  /* The rest of the rendered brand kit (docs/brand/identity.md, branch
     claude/phase-2-umwelt-spike-be6n0b). Values copied, not approximated. */
  --ember-mid: #e8a94e;         /* kit "amber mid"; already referenced below */
  --ember-low: #a8793e;         /* a faint capability */
  --white-hot: #fff8ec;         /* the lit centre only — keep it rare */
  --ink: #2f2758;               /* the mark and wordmark on light grounds */
  --ink-soft: #3d3470;          /* second ink: the far leaf, the bud */

  /* Wordmark: the device's own face, 600, tracked, all caps. */
  --font-system: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --wordmark-weight: var(--font-weight-semibold);
  --wordmark-tracking: 0.06em;

  --sky-gradient: linear-gradient(180deg, var(--night-deep) 0%, var(--night-soft) 100%);

  /* ============================================
     CHROME: header, footer, cookie notice
     The layout reads only these. Light pages get ink on cream (amber on
     cream is too low-contrast — identity.md); .body--night re-points them
     at the sky. The footer is always night: the street at dusk.
     ============================================ */
  --chrome-bg: var(--color-soft-white);
  --chrome-border: var(--color-ceramic-cream);
  --chrome-wordmark: var(--ink);
  --chrome-text: var(--ink);
  --chrome-muted: var(--ink-soft);
  --chrome-active: var(--ink);
  --chrome-accent: var(--ember-core);
  --chrome-hover-bg: var(--color-ceramic-cream);

  /* The seedling mark, part by part (mark-ink.svg / mark.svg). */
  --mark-stem: var(--ink);
  --mark-leaf-near: var(--ink);
  --mark-leaf-far: var(--ink-soft);
  --mark-node: var(--ink-soft);
  --mark-core: var(--parchment);

  --footer-bg: var(--sky-gradient);
  --footer-heading: var(--parchment);
  --footer-text: var(--moon-text);
  --footer-muted: var(--mist);
  --footer-link-hover: var(--ember-high);
  --footer-rule: var(--night-edge);
  --footer-column-min: 15.625rem;   /* 250px */

  /* ============================================
     PRODUCT PAGES: the list (/products) and detail (/product/:slug)
     Daylight pages, so the chrome rule holds: ink carries text and
     actions, amber is warmth (badges, hover rules) never body text, and
     sage is a ground tint only — white on sage is 2.1:1. Contrast on
     white: ink 13.5, graphite 9.6, slate (muted) 5.4, positive 6.4.
     Muted text stays off the cream ground (slate on cream is 4.2).
     ============================================ */
  --product-ground: var(--color-background-primary);
  --product-ground-soft: var(--color-soft-white);
  --product-ground-warm: var(--color-ceramic-cream);
  --product-tint: color-mix(in srgb, var(--color-sage-green) 18%, var(--product-ground));
  --product-rule: var(--color-border-light);
  --product-rule-strong: var(--color-border-medium);

  --product-heading: var(--ink);
  --product-text: var(--color-text-primary);
  --product-muted: var(--color-text-secondary);
  --product-price: var(--ink);
  --product-link: var(--ink);

  --product-action-bg: var(--ink);
  --product-action-text: var(--white-hot);
  --product-action-hover: var(--ink-soft);

  --product-accent: var(--ember-core);         /* hover rules, badge grounds */
  --product-accent-text: var(--night-deep);    /* on amber: 8.7 */
  --product-badge-bg: var(--ink);
  --product-badge-text: var(--parchment);

  --product-positive: color-mix(in srgb, var(--color-grass-green) 40%, var(--color-deep-cedar));
  --product-positive-tint: color-mix(in srgb, var(--color-grass-green) 12%, var(--product-ground));

  --product-overlay: color-mix(in srgb, var(--white-hot) 92%, transparent);

  /* Emoji and glyph sizes — icons, never running text. */
  --icon-sm: 1.25rem;
  --icon-md: 1.5rem;
  --icon-lg: 2rem;
  --icon-xl: 3rem;
  --icon-2xl: 4rem;
}

/* The night-sky scope: any section that lives under the constellation.
   Doubled selector so it outranks single-class section backgrounds
   (e.g. .blog-hero) regardless of stylesheet load order. */
.night-sky,
.night-sky.night-sky {
  background: var(--sky-gradient);
  color: var(--moon-text);
}
.night-sky h1, .night-sky h2, .night-sky h3, .night-sky h4 {
  color: var(--parchment);
  font-family: var(--font-serif);
  font-weight: var(--font-weight-regular);
}
.night-sky a { color: var(--ember-core); }
.night-sky a:hover { color: var(--ember-high); }
.night-sky .muted { color: var(--mist); }

/* The Mycelium's Voice: stream tabs + cards under the night hero. */
.blog-streams {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.4rem;
}
.stream-tab,
.night-sky a.stream-tab {
  display: inline-block;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--night-edge);
  border-radius: 999px;
  background: var(--night-soft);
  color: var(--moon-text);
  font-size: 0.85rem;
  text-decoration: none;
}
.stream-tab:hover,
.night-sky a.stream-tab:hover {
  border-color: var(--ember-mid);
  color: var(--ember-high);
}
.stream-tab.active,
.night-sky a.stream-tab.active {
  background: var(--night-edge);
  border-color: var(--ember-mid);
  color: var(--parchment);
}
.blog-stream-blurb {
  color: var(--color-text-secondary);
  font-style: italic;
  margin-bottom: 1.2rem;
}
.domain-badge--axis { opacity: 0.85; text-decoration: none; }
.post-header__sky { margin-top: 1.5rem; }
.blog-cta.night-sky .cta-box h2 { color: var(--parchment); }
.blog-cta.night-sky .cta-box p { color: var(--moon-text); }

/* Recommendation cards: the engine's honest sentence + component chips. */
.match-reason {
  display: block;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--color-text-secondary);
  margin: 0.35rem 0;
}
.recommendation-meta--components {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.component-chip {
  font-size: 0.72rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border, #d8d0c0);
  color: var(--color-text-secondary);
  background: transparent;
}
.component-chip--threat { border-color: var(--ember-mid); color: var(--ember-mid); }

/* Night pages (body--night): chrome joins the sky instead of floating
   cream above it — store, blog, and constellation read as one world.
   Only tokens move here; main.css keeps one set of chrome rules. */
.body--night {
  background: var(--night-deep);
  --chrome-bg: var(--night-deep);
  --chrome-border: var(--night-edge);
  --chrome-wordmark: var(--ember-high);
  --chrome-text: var(--moon-text);
  --chrome-muted: var(--mist);
  --chrome-active: var(--ember-high);
  --chrome-hover-bg: var(--night-soft);
  --mark-stem: var(--ember-mid);
  --mark-leaf-near: var(--bond-warm);
  --mark-leaf-far: var(--ember-high);
  --mark-node: var(--ember-high);
  --mark-core: var(--white-hot);
}
.body--night .site-main { background: var(--night-deep); }

/* ============================================
   LAYER-SPECIFIC COMPONENT CLASSES
   ============================================ */

/* Layer 1: Pragmatic Capability */
.layer-1-text {
  color: var(--color-graphite);
  font-family: var(--font-sans);
}

.layer-1-heading {
  font-family: var(--font-sans);
  font-weight: var(--font-weight-bold);
  color: var(--color-graphite);
}

.layer-1-metric {
  font-family: var(--font-mono);
  font-size: var(--text-metric);
  font-weight: var(--font-weight-medium);
  color: var(--color-sky-blue);
}

/* Layer 2: Aspirational Homestead */
.layer-2-text {
  color: var(--color-text-primary);
  font-family: var(--font-body);
  line-height: var(--line-height-relaxed);
}

.layer-2-heading {
  font-family: var(--font-serif);
  font-weight: var(--font-weight-regular);
  color: var(--color-deep-cedar);
}

/* Layer 3: Mythic Depth */
.layer-3-text {
  color: var(--color-deep-cedar);
  font-family: var(--font-serif);
  font-style: italic;
  line-height: var(--line-height-relaxed);
}

.layer-3-heading {
  font-family: var(--font-mythic);
  font-weight: var(--font-weight-regular);
  letter-spacing: 0.05em;
  color: var(--color-deep-cedar);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  :root {
    --color-text-primary: #000000;
    --color-background-primary: #FFFFFF;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-base: 0ms;
    --transition-slow: 0ms;
  }
}

/* ============================================
   DARK MODE SUPPORT (Future Enhancement)
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* Placeholder for future dark mode tokens */
}

/* ============ The ghost layer (N) ============ */
.ghost-row { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 0.8rem 0; }
.ghost-card {
  flex: 1 1 16rem;
  background: transparent;
  border: 1px dashed var(--night-edge);
  border-radius: var(--radius-lg, 12px);
  padding: 0.8rem 1rem;
  opacity: 0.75;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ghost-card:hover { opacity: 1; }
.ghost-card__text { color: var(--color-text-secondary, var(--mist)); font-size: 0.9rem; line-height: 1.55; font-style: italic; margin: 0; }
.ghost-card__actions { display: flex; align-items: center; gap: 0.5rem; }
.ghost-card__dismiss {
  background: none; border: none; color: var(--color-text-secondary, var(--mist));
  font-size: 1.1rem; cursor: pointer; padding: 0 0.4rem; line-height: 1;
}
.ghost-card__dismiss:hover { color: var(--parchment); }

/* ── Price observation age ──────────────────────────────────────────────
   Catalog prices are dated observations, not a live feed. The date renders
   beside every price, and how faded it is says how much to trust it: a
   seven-month-old number should not look as confident as yesterday's. */
.price-seen,
.product-price__seen {
  font-size: 0.82em;
  font-weight: 400;
  color: var(--color-text-light);
  white-space: nowrap;
}

.price-seen.is-fresh,
.product-price__seen.is-fresh {
  color: var(--color-text-secondary);
}

.price-seen.is-stale,
.product-price__seen.is-stale {
  color: var(--color-text-light);
  font-style: italic;
}

.night-sky .price-seen,
.night-sky .product-price__seen {
  color: var(--mist);
}
