/* =========================================================================
   ICOS Brand & Style Guide — Core Stylesheet
   Apple-clean documentation system. All values flow from design tokens.
   ========================================================================= */

/* ---------- Tokens: Light ---------- */
:root, [data-theme="light"] {
  /* Brand — Blau (Basis 100% + Tints 90→10) */
  --blue-base: #1E4975;
  --blue-90: #355B83;
  --blue-80: #4B6D91;
  --blue-70: #62809E;
  --blue-60: #7892AC;
  --blue-50: #8FA4BA;
  --blue-40: #A5B6C8;
  --blue-30: #BCC8D6;
  --blue-20: #D2DBE3;
  --blue-10: #E9EDF1;

  /* Brand — Orange (Basis 100% + Tints 90→10) */
  --orange-base: #FF940A;
  --orange-90: #FF9F23;
  --orange-80: #FFA93B;
  --orange-70: #FFB454;
  --orange-60: #FFBF6C;
  --orange-50: #FFCA85;
  --orange-40: #FFD49D;
  --orange-30: #FFDFB6;
  --orange-20: #FFEACE;
  --orange-10: #FFF4E7;

  /* Neutral — Grau (Basis 100% = #191919 + Tints) */
  --gray-base: #191919;
  --gray-90: #303030;
  --gray-80: #474747;
  --gray-70: #5E5E5E;
  --gray-60: #757575;
  --gray-50: #8C8C8C;
  --gray-40: #A3A3A3;
  --gray-30: #BABABA;
  --gray-20: #D1D1D1;
  --gray-10: #E8E8E8;

  /* Semantik */
  --success: #1E8E57;
  --success-strong: #136540;
  --success-soft: #E7F4EC;
  --error: #D23B2E;
  --error-strong: #A82318;
  --error-soft: #FBEAE8;

  /* Funktions-Aliase */
  --brand-primary: var(--blue-base);
  --brand-accent: var(--orange-base);
  /* Orange als Textton auf hellem Grund (AA): das vertiefte Orange — niemals das helle #FF940A für Text */
  --orange-text: #B65E00;
  /* LEGACY — nicht mehr verwendet. Buttons sind jetzt #FF940A-Vollton mit Anthrazit-Schrift (#191919, AAA 8,7:1). Token bleibt nur zur Rückwärtskompatibilität. */
  --btn-orange: #B85D00;
  --btn-orange-hover: #A45200;

  /* Flächen & Text (Light) */
  --bg: #FFFFFF;
  --bg-subtle: #F5F7F9;
  --bg-sunken: #EAEFF3;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --border: #E6EBEF;
  --border-strong: #D2DBE3;
  --text: #191919;
  --text-secondary: #5E5E5E;
  --text-muted: #8C8C8C;
  --link: var(--blue-base);
  --code-bg: #F2F5F8;
  --code-text: #2B4763;

  /* Typografie */
  --font-sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Menlo", Consolas, monospace;

  --fs-display: clamp(2.6rem, 1.6rem + 4vw, 4.5rem);
  --fs-h1: clamp(2rem, 1.4rem + 2.4vw, 3rem);
  --fs-h2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-h3: 1.3125rem;
  --fs-h4: 1.0625rem;
  --fs-body: 1.0625rem;
  --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem;
  --fs-2xs: 0.6875rem;

  /* Spacing (4er-Raster) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;

  /* Radius (weich) */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Schatten (dezent) */
  --shadow-sm: 0 1px 2px rgba(25, 35, 53, 0.05), 0 1px 1px rgba(25, 35, 53, 0.04);
  --shadow: 0 4px 16px rgba(25, 45, 77, 0.07), 0 1px 3px rgba(25, 45, 77, 0.05);
  --shadow-lg: 0 18px 48px rgba(25, 45, 77, 0.12), 0 4px 12px rgba(25, 45, 77, 0.06);

  --sidebar-w: 280px;
  --topbar-h: 64px;
  --content-max: 1080px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Tokens: Dark ---------- */
[data-theme="dark"] {
  --brand-primary: #6E97C4;
  --bg: #0E1116;
  --bg-subtle: #141A22;
  --bg-sunken: #0A0D11;
  --surface: #161C25;
  --surface-2: #1C232E;
  --border: #283140;
  --border-strong: #36414F;
  --text: #F2F5F8;
  --text-secondary: #AEB8C4;
  --text-muted: #7C8794;
  --link: #6E97C4;
  --code-bg: #11161D;
  --code-text: #A9C4E0;
  --success-soft: #11271D;
  --error-soft: #2A1512;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 56px rgba(0, 0, 0, 0.55);
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-primary); }
h5 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; }
li { list-style: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- App Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-5);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 700; letter-spacing: -0.01em; }
.topbar__brand img { height: 26px; width: auto; }
.topbar__tag { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.topbar__spacer { flex: 1; }
.topbar__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.theme-toggle {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 38px; padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary);
  border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600;
  transition: all 0.2s var(--ease);
}
.theme-toggle:hover { border-color: var(--brand-primary); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Sidebar */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 40;
  overflow-y: auto; padding: var(--space-5) var(--space-4) var(--space-8);
  background: var(--bg-subtle); border-right: 1px solid var(--border);
}
.nav-group { margin-bottom: var(--space-5); }
.nav-group__label {
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 var(--space-3); margin-bottom: var(--space-2);
}
.nav-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
  transition: all 0.15s var(--ease);
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--surface); color: var(--brand-primary); box-shadow: var(--shadow-sm); }
.nav-link .num { font-size: inherit; font-weight: 700; color: var(--text-muted); width: 24px; flex-shrink: 0; }
.nav-link.is-active .num { color: var(--brand-accent); }
.nav-sub { display: flex; flex-direction: column; margin: 2px 0 6px; padding-left: calc(var(--space-3) + 24px); gap: 1px; }
.nav-sublink {
  position: relative; padding: 6px var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text-muted); text-decoration: none; line-height: 1.3;
  transition: all 0.15s var(--ease);
}
.nav-sublink::before {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong);
}
.nav-sublink:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-sublink.is-active { color: var(--brand-accent); font-weight: 700; }
.nav-sublink.is-active::before { background: var(--brand-accent); }

/* Main */
.main { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); min-width: 0; }
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-8) var(--space-7) var(--space-10); }
@media (max-width: 1180px) { .page { padding: var(--space-7) var(--space-6) var(--space-9); } }

/* ---------- Hero / Page header ---------- */
.page-head { margin-bottom: var(--space-8); }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--brand-accent); margin-bottom: var(--space-4);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-accent); }
.page-title { font-size: var(--fs-h1); font-weight: 700; margin-bottom: var(--space-4); }
.page-lead { font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); color: var(--text-secondary); max-width: 60ch; line-height: 1.5; text-wrap: pretty; }

.hero-display { font-size: var(--fs-display); font-weight: 700; letter-spacing: -0.03em; line-height: 1.02; color: var(--text); }

/* ---------- Sections ---------- */
.section { margin-top: var(--space-9); scroll-margin-top: calc(var(--topbar-h) + 24px); }
.section__head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-5); }
.section__num {
  font-size: var(--fs-h2); font-weight: 700; color: var(--brand-accent);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.section__title { font-size: var(--fs-h2); font-weight: 700; }
/* Markenaussage / Claim — eine große, geschlossene Aussage. Ein Schlüsselwort darf in Orange stehen. */
.claim { font-size: clamp(2rem, 1.4rem + 2.2vw, 3.25rem); font-weight: 700; letter-spacing: -0.025em; line-height: 1.12; max-width: 24ch; text-wrap: balance; }
.section__intro { font-size: 1.125rem; color: var(--text-secondary); max-width: 64ch; margin: calc(-1 * var(--space-2)) 0 var(--space-6); line-height: 1.6; text-wrap: pretty; }
.subhead { font-size: var(--fs-h4); font-weight: 700; letter-spacing: 0; margin: var(--space-6) 0 var(--space-4); color: var(--brand-primary); }

.prose p { color: var(--text-secondary); max-width: 68ch; margin-bottom: var(--space-4); line-height: 1.65; }
.prose strong { color: var(--text); font-weight: 700; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-6); box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Swatches ---------- */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.swatch {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.swatch:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.swatch__chip { height: 84px; display: flex; align-items: flex-end; justify-content: flex-end; padding: var(--space-2); }
.swatch__pct { font-size: var(--fs-2xs); font-weight: 700; padding: 2px 7px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.85); color: #191919; }
.swatch__pct.on-light { background: rgba(25,25,25,0.08); }
.swatch__body { padding: var(--space-3); }
.swatch__name { font-size: var(--fs-sm); font-weight: 700; }
.swatch__hex { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; cursor: copy; }
.swatch__hex:hover { color: var(--brand-primary); }

.swatch-lg { display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.swatch-lg__chip { height: 150px; position: relative; }
.swatch-lg__body { padding: var(--space-4) var(--space-5); background: var(--surface); }
.swatch-lg__name { font-weight: 700; font-size: var(--fs-h4); }
.swatch-lg__role { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--space-3); }
.swatch-lg__codes { display: flex; flex-wrap: wrap; gap: var(--space-3); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-secondary); }
.swatch-lg__codes span { cursor: copy; }
.swatch-lg__codes span:hover { color: var(--brand-primary); }

/* ---------- Spec table ---------- */
.spec { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.spec th, .spec td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.spec th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; }
.spec td { color: var(--text-secondary); }
.spec td strong { color: var(--text); font-weight: 700; }
.spec tr:last-child td { border-bottom: none; }
.spec code, .mono { font-family: var(--font-mono); font-size: 0.9em; color: var(--code-text); }

/* ---------- Tokens / code ---------- */
.token-row {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: var(--space-2);
}
.token-row .dot-chip { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border-strong); flex-shrink: 0; }
.token-row .tname { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text); font-weight: 600; }
.token-row .tval { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); margin-left: auto; }
.copy-btn {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-secondary);
  border-radius: var(--radius-sm); padding: 4px 10px; font-size: var(--fs-2xs); font-weight: 700;
}
.copy-btn:hover { color: var(--brand-primary); border-color: var(--brand-primary); }

pre.code {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-5); overflow-x: auto; font-family: var(--font-mono); font-size: var(--fs-sm);
  line-height: 1.7; color: var(--code-text); margin: 0;
}
pre.code .c-prop { color: var(--brand-primary); }
pre.code .c-val { color: var(--text); }
[data-theme="dark"] pre.code .c-val { color: #E6ECF3; }
pre.code .c-com { color: var(--text-muted); }

/* ---------- Callouts ---------- */
.callout {
  display: flex; gap: var(--space-4); padding: var(--space-5);
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2);
}
.callout__icon { flex-shrink: 0; width: 24px; height: 24px; }
.callout--accent { background: var(--orange-10); border-color: var(--orange-30); }
[data-theme="dark"] .callout--accent { background: rgba(255,148,10,0.08); border-color: rgba(255,148,10,0.3); }
.callout--info { background: var(--blue-10); border-color: var(--blue-30); }
[data-theme="dark"] .callout--info { background: rgba(110,151,196,0.1); border-color: rgba(110,151,196,0.3); }
.callout__title { font-weight: 700; margin-bottom: var(--space-1); }
.callout__body { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.6; }
.callout__body strong { color: var(--text); }

/* ---------- Do / Don't ---------- */
.dd { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
@media (max-width: 720px) { .dd { grid-template-columns: 1fr; } }
.dd__item { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.dd__stage { height: 180px; display: grid; place-items: center; background: var(--bg-subtle); padding: var(--space-5); }
.dd__label { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); font-size: var(--fs-sm); font-weight: 700; border-top: 1px solid var(--border); }
.dd__label .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.dd__do .mark { background: var(--success); }
.dd__dont .mark { background: var(--error); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px 14px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; background: var(--blue-10); color: var(--blue-base);
}
[data-theme="dark"] .pill { background: rgba(110,151,196,0.14); color: #9FBCDB; }
.pill--accent { background: var(--orange-10); color: #B65E00; }
[data-theme="dark"] .pill--accent { background: rgba(255,148,10,0.14); color: var(--orange-base); }
.system-pill {
  display: inline-flex; align-items: center; padding: 8px 18px; border-radius: var(--radius-pill);
  background: var(--surface); color: var(--blue-base); font-weight: 700; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.system-pill.is-state { color: var(--orange-base); }

/* ---------- Misc utility ---------- */
.muted { color: var(--text-muted); }
.divider { height: 1px; background: var(--border); border: none; margin: var(--space-7) 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.lede-list { display: grid; gap: var(--space-3); }
.lede-list li { display: flex; gap: var(--space-3); align-items: flex-start; color: var(--text-secondary); line-height: 1.55; }
.lede-list li::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--brand-accent); margin-top: 9px; flex-shrink: 0; }
.kicker { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

/* Footer nav */
.page-foot { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-10); padding-top: var(--space-6); border-top: 1px solid var(--border); }
.page-foot a { display: flex; flex-direction: column; gap: 2px; padding: var(--space-4) var(--space-5); border: 1px solid var(--border); border-radius: var(--radius); min-width: 200px; }
.page-foot a:hover { border-color: var(--brand-primary); text-decoration: none; box-shadow: var(--shadow-sm); }
.page-foot .lbl { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.page-foot .ttl { font-weight: 700; color: var(--text); }
.page-foot .next { text-align: right; align-items: flex-end; }

/* Mobile nav toggle */
.menu-btn { display: none; }
@media (max-width: 940px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform 0.28s var(--ease); width: min(86vw, var(--sidebar-w)); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); }
  .scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(10,15,25,0.4); z-index: 39; opacity: 0; pointer-events: none; transition: opacity 0.25s var(--ease); }
  .scrim.is-open { opacity: 1; pointer-events: auto; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
