/* ============================================================================
   Castells.App / Troncs — Design Tokens
   rigorós · tècnic · net
   Linear/Notion productivity lane. Data is the protagonist.
   ============================================================================ */

/* ---------- Fonts ---------- */
/* Primary sans: Manrope (variable) — neutral, data-forward, gentle counters.
   Mono: JetBrains Mono — used for codes (castell notation: 3d8, 4d9fm, Pd4). */

@font-face {
  font-family: 'Manrope';
  src: url('fonts/Manrope-VariableFont_wght.ttf') format('truetype-variations'),
       url('fonts/Manrope-VariableFont_wght.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ==========================================================================
     COLORS — neutral tinted palette, fully decoupled from any colla identity.
     Off-whites are very slightly warm-graphite-tinted; graphites are cool-neutral.
     One accent: "signal" — a restrained ink teal, used sparingly.
     ========================================================================== */

  /* Surfaces — warmer off-whites at the top of the stack */
  --surface-0: #fbfbfa;      /* app canvas */
  --surface-1: #f6f6f4;      /* raised panel / sidebar */
  --surface-2: #efefec;      /* hover / selected row */
  --surface-3: #e6e6e2;      /* pressed / heavy selected */

  /* Lines */
  --line-1: #ebebe7;         /* hairline dividers */
  --line-2: #dddcd6;         /* card borders, table rules */
  --line-3: #c7c5bc;         /* focus ring base */

  /* Foreground — graphite ramp */
  --fg-1: #16181c;           /* primary text, numbers */
  --fg-2: #3b3f46;           /* secondary, labels */
  --fg-3: #6a6f78;           /* tertiary, meta */
  --fg-4: #9ea3ad;           /* muted, placeholders */
  --fg-5: #c2c6cd;           /* disabled */

  /* On-inverse (dark surfaces / chips) */
  --on-dark-1: #f5f5f3;
  --on-dark-2: #b9bcc2;

  /* Accent — "signal" ink. Used only for active state, focus, CTAs.
     Not a brand color; never used for chrome. */
  --accent:        #1f5f5b;
  --accent-hover:  #1a504d;
  --accent-press:  #163f3d;
  --accent-soft:   #e6efee;   /* tinted background */
  --accent-line:   #c6d7d5;

  /* Semantics — all muted, never saturated */
  --ok:            #2f6b3f;
  --ok-soft:       #e9efe9;
  --warn:          #8a5a17;
  --warn-soft:     #f5ecd9;
  --danger:        #9a2b2b;
  --danger-soft:   #f2e0e0;
  --info:          #2b5a8a;
  --info-soft:     #e0e9f2;

  /* Data viz — four calibrated neutrals + accent, safe for adjacent bars */
  --data-1: #1f5f5b; /* accent */
  --data-2: #3b3f46; /* graphite */
  --data-3: #7a7e86;
  --data-4: #a7a9ad;
  --data-5: #cfd0d1;

  /* ==========================================================================
     TYPOGRAPHY
     Primary: Inter Tight. Mono: JetBrains Mono.
     Data uses tabular figures (font-variant-numeric: tabular-nums).
     ========================================================================== */
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  /* Sizes — tight, data-friendly. Base 14 (mobile-data density). */
  --text-xs:   11px;   /* meta, row count, timestamp */
  --text-sm:   12px;   /* labels, table headers */
  --text-base: 14px;   /* body */
  --text-md:   16px;   /* emphasized body */
  --text-lg:   18px;   /* screen titles (mobile) */
  --text-xl:   22px;   /* section headers, key numbers */
  --text-2xl:  28px;   /* dashboard big numbers */
  --text-3xl:  40px;   /* hero stat / splash */

  /* Weights — Inter Tight reads heavy; lean 400/500/600 */
  --w-regular:  400;
  --w-medium:   500;
  --w-semi:     600;
  --w-bold:     700;

  /* Line heights */
  --lh-tight:  1.12;
  --lh-snug:   1.28;
  --lh-body:   1.5;

  /* Letter-spacing — Inter Tight takes a hair negative at large sizes */
  --tr-tight:   -0.01em;
  --tr-display: -0.02em;
  --tr-label:    0.02em;     /* all-caps micro-labels */

  /* ==========================================================================
     SPACING — 4px base unit
     ========================================================================== */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* ==========================================================================
     RADII — restrained. No pill buttons. Slightly softened corners only.
     ========================================================================== */
  --radius-0: 0;
  --radius-1: 4px;    /* chips, inputs */
  --radius-2: 6px;    /* buttons, cards */
  --radius-3: 10px;   /* sheets, large surfaces */
  --radius-full: 999px;

  /* ==========================================================================
     ELEVATION — used sparingly. Flat-first; shadows only for floating sheets.
     ========================================================================== */
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(15, 17, 21, 0.04),
              0 0 0 1px rgba(15, 17, 21, 0.04);
  --shadow-2: 0 2px 8px rgba(15, 17, 21, 0.06),
              0 0 0 1px rgba(15, 17, 21, 0.05);
  --shadow-sheet: 0 -8px 24px rgba(15, 17, 21, 0.08),
                  0 0 0 1px rgba(15, 17, 21, 0.04);

  /* ==========================================================================
     MOTION — quick, linear-ish. No bounces, no overshoots.
     ========================================================================== */
  --motion-fast:   120ms cubic-bezier(0.2, 0, 0, 1);
  --motion-med:    180ms cubic-bezier(0.2, 0, 0, 1);
  --motion-slow:   260ms cubic-bezier(0.2, 0, 0, 1);

  /* ==========================================================================
     TABLE DENSITY — role-aware
     ========================================================================== */
  --row-h-dense:   32px;   /* tècnic views */
  --row-h-regular: 40px;   /* mixed */
  --row-h-comfy:   52px;   /* casteller views */
}

/* ---------- Dark mode (secondary: evening assaigs / video screens) ---------- */
:root[data-theme="dark"], .dark {
  --surface-0: #0f1013;
  --surface-1: #16181c;
  --surface-2: #1d2025;
  --surface-3: #262a30;

  --line-1: #22252a;
  --line-2: #2c3037;
  --line-3: #3a3f47;

  --fg-1: #ecedee;
  --fg-2: #b9bcc2;
  --fg-3: #8b8f97;
  --fg-4: #6a6f78;
  --fg-5: #4a4e55;

  --accent:       #5ba6a1;
  --accent-hover: #6fb8b3;
  --accent-press: #4a918d;
  --accent-soft:  #1a2928;
  --accent-line:  #2e4644;

  --ok-soft:     #1b2a1f;
  --warn-soft:   #2a2115;
  --danger-soft: #2a1818;
  --info-soft:   #16222e;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-2: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
}

/* ============================================================================
   SEMANTIC STYLES — use these in components, not raw tokens.
   ============================================================================ */

html, body {
  background: var(--surface-0);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-body);
  font-feature-settings: "ss01", "ss02";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Type scale — semantic */
.t-display {
  font-size: var(--text-3xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-display);
  line-height: var(--lh-tight);
}
.t-h1 {
  font-size: var(--text-2xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-display);
  line-height: var(--lh-tight);
}
.t-h2 {
  font-size: var(--text-xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  line-height: var(--lh-snug);
}
.t-h3 {
  font-size: var(--text-lg);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-tight);
  line-height: var(--lh-snug);
}
.t-body {
  font-size: var(--text-base);
  font-weight: var(--w-regular);
  line-height: var(--lh-body);
}
.t-body-em {
  font-size: var(--text-base);
  font-weight: var(--w-medium);
  line-height: var(--lh-body);
}
.t-label {
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--fg-2);
  letter-spacing: 0;
}
.t-meta {
  font-size: var(--text-xs);
  font-weight: var(--w-regular);
  color: var(--fg-3);
  letter-spacing: 0;
}
.t-micro {
  font-size: 10px;
  font-weight: var(--w-semi);
  color: var(--fg-3);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
}

/* Numerics — use for all data, always */
.t-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "ss01";
}
.t-stat {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-display);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.t-stat-xl {
  font-family: var(--font-sans);
  font-size: var(--text-3xl);
  font-weight: var(--w-semi);
  letter-spacing: var(--tr-display);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Mono — castell notation (3d8, 4d9fm, Pd4), codes, IDs */
.t-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: var(--w-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.t-mono-sm {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--w-medium);
  color: var(--fg-3);
}

/* Selection */
::selection {
  background: var(--accent-soft);
  color: var(--accent-press);
}

/* ============================================================================
   LEGAL PAGES — Privacy + Terms share this layout.
   Long-form reading, measured column, landing aesthetic.
   ============================================================================ */

body.legal {
  margin: 0;
  background: var(--surface-0);
  color: var(--fg-1);
  font: 400 15px/1.65 var(--font-sans);
}

.legal-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(251, 251, 250, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line-1);
}
.legal-nav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.legal-nav a.legal-back {
  font: 500 13px/1 var(--font-mono);
  color: var(--fg-3);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.legal-nav a.legal-back:hover { color: var(--fg-1); }
.legal-nav .legal-wordmark {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.legal-nav .legal-wordmark img {
  width: 24px; height: 24px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--line-2);
}
.legal-nav .legal-wordmark span {
  font: 600 13px/1 var(--font-sans);
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.legal-nav .legal-wordmark .legal-wordmark-dim { color: var(--fg-3); }

.legal-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 72px 32px 96px;
}

.legal-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.legal-eyebrow-line {
  width: 24px; height: 1px; background: var(--fg-3);
}
.legal-eyebrow-label {
  font: 500 10px/1 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-3);
}

.legal-title {
  margin: 0 0 8px;
  font: 600 clamp(32px, 5vw, 44px)/1.05 var(--font-sans);
  letter-spacing: -0.025em;
  color: var(--fg-1);
}
.legal-meta {
  margin: 0 0 48px;
  font: 500 12px/1 var(--font-mono);
  color: var(--fg-3);
  letter-spacing: -0.01em;
}

.legal-main h2 {
  margin: 40px 0 12px;
  font: 600 18px/1.3 var(--font-sans);
  letter-spacing: -0.015em;
  color: var(--fg-1);
}
.legal-main p {
  margin: 0 0 18px;
  color: var(--fg-2);
  text-wrap: pretty;
}
.legal-main p:last-child { margin-bottom: 0; }
.legal-main ul {
  margin: 0 0 20px;
  padding-left: 20px;
  color: var(--fg-2);
}
.legal-main li { margin-bottom: 6px; }
.legal-main a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.legal-main a:hover { color: var(--accent-press); text-decoration-color: var(--accent); }
.legal-main strong { color: var(--fg-1); font-weight: 600; }

.legal-footer {
  border-top: 1px solid var(--line-1);
  padding: 24px 32px;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.legal-footer .legal-footer-meta {
  font: 500 11px/1 var(--font-mono);
  color: var(--fg-4);
  letter-spacing: 0;
}
.legal-footer .legal-footer-links {
  margin-left: auto;
  display: flex;
  gap: 20px;
}
.legal-footer .legal-footer-links a {
  font: 500 12px/1 var(--font-sans);
  color: var(--fg-3);
  text-decoration: none;
}
.legal-footer .legal-footer-links a:hover { color: var(--fg-1); }

@media (max-width: 560px) {
  .legal-nav-inner { padding: 12px 20px; gap: 16px; }
  .legal-main { padding: 40px 20px 64px; }
  .legal-footer { padding: 20px; }
}
