/*
 * Design Tokens — Quant Research Intelligence Lab
 * Typography: IBM Plex Mono (OpenCode.ai style)
 * Local hosting, preloaded, font-display:swap, zero CLS
 */

/* ═══════════════════════════════════════════════════════════
 * @font-face — IBM Plex Mono (lokal gehostet)
 * ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Thin.ttf') format('truetype');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-ThinItalic.ttf') format('truetype');
  font-weight: 100;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-ExtraLight.ttf') format('truetype');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-ExtraLightItalic.ttf') format('truetype');
  font-weight: 200;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-LightItalic.ttf') format('truetype');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-MediumItalic.ttf') format('truetype');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-SemiBoldItalic.ttf') format('truetype');
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-BoldItalic.ttf') format('truetype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ═══════════════════════════════════════════════════════════
 * Design Tokens
 * ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Surface ── */
  --color-surface-canvas:   #0B0D0F;
  --color-surface-primary:  #111418;
  --color-surface-secondary:#171B20;
  --color-surface-tertiary: #1D2228;
  --color-surface-hover:    #242A31;

  /* ── Border ── */
  --color-border-subtle:    #262C33;
  --color-border-strong:    #39414A;

  /* ── Text ── */
  --color-text-primary:     #F2F4F6;
  --color-text-secondary:   #B3BAC2;
  --color-text-muted:       #7F8892;
  --color-text-disabled:    #59616A;

  /* ── UI accent: MONOCHROME · the shell is black/gray/white ── */
  /* Blue is NOT the accent/brand color. Neutral light-gray is the generic
     accent (links, active nav, focus, selected tabs); it is deliberately
     reserved so that any color on screen carries data/semantic meaning. */
  --color-accent:           #C9CDD3;

  /* ── Semantic accents ── (allowed: they carry meaning) ── */
  --color-accent-info:      #9AA2AB;  /* info — neutral, not blue */
  --color-accent-positive:  #62A67B;  /* success / active / long / connected */
  --color-accent-negative:  #C56B70;  /* error / critical / short / drawdown */
  --color-accent-warning:   #C2A25C;  /* warn / pending / review / risk */
  --color-accent-neutral:   #8D97A2;

  /* ── Status semantics (functional color only) ── */
  --status-success: #62A67B;
  --status-warning: #C2A25C;
  --status-error:   #C56B70;
  --status-info:    #9AA2AB;

  /* ── Chart / data series: the ONLY place palette color is expected ── */
  --chart-green:   #3fb950;
  --chart-red:     #f85149;
  --chart-yellow:  #d29922;
  --chart-purple:  #bc8cff;
  --chart-cyan:    #39c5cf;

  /*
   * ── Legacy tree-nav palette ──
   * tree-nav.css (and a few inline banner styles) reference the short-named
   * vars --bg/--bg2/--bg3/--bg4/--text/--text2/--border/--accent/... which are
   * NOT part of the --color-* token system above. Most templates define their
   * own :root with these inline; trading_journal.html does not, which made
   * .sidebar{background:var(--bg2)} INVALID (undefined var) → transparent →
   * the sidebar painted black on the standalone trade-detail route. Provide a
   * central fallback here; pages that define the same vars later in :root
   * still win (normal CSS cascade), so this only fixes pages that lacked them.
   */
  --bg:            #0d1117;
  --bg2:           #161b22;
  --bg3:           #21262d;
  --bg4:           #30363d;
  --text:          #e6edf3;
  --text2:         #8b949e;
  --border:        #30363d;
  --accent:        #C9CDD3;
  --green:         #3fb950;
  --red:           #f85149;
  --orange:        #d29922;
  --purple:        #bc8cff;
  --radius:        8px;

  /* ── Spacing ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;

  /* ── Radius ── */
  --radius-control: 4px;
  --radius-panel: 6px;
  --radius-modal: 8px;

  /* ═══════════════════════════════════════════════════
   * TYPOGRAPHY — Global (OpenCode.ai style)
   * ═══════════════════════════════════════════════════ */

  /* Font Families — NUR diese zwei Tokens verwenden */
  --font-ui:   "IBM Plex Mono", "Berkeley Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-mono: "IBM Plex Mono", "Berkeley Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Font Weights — NUR diese verwenden */
  --font-weight-thin:      100;
  --font-weight-light:     300;
  --font-weight-regular:   400;
  --font-weight-medium:    500;
  --font-weight-semibold:  600;
  --font-weight-bold:      700;

  /* Typography Scale — Desktop (Basis) */
  --text-display-xl:   clamp(2.25rem, 5vw, 3.5rem);     /* 36-56px */
  --text-display-lg:   clamp(1.75rem, 4vw, 2.5rem);     /* 28-40px */
  --text-h1:           clamp(1.5rem, 3.5vw, 2rem);      /* 24-32px */
  --text-h2:           clamp(1.25rem, 2.5vw, 1.5rem);   /* 20-24px */
  --text-h3:           clamp(1.1rem, 2vw, 1.25rem);     /* 17-20px */
  --text-h4:           clamp(1rem, 1.5vw, 1.125rem);    /* 16-18px */
  --text-body-lg:      clamp(0.95rem, 1.5vw, 1.0625rem);/* 15-17px */
  --text-body:         clamp(0.875rem, 1.25vw, 0.9375rem);/* 14-15px */
  --text-body-sm:      clamp(0.8125rem, 1vw, 0.875rem); /* 13-14px */
  --text-caption:      clamp(0.6875rem, 0.8vw, 0.75rem);/* 11-12px */
  --text-label:        clamp(0.625rem, 0.7vw, 0.6875rem);/* 10-11px */
  --text-button:       clamp(0.8125rem, 1vw, 0.875rem); /* 13-14px */
  --text-code:         clamp(0.8125rem, 1vw, 0.875rem); /* 13-14px */

  /* Line Heights */
  --leading-tight:  1.2;
  --leading-normal: 1.4;
  --leading-relaxed:1.6;

  /* ── Elevation ── */
  --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 4px 16px rgba(0, 0, 0, 0.5);

  /* ── Strategy-Studio: semantische Farben (WP-SS-54) ──
     Farbe ist im Strategy Studio ein Orientierungssystem: Boolean und Blocks
     lesen DIESELBEN Tokens, damit eine Bedingung in beiden Editoren gleich
     aussieht (Auftrag §2/§9/§48). Kanonisch hier im Design System — die
     Ansichten mappen nur noch auf ihren Namen und tragen keinen eigenen Wert.
     Dark Institutional + semantische Neon-Akzente, kein Gaming-Look. */
  --qr-sw-price:  #58a6ff;   /* Preis / Markt          */
  --qr-sw-ind:    #2dd4bf;   /* Indikator              */
  --qr-sw-time:   #bc8cff;   /* Zeit / Session         */
  --qr-sw-state:  #8b98a5;   /* Zustand / Variable     */
  --qr-sw-risk:   #f0883e;   /* Risiko / Struktur      */
  --qr-sw-block:  #ff5c8a;   /* Blocker / Invalidierung*/
  --qr-sw-logic:  #8b7cf6;   /* Logik-Gruppe           */
  --qr-sw-entry:  #3fb950;   /* Einstieg               */
  --qr-sw-size:   #e3b341;   /* Positionsgroesse       */
  --qr-sw-stop:   #f85149;   /* Stop                   */
  --qr-sw-target: #f0b429;   /* Ziel                   */
  --qr-sw-shadow: 0 1px 0 rgba(255,255,255,.03), 0 6px 18px -10px rgba(0,0,0,.85);
}

/* ═══════════════════════════════════════════════════════════
 * Global Defaults — alles erbt von hier
 * ═══════════════════════════════════════════════════════════ */

html {
  font-family: var(--font-ui);
  font-size: 16px; /* Basis für rem-Einheiten */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-body);
  font-weight: var(--font-weight-regular);
  line-height: var(--leading-normal);
}

/* Form elements do NOT inherit font-family by default — force it */
button,
input,
textarea,
select,
option {
  font: inherit;
}

/* ═══════════════════════════════════════════════════════════
 * Scroll-Leisten — EIN Haus-Standard für ganz QRIL
 * Referenz/ursprünglich: Journal (.tj-content in trading_journal.css).
 * Jede sichtbare Leiste sieht so aus; Komponenten überschreiben das NICHT.
 * Erlaubt ist nur AUSBLENDEN: `scrollbar-width: none` bzw.
 * `::-webkit-scrollbar { display: none }`. NIEMALS `scrollbar-width: thin`
 * setzen — das schaltet in Chrome die ::-webkit-Regeln ab und liefert die
 * native (helle) Leiste. Gate: tests/test_ui_scrollbar_standard.py.
 * Zweite, identische Quelle: dashboard/qril_header_middleware.py (_STYLE) —
 * sie deckt die Seiten ab, die diese Datei nicht laden.
 * ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-surface-secondary, #171B20); }
::-webkit-scrollbar-thumb { background: var(--color-border-strong, #39414A); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted, #7F8892); }
::-webkit-scrollbar-corner { background: var(--color-surface-secondary, #171B20); }

/* ═══════════════════════════════════════════════════════════
 * Typography Utility Classes — zentral, NUR diese verwenden
 * ═══════════════════════════════════════════════════════════ */

.text-display-xl { font-size: var(--text-display-xl); font-weight: var(--font-weight-bold); line-height: var(--leading-tight); }
.text-display-lg { font-size: var(--text-display-lg); font-weight: var(--font-weight-bold); line-height: var(--leading-tight); }
.text-h1  { font-size: var(--text-h1);  font-weight: var(--font-weight-bold);     line-height: var(--leading-tight); }
.text-h2  { font-size: var(--text-h2);  font-weight: var(--font-weight-semibold); line-height: var(--leading-tight); }
.text-h3  { font-size: var(--text-h3);  font-weight: var(--font-weight-semibold); line-height: var(--leading-normal); }
.text-h4  { font-size: var(--text-h4);  font-weight: var(--font-weight-medium);   line-height: var(--leading-normal); }
.text-body-lg { font-size: var(--text-body-lg); font-weight: var(--font-weight-regular); line-height: var(--leading-relaxed); }
.text-body    { font-size: var(--text-body);    font-weight: var(--font-weight-regular); line-height: var(--leading-normal); }
.text-body-sm { font-size: var(--text-body-sm); font-weight: var(--font-weight-regular); line-height: var(--leading-normal); }
.text-caption { font-size: var(--text-caption); font-weight: var(--font-weight-regular); line-height: var(--leading-normal); }
.text-label   { font-size: var(--text-label);   font-weight: var(--font-weight-medium);  line-height: var(--leading-tight); text-transform: uppercase; letter-spacing: 0.05em; }
.text-button  { font-size: var(--text-button);  font-weight: var(--font-weight-semibold);line-height: var(--leading-tight); }
.text-code    { font-size: var(--text-code);    font-weight: var(--font-weight-regular); line-height: var(--leading-normal); font-family: var(--font-mono); }
.text-mono    { font-family: var(--font-mono); }

/* Weight utilities */
.font-thin       { font-weight: var(--font-weight-thin); }
.font-light      { font-weight: var(--font-weight-light); }
.font-regular    { font-weight: var(--font-weight-regular); }
.font-medium     { font-weight: var(--font-weight-medium); }
.font-semibold   { font-weight: var(--font-weight-semibold); }
.font-bold       { font-weight: var(--font-weight-bold); }

/* ═══════════════════════════════════════════════════════════
 * Dark Mode — bereits die Default-Farben, kein Override nötig
 * Light Mode (später) überschreibt nur Farben, nicht Typo
 * ═══════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: light) {
  :root {
    /* Light mode behält identische Typografie bei,
       überschreibt nur Farb-Tokens (später) */
  }
}

/* Global readable font size — überschreibt body nur wenn nötig */
@media screen and (max-width: 768px) {
  html { font-size: 15px; }
}
@media screen and (max-width: 480px) {
  html { font-size: 14px; }
}
