/*
 * base.css — design tokens, reset, typography, global refinements.
 * TradingOnline 2026 — "editorial finance" aesthetic.
 * Brand palette LOCKED. Display = Fraunces (mockup approvati), body = Inter, mono = JetBrains. The premium feel
 * comes from execution: fluid type, tabular figures, layered depth, refined
 * focus/selection/scrollbar, animated underlines. No CSS framework, no CDN.
 */

/* =========================================================================
 * 1. Design tokens
 * ====================================================================== */
:root {
  /* Brand palette (LOCKED) */
  --brk-purple: #4907d9;
  --brk-purple-700: #3a05ab;
  --brk-purple-900: #240366;
  --brk-green:  #04be68;
  --brk-green-700: #039a54;
  --brk-pink:   #d4537e;
  --brk-star:   #f5a623;

  /* Ink & grays (added a faint warm ink for editorial depth) */
  --brk-ink:    #14161c;   /* slightly deeper than before for crisper text */
  --brk-muted:  #5a5f72;
  --brk-gray:   #8a8f9e;
  --brk-line:   #e7e9f1;
  --brk-line-strong: #d6d9e6;
  --brk-surface:#f6f7fb;
  --brk-surface-2:#eef0f8;
  --brk-bg:     #ffffff;

  /* Tints (atmosphere, used sparingly — NOT big purple-on-white blobs) */
  --tint-purple: rgba(73, 7, 217, 0.06);
  --tint-green:  rgba(4, 190, 104, 0.10);
  --tint-pink:   rgba(212, 83, 126, 0.08);

  /* Semantic */
  --color-text: var(--brk-ink);
  --color-text-muted: var(--brk-muted);
  --color-bg: var(--brk-bg);
  --color-border: var(--brk-line);
  --color-link: var(--brk-purple);
  --color-link-hover: var(--brk-purple-700);

  /* Typography — display = Fraunces (come da mockup approvati + brand identity). */
  --font-heading: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* Alias coerenti coi nomi usati nei mockup (porting CSS senza attrito). */
  --disp: var(--font-heading);
  --sans: var(--font-body);
  --mono: var(--font-mono);

  /* Fluid type scale (clamp = responsive elegance) */
  --fs-xs:   0.78rem;
  --fs-sm:   0.875rem;
  --fs-base: 1.0625rem;                          /* 17px prose */
  --fs-lg:   clamp(1.15rem, 1.05rem + 0.5vw, 1.3rem);
  --fs-xl:   clamp(1.4rem, 1.2rem + 1vw, 1.75rem);
  --fs-2xl:  clamp(1.8rem, 1.4rem + 2vw, 2.5rem);
  --fs-3xl:  clamp(2.3rem, 1.7rem + 3vw, 3.4rem);
  --fs-4xl:  clamp(2.8rem, 2rem + 4.5vw, 4.5rem);

  --lh-tight: 1.08;
  --lh-snug:  1.32;
  --lh-base:  1.72;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px; --sp-10: 128px;

  /* Radius */
  --radius-xs: 6px;
  --radius-button: 10px;
  --radius-card: 16px;
  --radius-pill: 100px;

  /* Layered, color-tinted shadow system (realistic depth) */
  --shadow-xs: 0 1px 2px rgba(20, 22, 28, 0.04);
  --shadow-sm: 0 1px 3px rgba(20, 22, 28, 0.05), 0 1px 2px rgba(20, 22, 28, 0.04);
  --shadow-md: 0 4px 6px rgba(20, 22, 28, 0.04), 0 10px 20px rgba(36, 3, 102, 0.06);
  --shadow-lg: 0 12px 24px rgba(36, 3, 102, 0.10), 0 4px 8px rgba(20, 22, 28, 0.05);
  --shadow-xl: 0 28px 60px rgba(36, 3, 102, 0.16), 0 10px 20px rgba(20, 22, 28, 0.06);
  --shadow-green: 0 8px 22px rgba(4, 190, 104, 0.28);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s;
  --dur: 0.28s;
  --dur-slow: 0.5s;

  /* Layout */
  --container-max: 1240px;
  --prose-max: 720px;

  /* Z-index */
  --z-header: 100; --z-sticky: 200; --z-modal: 9000; --z-popup: 9999;
}

/* =========================================================================
 * 2. Self-hosted fonts (woff2 in task A4b — degrades to system stack)
 * ====================================================================== */
@font-face { font-family:"Inter"; src:url("../fonts/inter-variable.woff2") format("woff2"); font-weight:100 900; font-display:swap; }
@font-face { font-family:"JetBrains Mono"; src:url("../fonts/jetbrains-mono.woff2") format("woff2"); font-weight:400 700; font-display:swap; }
/* Fraunces — display serif (variabile opsz 9..144, wght 300..900), self-hosted OFL. */
@font-face { font-family:"Fraunces"; src:url("../fonts/fraunces-latin.woff2") format("woff2"); font-weight:300 900; font-display:swap; font-style:normal;
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family:"Fraunces"; src:url("../fonts/fraunces-latin-ext.woff2") format("woff2"); font-weight:300 900; font-display:swap; font-style:normal;
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
/* Manrope rimosso: display ora = Fraunces (manrope-variable.woff2 non più caricato). */

/* =========================================================================
 * 3. Reset
 * ====================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "cv05" 1;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, picture, svg, video { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul, ol { padding: 0; }

/* =========================================================================
 * 4. Typography
 * ====================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -0.022em;        /* optical tightening = premium display */
  color: var(--brk-ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-3xl); letter-spacing: -0.03em; }
h2 { font-size: var(--fs-2xl); letter-spacing: -0.025em; }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); letter-spacing: -0.015em; }
p { text-wrap: pretty; }

a { color: var(--color-link); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: var(--color-link-hover); }

/* Tabular figures for financial data (the "fintech" signal) */
.to-num, .tnum, time, .price { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
code, kbd, samp { font-family: var(--font-mono); }

strong, b { font-weight: 700; }

/* =========================================================================
 * 5. Global refinements (the small things that read "designed")
 * ====================================================================== */
::selection { background: var(--brk-purple); color: #fff; text-shadow: none; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brk-purple);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* Refined thin scrollbar (WebKit) + Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--brk-line-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--brk-line-strong); border: 3px solid var(--brk-bg); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--brk-gray); }

/* Animated underline utility for inline links (left-to-right reveal) */
.to-ulink {
  background-image: linear-gradient(var(--brk-purple), var(--brk-purple));
  background-size: 0% 1.5px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size var(--dur) var(--ease-out);
  padding-bottom: 1px;
}
.to-ulink:hover { background-size: 100% 1.5px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================================
 * 6. Accessibility helpers
 * ====================================================================== */
.screen-reader-text {
  border: 0; clip: rect(1px,1px,1px,1px); clip-path: inset(50%);
  height: 1px; width: 1px; margin: -1px; padding: 0; overflow: hidden;
  position: absolute !important; word-wrap: normal !important;
}
.to-skip-link { position: absolute; left: -9999px; }
.to-skip-link:focus {
  position: fixed; top: var(--sp-2); left: var(--sp-2); z-index: var(--z-popup);
  width: auto; height: auto; clip: auto; clip-path: none;
  padding: var(--sp-2) var(--sp-4); background: var(--brk-ink); color: #fff;
  border-radius: var(--radius-button); box-shadow: var(--shadow-lg); font-weight: 600;
}
