/* CENAMAD · design tokens (single source).
 *
 * Every colour, type, space, radius, shadow, motion and focus value used by the app lives here.
 * Two visual directions re-skin the same roles:
 *   [data-visual="interactivo"]  warm workshop table (Taller vivo)
 *   [data-visual="formal"]       technical memoria (Memoria técnica)
 * The attribute is set on the workspace root and on <html> while a project is open.
 * Pages outside a project (library, review sheet, admin) use the neutral :root values.
 *
 * Contrast (WCAG 2.2, measured on the paired background): body text ≥ 4.5:1, focus ring ≥ 3:1.
 *
 * Phase 4: the shell follows the UC Kit Digital (madera.uc.cl / CIM UC). Roboto and Roboto Slab are served from
 * public/fonts (no runtime third-party request); the UC palette and fonts are exposed as --uc-* tokens that every
 * stream may use, and the neutral :root roles below are mapped onto them.
 */

/* ------------------------------------------------------------------ fonts (local, Apache-2.0)
 * Roboto 300/400/500/700 and Roboto Slab 400/700, latin + latin-ext, woff2. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("../fonts/roboto-300.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/roboto-400.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/roboto-500.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/roboto-700.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto Slab";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/roboto-slab-400.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto Slab";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/roboto-slab-700.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* ---- UC Kit Digital (shared with every stream) ---- */
  --uc-azul: #0176de; /* primary */
  --uc-azul-2: #173f8a; /* headings, nav, links on light */
  --uc-azul-osc: #03122e; /* top strip, footer */
  --uc-amarillo: #fec60d; /* decoration only; never text on light */
  --uc-amarillo-osc: #e3ae00;
  --uc-gris-a: #eaeaea;
  --uc-gris-b: #f0f0f0;
  --uc-gris-c: #f6f6f6;
  --uc-gris-txt: #707070; /* 5.2:1 on white, 4.8:1 on #f6f6f6 */
  --uc-font: "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --uc-font-slab: "Roboto Slab", Georgia, "Times New Roman", serif;
  --uc-sombra: 0 0 8px rgb(136 136 136 / 0.18);
  --uc-sombra-alta: 0 10px 24px rgb(3 18 46 / 0.18);
  --uc-topbar-h: 44px;

  /* ---- type ---- */
  --f-display: var(--uc-font-slab);
  --f-text: var(--uc-font);
  --f-mono: Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --f-heading: var(--f-text);
  --fw-heading: 700;
  --ls-heading: -0.01em;

  --fs-xs: 12px; /* floor: nothing smaller */
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-base: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: clamp(26px, 2.4vw + 14px, 36px);
  --fs-4xl: clamp(30px, 3.6vw + 14px, 52px);
  --fs-figure: clamp(34px, 4vw + 16px, 64px); /* large result figures */
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-base: 1.5;

  /* ---- space (4 px grid) ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 48px;
  --sp-9: 64px;
  --gutter: 16px; /* page side gutter on phones */
  --page-max: 1440px;

  /* ---- radius ---- */
  --r-0: 0;
  --r-1: 2px;
  --r-2: 4px; /* UC Kit Digital: buttons, cards, inputs */
  --r-3: 8px;
  --r-4: 12px;
  --r-pill: 999px;

  /* ---- elevation (UC Kit Digital uses one soft grey shadow; 2 and 3 extend it) ---- */
  --sh-1: 0 0 8px rgb(136 136 136 / 0.18);
  --sh-2: 0 6px 18px rgb(3 18 46 / 0.12), 0 0 8px rgb(136 136 136 / 0.18);
  --sh-3: 0 18px 44px rgb(3 18 46 / 0.22), 0 2px 6px rgb(3 18 46 / 0.1);

  /* ---- motion (150–300 ms, disabled with reduced motion) ---- */
  --t-fast: 150ms;
  --t-base: 220ms;
  --t-slow: 300ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* ---- targets ---- */
  --tap: 40px;
  --tap-min: 24px;

  /* ---- neutral colour roles (shell, library, review sheet, admin) ---- */
  --c-bg: #f6f6f6;
  --c-surface: #ffffff;
  --c-surface-2: #fafafa;
  --c-sunken: #f0f0f0;
  --c-ink: #03122e; /* 17.8:1 on white */
  --c-ink-2: #173f8a; /* 9.8:1 on white */
  --c-muted: #6b6b6b; /* 5.4:1 on white, 5.0:1 on --c-bg */
  --c-line: #eaeaea;
  --c-line-strong: #8a8a8a; /* 3.7:1 on white: control borders */
  --c-accent: #0176de; /* primary action (white text: 4.5:1) */
  --c-accent-ink: #ffffff;
  --c-accent-hover: #173f8a;
  --c-accent-soft: #e7f1fc;
  --c-accent-text: #0a5bb5; /* accent used as text on light: 6.0:1 on white */
  --c-highlight: #fec60d; /* decorative accent (fills ≥ 3:1, never body text) */
  --c-highlight-text: #7a4d0e; /* 7.3:1 */
  --c-warn: #7a4d0e; /* pending / prevalidation text (6.4:1 on soft) */
  --c-warn-soft: #fdf0d5;
  --c-warn-line: #d9b56a;
  --c-danger: #9b2c22;
  --c-danger-soft: #fbe9e6;
  --c-danger-line: #e0a69e;
  --c-info: #2e4a5a;
  --c-info-soft: #e7eef2;
  --c-info-line: #b4c6d1;
  --c-stale: #7a4d0e;
  --c-stale-soft: #fff4dc;
  --c-ok: #1f5c3f;
  --c-ok-soft: #e1f0e6;
  --c-focus: #0c4da2; /* 7.3:1 on white, ≥ 3:1 on every light surface used */
  --c-focus-dark: var(--uc-amarillo); /* focus on the dark-blue strip / footer (11:1) */
  --c-focus-halo: rgb(255 255 255 / 0.9);
  --c-overlay: rgb(3 18 46 / 0.55);

  /* ---- physics colour roles (renderers; meaning, not decoration) ---- */
  --c-interior: #b5651d; /* warm side */
  --c-interior-soft: #f6e3cc;
  --c-exterior: #3f5f70; /* cool side */
  --c-exterior-soft: #dde7ec;
  --c-temp: #b4471f; /* θ line */
  --c-pv: #2c5d8a; /* vapour pressure */
  --c-psat: #6b4f9a; /* saturation pressure */
  --c-condensa: #1b6f8a; /* gc > 0 marker */

  /* ---- legacy aliases (admin.css, revision.css, biblioteca.css) ---- */
  --ink: var(--c-ink);
  --paper: var(--c-bg);
  --pine: var(--c-accent);
  --line: var(--c-line);
  --muted: var(--c-muted);
  --pale: var(--c-accent-soft);
  --tan: var(--c-highlight);
  --amber: var(--c-warn);
}

@media (pointer: coarse) {
  :root {
    --tap: 44px;
    --tap-min: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --t-fast: 0ms;
    --t-base: 0ms;
    --t-slow: 0ms;
  }
}

/* ------------------------------------------------------------------ Interactivo · Taller vivo
 * UC Kit Digital chrome (owner review, 29 nov: «the whole site has the UC design system»): white UC cards on the
 * UC light grey, UC blue for primary actions, links and focus, UC dark blue ink and the UC yellow as the short
 * heading rule — the same system the shell uses (:root --uc-*). The calculator keeps its soul in the drawings:
 * timber materials, the warm/cool interior–exterior wash, the temperature ramp and the vapour colours (physics
 * roles below are inherited unchanged from :root). Measured: --c-ink on white 18:1; --c-muted #5f5f5f 6.5:1 on
 * white, 6.0:1 on #f6f6f6; white on --uc-azul 4.5:1 (large/bold button text only; small blue text and pressed
 * toggles use --uc-azul-2, 10:1); the --uc-azul focus ring 4.2:1 on #f6f6f6. Literal fallbacks keep the block
 * standing on its own if the shell's UC tokens are ever not loaded. */
[data-visual="interactivo"] {
  --f-heading: var(--uc-font-slab, "Roboto Slab", Georgia, serif);
  --f-display: var(--uc-font-slab, "Roboto Slab", Georgia, serif);
  --f-text: var(--uc-font, "Roboto", system-ui, sans-serif);
  --fw-heading: 700;
  --ls-heading: -0.004em;

  --c-bg: var(--uc-gris-c, #f6f6f6); /* page: UC lightgray-c */
  --c-surface: #ffffff; /* UC card */
  --c-surface-2: #fafafa;
  --c-sunken: var(--uc-gris-b, #f0f0f0);
  --c-ink: var(--uc-azul-osc, #03122e);
  --c-ink-2: var(--uc-azul-2, #173f8a);
  --c-muted: #5f5f5f;
  --c-line: var(--uc-gris-a, #eaeaea);
  --c-line-strong: #8a8a8a; /* control borders, 3.5:1 on white */
  --c-accent: var(--uc-azul, #0176de); /* primary action */
  --c-accent-ink: #ffffff;
  --c-accent-hover: var(--uc-azul-2, #173f8a);
  --c-accent-soft: #e7f1fc;
  --c-accent-text: var(--uc-azul-2, #173f8a); /* links and small blue text */
  --c-highlight: var(--uc-amarillo, #fec60d); /* the heading rule, never text */
  --c-highlight-text: #6b4e00;
  --c-oak: #c8a27a; /* timber, drawings only */
  --c-oak-soft: #efe2cf;
  --c-warn: #7a4d0e;
  --c-warn-soft: #fdf0d5;
  --c-stale-soft: #fff4dc;
  --c-focus: var(--uc-azul, #0176de);

  --r-card: var(--r-2, 4px);
  --sh-card: var(--uc-sombra, 0 0 8px rgb(136 136 136 / 0.18));
}

/* ------------------------------------------------------------------ Formal · Memoria técnica
 * «The engineering plate», drawn with the UC Kit Digital (madera.uc.cl) the shell already uses: the same desk
 * (#F6F6F6), white plates and cards with UC's 4 px radius, #EAEAEA hairline and soft grey shadow, Roboto for text
 * and UI, Roboto Slab for document and section titles, UC blue (#0176DE) for interaction fills, rails and focus,
 * #173F8A for every small blue text (links, numbers, tabs), UC dark blue (#03122E) as the document ink and the UC
 * yellow only as the short heading rule. Formal therefore inherits the shell's :root roles and overrides only
 * what is its own: the slab headings and the near-monochrome physics roles of a technical drawing.
 * Green survives only as a state mark (a «completo» dot, when a state is shown at all) — never an engine figure. */
[data-visual="formal"] {
  /* UC Kit Digital: the global --uc-* tokens are the source; the literals are only fallbacks. */
  --f-text: var(--uc-font, "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif);
  --f-heading: var(--uc-font-slab, "Roboto Slab", Georgia, "Times New Roman", serif);
  --fw-heading: 700;
  --ls-heading: -0.004em; /* Roboto Slab needs almost no tracking correction */

  --c-bg: var(--uc-gris-c, #f6f6f6); /* the shell's desk */
  --c-surface: #ffffff; /* plate */
  --c-surface-2: var(--uc-gris-c, #f6f6f6);
  --c-sunken: var(--uc-gris-b, #f0f0f0);
  --c-ink: var(--uc-azul-osc, #03122e); /* the document ink, 17.8:1 on the plate */
  --c-ink-2: #2b3b55; /* secondary ink (row heads, drawing linework), 11:1 — small blue text uses --c-accent-text */
  --c-muted: #6b6b6b; /* UC grey text, 5.4:1 on white, 4.9:1 on #f0f0f0 */
  --c-line: var(--uc-gris-a, #eaeaea);
  --c-line-strong: #8a8a8a; /* control boundary, ≥ 3:1 on the plate and the desk */
  --c-accent: var(--uc-azul, #0176de); /* fills, rails, focus (white text on it 4.5:1) */
  --c-accent-ink: #ffffff;
  --c-accent-hover: var(--uc-azul-2, #173f8a);
  --c-accent-soft: #e7f1fc;
  --c-accent-text: var(--uc-azul-2, #173f8a); /* UC blue as text: always the darker blue */
  --c-highlight: var(--uc-amarillo, #fec60d); /* heading rule and marks only, never text */
  --c-highlight-text: #6b4e00;
  --c-focus: var(--uc-azul, #0176de);

  /* Physics roles: the Glaser diagram stays near-monochrome on the UC dark blue, the way a plate is drawn. */
  --c-temp: #03122e;
  --c-pv: #173f8a;
  --c-psat: #03122e;
  --c-condensa: #0176de;

  /* UC Kit Digital shapes: 4 px everywhere a control, card or plate has a corner; one soft grey elevation. */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 4px;
  --r-4: 4px;
  --r-card: 4px;
  --sh-1: var(--uc-sombra, 0 0 8px rgb(136 136 136 / 0.18));
  --sh-2: var(--uc-sombra, 0 0 8px rgb(136 136 136 / 0.18));
  --sh-3: 0 18px 44px rgb(3 18 46 / 0.22), 0 2px 6px rgb(3 18 46 / 0.1);
  --sh-card: var(--sh-1);
}
