/* Stormfors Knowledge Base — styleguide
 * Matches stormfors.com: oversized slab-serif headings, monochrome off-white/ink,
 * "• eyebrow" labels, uppercase breadcrumbs, restrained crimson accent. Light + dark.
 * Display: Jubilat (Zilla Slab fallback). Body: Inter.
 */

:root {
  /* Brand color tokens (exact, from styleguide) */
  --black:       #212121;
  --grey-dark:   #999999;
  --grey-light:  #dddddd;
  --white:       #f2f2f2;
  --pure-white:  #ffffff;
  --20-light:    rgba(242,242,242,.2);
  --20-dark:     rgba(33,33,33,.2);
  --crimson:      #d42350;
  --crimson-dark: #a81a3f;

  /* Light theme (default) */
  --bg:         var(--white);      /* Background = White */
  --surface:    var(--pure-white);
  --surface-2:  #e6e6e6;
  --border:     var(--20-dark);    /* Border = 20% (Dark) */
  --text:       var(--black);      /* Text = Black */
  --text-muted: var(--grey-dark);  /* Grey (Dark) */
  --link:       var(--black);
  --link-hover: var(--crimson);
  --accent:     var(--crimson);
  --code-bg:    #e6e6e6;
  --pre-bg:     var(--black);
  --pre-fg:     #eaeaea;

  /* Typography */
  --font-display: "Jubilat", "Zilla Slab", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  --fw-normal: 400;   /* default weight everywhere */

  /* Type scale (exact, from styleguide) */
  --fs-h1: 4.5rem;
  --fs-h2: 3rem;
  --fs-h3: 2.25rem;
  --fs-h4: 1.75rem;
  --fs-h5: 1.375rem;
  --fs-h6: 1.125rem;
  --fs-paragraph-l: 1.125rem;
  --fs-paragraph-m: 1rem;     /* body default */
  --fs-paragraph-s: 0.875rem;
  --fs-deco: 0.75rem;         /* Decorative */
  --fs-link: 1rem;
  --fs-body: var(--fs-paragraph-m);
  --fs-small: var(--fs-paragraph-s);
  --lh-body: 1.7;
  --lh-tight: 1.05;

  /* Spacing scale */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-6: 1.5rem; --sp-8: 2rem; --sp-12: 3rem; --sp-16: 4rem;

  /* Standardized rhythm — use these between elements/sections */
  --space-element: 1.5rem;   /* gap between blocks (p, list, table, callout) */
  --space-section: 4rem;     /* gap before a new section (h2) */
  --space-sub: 2.5rem;       /* gap before a subsection (h3) */

  /* Layout */
  --container-width: 80rem;             /* page container */
  --content-width: 80rem;               /* prose reading column */
  --global-horizontal-padding: 5vw;     /* page side padding */
  --sidebar-width: 17rem;               /* left nav */
  --header-h: 4rem;                     /* sticky top-bar height */

  --radius: 0.5rem;
  --radius-sm: 3px;
  --shadow: 0 1px 2px rgba(33,33,33,.06), 0 12px 34px rgba(33,33,33,.08);
}

[data-theme="dark"] {
  --bg:         var(--black);      /* Bg alternate = Black */
  --surface:    #2a2a2a;
  --surface-2:  #333333;
  --border:     var(--20-light);   /* 20% (Light) */
  --text:       var(--white);      /* Text alternate = White */
  --text-muted: var(--grey-dark);
  --link:       var(--white);
  --link-hover: #ff6f8b;
  --accent:     #ff6f8b;
  --code-bg:    #333333;
  --pre-bg:     #0f0f0f;
  --pre-fg:     #eaeaea;
  --shadow:     0 1px 2px rgba(0,0,0,.4), 0 12px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  transition: background-color .2s ease, color .2s ease;
}

/* Shell: top bar (full width) + sidebar (left) + content (right).
   Explicit rows (auto / 1fr / auto) so the middle row fills the viewport and the
   header/footer stay their natural height even when a page is empty. */
.sf-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: auto 1fr auto; min-height: 100vh; }
.sf-header { grid-area: 1 / 1 / 2 / -1; }
.sf-sidebar { grid-area: 2 / 1 / 3 / 2; }
.sf-main { grid-area: 2 / 2 / 3 / 3; }
.sf-footer { grid-area: 3 / 1 / 4 / -1; }

.sf-container { width: 100%; max-width: var(--container-width); margin-inline: auto; padding-inline: var(--global-horizontal-padding); }

/* Top bar — fixed ~5rem height; brand occupies the sidebar column so the
   divider lands exactly on the sidebar's right border (one continuous line). */
.sf-header { background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.sf-header .sf-container { display: flex; align-items: stretch; gap: 0; padding: 0; max-width: none; min-height: var(--header-h); }

/* Left sidebar */
.sf-sidebar { border-right: 1px solid var(--border); background: var(--bg); }
.sf-sidebar nav { position: sticky; top: var(--header-h); max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: var(--sp-8) var(--sp-6); }
.sf-sidebar__group { margin-bottom: var(--sp-6); }
.sf-sidebar__title { font-size: var(--fs-deco); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; margin: 0 0 var(--sp-2); }
.sf-sidebar a { display: block; padding: var(--sp-1) 0; color: var(--text-muted); text-decoration: none; font-size: var(--fs-paragraph-s); line-height: 1.4; }
.sf-sidebar a:hover { color: var(--text); }
.sf-sidebar a[aria-current="page"] { color: var(--text); font-weight: 600; border-left: 2px solid var(--crimson); margin-left: -10px; padding-left: 8px; }

/* Content column */
.sf-main { padding: var(--space-section) clamp(var(--sp-6), 5vw, var(--sp-16)) var(--sp-16); }
.sf-main > * { max-width: var(--content-width); }
.sf-hero { max-width: var(--content-width); margin-bottom: var(--space-section); }
.sf-hero h1 { margin-bottom: var(--sp-6); }
.sf-hero .sf-lead { margin-bottom: 0; }
.sf-brand { width: var(--sidebar-width); box-sizing: border-box; padding-left: var(--sp-6); display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
.sf-logo { height: 22px; width: auto; display: block; }
.sf-nav { display: flex; align-items: center; gap: var(--sp-6); margin-left: auto; padding-right: var(--global-horizontal-padding); flex-wrap: wrap; }
.sf-nav a { color: var(--text); text-decoration: none; font-size: var(--fs-small); }
.sf-nav a:hover { color: var(--crimson); }

/* Dark-mode toggle (pill switch) */
.sf-toggle { appearance: none; border: 1px solid var(--border); background: var(--surface-2); width: 44px; height: 24px; border-radius: 999px; position: relative; cursor: pointer; padding: 0; transition: background-color .2s; }
.sf-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); transition: transform .2s; }
[data-theme="dark"] .sf-toggle::after { transform: translateX(20px); }

/* Footer */
.sf-footer { border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-small); }
.sf-footer .sf-container { padding-top: var(--sp-8); padding-bottom: var(--sp-8); }

/* Typography — oversized slab display */
h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--lh-tight); color: var(--text); font-weight: var(--fw-normal); text-wrap: balance; }
h1 { font-size: var(--fs-h1); margin: 0 0 var(--sp-6); letter-spacing: -.02em; }
h2 { font-size: var(--fs-h2); margin: var(--space-section) 0 var(--sp-4); letter-spacing: -.01em; }
h3 { font-size: var(--fs-h3); margin: var(--space-sub) 0 var(--sp-3); }
h4 { font-size: var(--fs-h4); margin: var(--space-element) 0 var(--sp-2); }
p { margin: 0 0 var(--space-element); }
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }
ul, ol { margin: 0 0 var(--space-element); padding-left: var(--sp-6); }
li { margin: var(--sp-1) 0; }
strong { color: var(--text); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-section) 0; }
table, pre, .sf-callout { margin-bottom: var(--space-element); }

/* Eyebrow — "• LABEL" leading bullet, uppercase */
.sf-eyebrow { font-family: var(--font-body); font-size: var(--fs-deco); text-transform: uppercase; letter-spacing: .1em; color: var(--text); font-weight: 600; margin: 0 0 var(--sp-3); }
.sf-eyebrow::before { content: "• "; color: var(--text-muted); }

.sf-lead { font-size: var(--fs-h5); color: var(--text); margin-bottom: var(--sp-8); line-height: 1.45; }

/* Breadcrumb — uppercase, dash separators */
.sf-crumb { font-size: var(--fs-deco); color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--sp-8); }
.sf-crumb a { color: var(--text-muted); text-decoration: none; }
.sf-crumb a:hover { color: var(--crimson); }
.sf-crumb span { margin: 0 var(--sp-2); opacity: .5; }

/* Code */
code { font-family: var(--font-mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); padding: .1em .4em; border-radius: var(--radius-sm); }
pre { background: var(--pre-bg); color: var(--pre-fg); padding: var(--sp-4); border-radius: var(--radius); overflow-x: auto; font-size: var(--fs-small); line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; color: inherit; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 0 0 var(--sp-6); font-size: var(--fs-small); }
th, td { text-align: left; padding: var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text); font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }

/* Callout */
.sf-callout { border-left: 3px solid var(--accent); background: var(--surface-2); padding: var(--sp-4) var(--sp-6); border-radius: var(--radius-sm); margin: var(--sp-6) 0; }
.sf-callout--warn { border-left-color: var(--crimson); }

/* Status pills */
.sf-pill { display: inline-block; font-size: var(--fs-deco); font-weight: 700; padding: .15em .65em; border-radius: 999px; letter-spacing: .03em; text-transform: uppercase; }
.sf-pill--stub { background: var(--surface-2); color: var(--text-muted); }
.sf-pill--draft { background: #f3e2c7; color: #7a5a00; }
.sf-pill--researched { background: #e9d6dd; color: var(--crimson-dark); }
.sf-pill--published { background: #d8ece0; color: #0a6b3d; }

/* Card grid */
.sf-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: var(--sp-8) 0; padding: 0; list-style: none; }
.sf-card { display: block; padding: var(--sp-6); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit; background: var(--surface); transition: box-shadow .15s, transform .15s, border-color .15s; }
.sf-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--crimson); }
.sf-card h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-h4); font-family: var(--font-display); }
.sf-card p { margin: 0; color: var(--text-muted); font-size: var(--fs-small); }

/* Two-column meta layout (left label column + content) */
.sf-meta { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-8); align-items: start; }
.sf-meta__aside dt { font-size: var(--fs-deco); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-top: var(--sp-4); }
.sf-meta__aside dd { margin: 0 0 var(--sp-2); }
@media (max-width: 720px) { .sf-meta { grid-template-columns: 1fr; gap: var(--sp-4); } }

/* Research report bits */
.report-meta { font-size: var(--fs-deco); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 var(--space-section); }
sup a { font-weight: 700; text-decoration: none; color: var(--accent); font-size: .72em; padding: 0 .05em; }
.sf-sources { font-size: var(--fs-small); }
.sf-sources li { margin: var(--sp-2) 0; word-break: break-word; }

/* Collapse sidebar on narrow viewports */
@media (max-width: 860px) {
  .sf-shell { grid-template-columns: 1fr; grid-template-rows: none; }
  .sf-header, .sf-footer, .sf-sidebar, .sf-main { grid-area: auto; }
  .sf-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .sf-sidebar nav { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: var(--sp-4) var(--sp-8); padding: var(--sp-4) var(--global-horizontal-padding); }
  .sf-sidebar__group { margin-bottom: 0; }
  /* unpin the brand column so the bar fits small screens */
  .sf-brand { width: auto; padding-left: var(--global-horizontal-padding); }
}

@media (max-width: 600px) {
  :root { --fs-h1: 2.75rem; --fs-h2: 2rem; --fs-h3: 1.5rem; }
}
