/* ==========================================================================
   Affiliate Agent Kit — Site Template Stylesheet (SQ-022 design system)
   ------------------------------------------------------------------------
   The agent swaps ONLY the 6 palette tokens in :root per intake —
   --paper, --ink, --ink-soft, --accent, --accent-ink, --surface.
   Every component below reads from these tokens. No raw hex or bare rem
   sizes live outside :root.
   ------------------------------------------------------------------------
   Palette A (Coffee, default for this template):
     --paper      #F7F1E8   page background
     --ink        #2E231B   primary text
     --ink-soft   #5E5044   secondary text, meta, captions
     --accent     #A84A22   links, buttons, tags, rules
     --accent-ink #FDF8F2   text ON accent
     --surface    #FFFFFF   cards, raised panels
   Palette B (Trailhead) is documented in template-spec.md §8 and is the
   set of tokens the agent writes into a Trailhead demo's :root.
   ========================================================================= */

:root {
  /* --- Core palette (6 tokens — the ONLY ones the agent swaps) ---------- */
  --paper:      #fbf6ea;
  --ink:        #18392b;
  --ink-soft:   #496056;
  --accent:     #b8662b;
  --accent-ink: #ffffff;
  --surface:    #ffffff;

  /* --- Derived tokens (computed; do not hardcode) ----------------------- */
  --rule:        color-mix(in srgb, var(--ink) 15%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--paper));

  /* --- Typography stack (system, no webfonts) --------------------------- */
  --font-sans:  system-ui, -apple-system, "Segoe UI", Roboto,
                "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  /* --- Type ladder (§2) -------------------------------------------------- */
  --text-h1:    2rem;       /* 32px */
  --text-h2:    1.5rem;     /* 24px */
  --text-h3:    1.25rem;    /* 20px */
  --text-body:  1rem;       /* 16px */
  --text-lede:  1.125rem;   /* 18px */
  --text-small: 0.875rem;   /* 14px */
  --text-meta:  0.8125rem;  /* 13px */

  --lh-tight:  1.15;
  --lh-normal: 1.5;
  --lh-loose:  1.6;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* --- Spacing scale (§5) ----------------------------------------------- */
  --space-1: 0.25rem;  /* 4px  */
  --space-2: 0.5rem;   /* 8px  */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2.5rem;   /* 40px */
  --space-7: 4rem;     /* 64px */

  /* --- Radius scale (§5) ------------------------------------------------ */
  --radius-sm: 2px;   /* pills, tags, small chips */
  --radius-md: 4px;   /* cards, buttons, disclosure blocks, figures */
  --radius-lg: 8px;   /* large panels only */

  /* --- Shadows: near-none by design (print-like) ------------------------ */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* =========================================================================
   Reset / base
   ========================================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--lh-loose);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg { max-width: 100%; height: auto; display: block; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-6) 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", monospace;
  font-size: 0.92em;
}
code {
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}
pre {
  background: var(--accent-soft);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--lh-normal);
}

/* =========================================================================
   Layout: container + header / footer shells
   ========================================================================= */
.container {
  max-width: 48rem;       /* 768px — prose */
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.container.container--wide {
  max-width: 64rem;       /* 1024px — card grids */
}

site-header,
site-footer { display: block; }

/* =========================================================================
   Sticky nav (§4a)
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-bottom: 1px solid var(--rule);
  padding: var(--space-4) 0;
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.site-title {
  display: inline-block;
  font-size: 1.0625rem;
  font-weight: var(--fw-bold);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.site-title:hover { text-decoration: underline; }
.site-tagline {
  display: block;
  font-size: var(--text-small);
  font-weight: var(--fw-regular);
  color: var(--ink-soft);
  margin-top: 2px;
  letter-spacing: 0;
}
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  margin-left: var(--space-4);
  font-size: var(--text-small);
  font-weight: var(--fw-medium);
}
.site-nav a:first-child { margin-left: 0; }
.site-nav a:hover,
.site-nav a:focus { color: var(--accent); }
.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* =========================================================================
   Main + section rhythm
   ========================================================================= */
main { padding: var(--space-6) 0 var(--space-7); }
main > .container > section { margin: 0 0 var(--space-6); }

/* =========================================================================
   Typography (§2 rule table)
   ========================================================================= */
h1, h2, h3, h4 {
  color: var(--ink);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--text-h1);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  margin-top: var(--space-2);
  max-width: 18ch;
}
h2 {
  font-size: var(--text-h2);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}
h3 {
  font-size: var(--text-h3);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-normal);
  margin-bottom: var(--space-2);
}
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.4em; }
li { margin-bottom: var(--space-1); }

.lede {
  font-size: var(--text-lede);
  line-height: var(--lh-normal);
  color: var(--ink);
  font-weight: var(--fw-regular);
  margin-bottom: var(--space-4);
}
.small,
small {
  font-size: var(--text-small);
  line-height: var(--lh-normal);
  color: var(--ink-soft);
}
.meta {
  font-size: var(--text-meta);
  line-height: var(--lh-normal);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-3);
}
.meta a { color: var(--ink-soft); }

/* =========================================================================
   Hero with eyebrow (§4b)
   ========================================================================= */
.hero {
  padding: var(--space-5) 0 var(--space-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-6);
}
.eyebrow {
  display: inline-block;
  font-size: var(--text-small);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}
.hero h1 { margin-top: 0; }
.hero-media {
  margin: var(--space-5) 0 0;
  max-width: 70rem;
}
.hero-media img,
.context-media img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}
.hero-media figcaption,
.context-media figcaption {
  color: var(--ink-soft);
  font-size: var(--text-small);
  margin-top: var(--space-2);
}
.context-media {
  margin: var(--space-5) 0;
  max-width: 36rem;
}

/* =========================================================================
   Buttons / CTAs
   ========================================================================= */
.btn,
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  font-size: var(--text-small);
  letter-spacing: 0.01em;
  line-height: 1.2;
  border: 1px solid var(--accent);
}
.btn:hover,
.btn-primary:hover {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 88%, var(--ink));
}
.btn--ghost {
  background: transparent;
  color: var(--accent);
}
.btn--ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* =========================================================================
   Cards with featured hierarchy (§4c)
   ========================================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
  margin: var(--space-5) 0 var(--space-3);
  padding: 0;
  list-style: none;
}
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.card h3 {
  margin: 0;
  font-size: var(--text-h3);
  line-height: var(--lh-normal);
}
.card p { margin: 0; color: var(--ink-soft); }
.card a.card-link {
  color: var(--ink);
  text-decoration: none;
}
.card a.card-link:hover h3 { color: var(--accent); }
.card-media {
  width: calc(100% + 2 * var(--space-5));
  height: 11.5rem;
  margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) 0;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
  border-bottom: 1px solid var(--rule);
}
.card--featured .card-media {
  width: calc(100% + 2 * (var(--space-5) - 1px));
  margin: calc(-1 * (var(--space-5) - 1px)) calc(-1 * (var(--space-5) - 1px)) 0;
}
.card .card-link-arrow {
  margin-top: auto;
  font-size: var(--text-small);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  text-decoration: none;
}
.card .card-link-arrow::after { content: " \2192"; }

/* Featured (top-pick) card — hierarchy by border + tag, never by size */
.card--featured {
  border-color: var(--accent);
  border-width: 2px;
  padding: calc(var(--space-5) - 1px);
}
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-small);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
}

/* =========================================================================
   Blockquote / verdict (§4d)
   ========================================================================= */
blockquote,
.blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--ink);
  font-size: var(--text-lede);
  line-height: var(--lh-normal);
}
blockquote p { margin: 0; }
blockquote p + p { margin-top: var(--space-3); }

/* =========================================================================
   Disclosure blocks (§7 R2/R3)
   ========================================================================= */
.disclosure {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  color: var(--ink);
  font-size: var(--text-small);
  line-height: var(--lh-normal);
}
.disclosure strong { color: var(--ink); }
.disclosure--inline {
  /* sits IMMEDIATELY before the first {{YOUR_LINK_n}} slot. R2. */
}
.disclosure--page {
  background: var(--surface);
  border-color: var(--rule);
  border-left-width: 4px;
  border-left-color: var(--accent);
}

/* =========================================================================
   Recommendation cards (articles)
   ========================================================================= */
.recommendation {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: var(--space-5) 0;
}
.recommendation h3 { margin: 0 0 var(--space-2); }
.recommendation .why { color: var(--ink-soft); font-size: var(--text-small); }
.recommendation .price { color: var(--ink); font-weight: var(--fw-semibold); }
.recommendation .spec { color: var(--ink-soft); font-size: var(--text-small); }

.affiliate-link {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  font-size: var(--text-small);
  margin-top: var(--space-3);
  border: 1px solid var(--accent);
}
.affiliate-link:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  color: var(--accent-ink);
}

/* =========================================================================
   Article header + body rhythm (§3b)
   ========================================================================= */
.article-body { max-width: 42rem; }
.article-body > * + * { margin-top: var(--space-4); }
.article-body h2 + p,
.article-body h3 + p { margin-top: var(--space-2); }

.breadcrumbs {
  font-size: var(--text-meta);
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
}
.breadcrumbs a { color: var(--ink-soft); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current="page"] { color: var(--ink); }

.article-meta {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: var(--text-small);
}
.article-meta p { margin-bottom: var(--space-2); }
.article-meta a { color: var(--ink-soft); }

/* =========================================================================
   Figure + figcaption system (§6)
   Empty-degrade: a <figure> with no surviving content hides itself, so
   a demo ships fine with zero images present.
   ========================================================================= */
.article-fig {
  margin: var(--space-5) 0;
}
.article-fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
}
.article-fig figcaption {
  font-size: var(--text-small);
  color: var(--ink-soft);
  margin-top: var(--space-2);
  line-height: var(--lh-normal);
}
.article-fig--hero { max-width: 62rem; }
.setup-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.setup-figures .article-fig { margin: 0; }
@media (max-width: 700px) { .setup-figures { grid-template-columns: 1fr; } }
figure:empty { display: none; }
.workflow-figure {
  margin: 0 0 var(--space-5);
}
.workflow-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
}

/* =========================================================================
   Tables (policy / disclosure program tables)
   ========================================================================= */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  font-size: var(--text-small);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  background: var(--accent-soft);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
tbody tr:last-child td { border-bottom: 0; }

/* =========================================================================
   Contact block (about)
   ========================================================================= */
.contact-block {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: var(--space-5) 0;
}
.contact-block dl { margin: 0; }
.contact-block dt {
  font-weight: var(--fw-semibold);
  margin-top: var(--space-3);
}
.contact-block dt:first-child { margin-top: 0; }
.contact-block dd {
  margin: 2px 0 0 0;
  color: var(--ink-soft);
}

/* =========================================================================
   Marker styling (visible {{MARKERS}} in published demos)
   ========================================================================= */
.marker {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

/* =========================================================================
   Demo notice (lives on demo pages only; documented in §7 R4)
   ========================================================================= */
.demo-notice {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
  font-size: var(--text-small);
  color: var(--ink);
  line-height: var(--lh-normal);
}
.demo-notice strong { color: var(--ink); }
.demo-notice a { color: var(--accent); }

/* =========================================================================
   Footer (3-tier per §4f)
   ========================================================================= */
.site-footer {
  margin-top: var(--space-7);
  border-top: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 70%, var(--surface));
  padding: var(--space-5) 0 var(--space-6);
  font-size: var(--text-small);
  color: var(--ink-soft);
}
.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.site-footer .footer-notice { font-size: var(--text-small); color: var(--ink-soft); }
.site-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-small);
}
.site-footer .footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
}
.site-footer .footer-links a:hover { color: var(--accent); }
.site-footer .footer-copyright {
  font-size: var(--text-small);
  color: var(--ink-soft);
}
.site-footer .footer-copyright a { color: var(--ink); }

/* =========================================================================
   Small-screen tweaks
   ========================================================================= */
@media (max-width: 480px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .site-nav a {
    margin-left: 0;
    margin-right: var(--space-4);
  }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
}

/* =========================================================================
   Print (so a buyer can read offline)
   ========================================================================= */
@media print {
  .site-header,
  .site-footer { display: none; }
  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
  a { color: #000; text-decoration: underline; }
  .disclosure,
  .recommendation,
  .card {
    border-color: #999;
    background: #fff;
    box-shadow: none;
  }
}
