/* =========================================================
   mediaintel — design tokens + global styles
   Klassisch-journalistische Ästhetik, FT/NZZ-Linie
   ========================================================= */

:root {
  /* Type */
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Colors — light */
  --bg: #fafaf7;
  --bg-elevated: #ffffff;
  --bg-subtle: #f3efe6;
  --bg-inset: #ece6d7;
  --fg: #1a1815;
  --fg-muted: #6b6661;
  --fg-faint: #98948e;
  --border: #e5dfd3;
  --border-strong: #c9c1b0;
  --rule: #1a1815;
  --accent: #0a90cf;
  --accent-hover: #0876b0;
  --accent-soft: #e0f0fa;
  --shadow: 0 1px 0 var(--border), 0 8px 24px -12px rgba(20, 18, 14, 0.08);

  /* Layout */
  --max-w: 1280px;
  --gutter: clamp(20px, 4vw, 48px);
  --section-y: clamp(56px, 9vw, 112px);
  --rule-thin: 1px;
  --rule-thick: 2px;
}

:root[data-theme="dark"] {
  --bg: #131210;
  --bg-elevated: #1c1b18;
  --bg-subtle: #232118;
  --bg-inset: #2a281f;
  --fg: #f3efe6;
  --fg-muted: #a8a299;
  --fg-faint: #6b6661;
  --border: #2e2b25;
  --border-strong: #4a463d;
  --rule: #f3efe6;
  --accent: #0a90cf;
  --accent-hover: #2ca5e0;
  --accent-soft: #0a1c2a;
  --shadow: 0 1px 0 var(--border), 0 8px 24px -12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html, body { overflow-x: clip; }  /* Prevent horizontal scroll from oversized hero/section content */

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  min-height: 100vh;
}

/* ---------- Typography ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--fg);
  text-wrap: balance;
}

h1 { font-size: clamp(40px, 5.5vw, 76px); line-height: 1.02; letter-spacing: -0.025em; font-weight: 600; }
h2 { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.08; letter-spacing: -0.02em; }
h3 { font-size: clamp(20px, 1.8vw, 26px); line-height: 1.2; }
h4 { font-size: 18px; line-height: 1.3; }

p { margin: 0; text-wrap: pretty; }

.lede {
  font-family: var(--font-serif);
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.5;
  font-weight: 400;
  color: var(--fg);
}

.body-text {
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg-muted);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex: none;
}
.eyebrow.muted { color: var(--fg-muted); }
.eyebrow.muted::before { background: var(--fg-faint); }

.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.02em; }
.mono-sm { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); }

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
a:hover { text-decoration-color: var(--accent); color: var(--accent); }

/* ---------- Container ---------- */

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

section { padding-block: var(--section-y); }
section + section { padding-top: 0; }

.rule { height: 1px; background: var(--border); border: 0; margin: 0; }
.rule-thick { height: 2px; background: var(--rule); border: 0; margin: 0; }
.rule-double { border: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); height: 4px; margin: 0; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.logo {
  /* Logo content is 1646x216 inside a 1920x1080 PNG, starting at (133,432).
     Single scale factor --s drives all crop math, so responsive resizing
     just needs to override --s at each breakpoint. */
  --s: 0.204;
  display: inline-block;
  text-decoration: none;
  width:  calc(1646 * var(--s) * 1px);
  height: calc( 216 * var(--s) * 1px);
  background-image: url(/mediaintel_logo.png);
  background-size:     calc(1920 * var(--s) * 1px) calc(1080 * var(--s) * 1px);
  background-position: calc(-133 * var(--s) * 1px) calc(-432 * var(--s) * 1px);
  background-repeat: no-repeat;
  flex-shrink: 0;
}
.logo img { display: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
}

.header-actions { margin-left: auto; }
.site-nav + .header-actions { margin-left: 0; }

.site-nav .btn-primary { display: none; }  /* Demo CTA in nav is mobile-only */

.site-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  position: relative;
  padding: 6px 0;
}
.site-nav a:hover { color: var(--fg); }
.site-nav a.active { color: var(--fg); }
.site-nav a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle, .menu-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  width: 36px; height: 36px;
  border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-toggle:hover, .menu-toggle:hover { color: var(--fg); border-color: var(--border-strong); }
.menu-toggle { display: none; }

.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--fg);
  border-radius: 0;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--fg); color: var(--fg); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: transparent;
  padding: 0;
  height: auto;
}
.btn-ghost:hover { color: var(--accent); }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }

.arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}
.btn:hover .arrow { transform: translateX(3px); }
a.with-arrow:hover .arrow { transform: translateX(3px); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 2px solid var(--rule);
  background: var(--bg);
  padding-block: 72px 32px;
  margin-top: 96px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--border);
}

.footer-brand h4 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 16px;
}
.footer-brand p {
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 380px;
}

.footer-col h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  font-weight: 500;
  margin: 0 0 16px 0;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 14px; color: var(--fg-muted); text-decoration: none; }
.footer-col a:hover { color: var(--fg); }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 28px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.footer-bottom .meta { display: flex; gap: 24px; }

/* ---------- Badges & Pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  background: var(--bg-elevated);
}
.badge.live {
  color: #0a6e3a;
  border-color: #0a6e3a;
}
:root[data-theme="dark"] .badge.live { color: #4dd17f; border-color: #4dd17f; }
.badge.live::before {
  content: "";
  width: 6px; height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
.badge.beta { color: var(--accent); border-color: var(--accent); }
.badge.soon { color: var(--fg-faint); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 28px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card:hover { border-color: var(--border-strong); }

/* ---------- Cookie banner ---------- */

.cookie-banner {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.25);
  padding: 24px 28px;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  pointer-events: none;
}
.cookie-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.cookie-banner h4 {
  font-family: var(--font-serif);
  font-size: 18px;
  margin-bottom: 6px;
}
.cookie-banner p {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.55;
  margin-bottom: 16px;
}
.cookie-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0 18px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: none;
}
.cookie-options.visible { display: flex; }
.cookie-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.cookie-option label { font-weight: 500; color: var(--fg); }
.cookie-option .desc { color: var(--fg-muted); font-size: 12px; margin-top: 2px; }
.cookie-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Switch */
.switch {
  position: relative;
  width: 36px; height: 20px;
  background: var(--border-strong);
  flex: none;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  transition: transform 0.15s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(16px); }
.switch.disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-row label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  font-weight: 500;
}
.form-row input, .form-row textarea, .form-row select {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  padding: 12px 14px;
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: var(--fg);
}
.form-row textarea { min-height: 120px; resize: vertical; font-family: var(--font-sans); }
.form-row .error-msg { font-size: 12px; color: var(--accent); margin-top: 4px; min-height: 16px; }
.form-row.invalid input, .form-row.invalid textarea, .form-row.invalid select { border-color: var(--accent); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}
.checkbox-row input[type="checkbox"] { margin-top: 3px; flex: none; accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Utility ---------- */

.grid { display: grid; gap: var(--gutter); }
.flex { display: flex; }
.muted { color: var(--fg-muted); }
.center { text-align: center; }

.col-2 { grid-template-columns: repeat(2, 1fr); }
.col-3 { grid-template-columns: repeat(3, 1fr); }
.col-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .col-2, .col-3, .col-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .logo { --s: 0.148; }  /* logo ~32px tall, ~244px wide */

  .site-header .container { gap: 12px; }
  .header-actions { flex: 1; gap: 8px; }
  .header-actions .btn-primary { display: none; }
  .menu-toggle { display: inline-flex; margin-left: auto; }

  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px var(--gutter) 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .site-nav.mobile-open { display: flex; }
  .site-nav a {
    padding: 14px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
  }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a.active::after { display: none; }
  .site-nav .btn-primary {
    display: inline-flex;
    margin-top: 12px;
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .logo { --s: 0.120; }  /* logo ~26px tall, ~198px wide — fits 320px viewports w/ gutter */
}

/* Scrollbar refinement */
::selection { background: var(--accent); color: #fff; }

/* Print */
@media print {
  .site-header, .site-footer, .cookie-banner, .tweaks-panel { display: none !important; }
}
