/*
  WEBKMT design tokens — Phase 1 unified token system (Step 0)
  ---------------------------------------------------------------------------
  Namespace: --dt-* only. This file is ADDITIVE: it never redefines the
  legacy --wk-* tokens (admin/auth/blog modules read them and are outside
  Phase 1 scope) nor the poster --p-* tokens (retokenised in Step 1).

  Sources:
  - Owner style mission 2026-11-04: Swiss + Bento skeleton, dark-mode
    elevation + futuristic atmosphere, wabi-sabi + bohemian soul.
  - ai-design-skills landing-page-design SKILL.md: B1 type styles,
    B2 spacing scale, B3 radii, B5 hero constraint, B7 motion curve.
  - Owner rulings (docs/PHASE1_STYLE_SYNTHESIS.md):
      C1 brief supersedes -> teal accent family stands; invalid #1B6BSF
         corrected to #1B6B5F; light mode gains AA-safe --dt-accent-text.
      C2 ban stands -> no people in imagery (asset rule, not a token).
      C3 brief supersedes -> glass blur, glow and hairline cell borders
         implemented; taste-meter FAILs (glass, shadow, hairline) defended.
      C4 sanctioned exceptions -> at most two named organic container
         classes; earth-warmth only on pills/avatars/CTA highlights.
  - Navy/dark-blue ban (previous owner instruction) REMAINS: the two banned
    navy hexes (listed in docs/PHASE1_STYLE_SYNTHESIS.md) and all navy or
    dark-blue hues are not part of this system. The teal ban was explicitly
    reversed by ruling C1.

  Contrast audit (WCAG AA, computed 2026-11-04):
    #141414 on #F2EEEE 16.0  | #38E8CE on #111A19 11.5 | #E0A98A on #111A19 8.6
    #F2EEEE on #1B6B5F 5.5   | #2A9D8C on #111A19 5.3  | #D4A187 on #F2EEEE 2.0
    Semantic inks: success #1B6B5F 6.2 | warning #8A5B00 5.7 | danger #B42318 6.4 on #FCFCFB;
    dark equivalents #5CEAD6, #FEC84B, #FDA29B each exceed 9:1 on #111A19.
    -> #D4A187 (light earth-warmth) is decorative fills/borders ONLY, never text.
    -> #269685 on light bg is 3.15:1: large text / UI fills only; use
       --dt-accent-text for body-size text and button ink needs a light
       foreground on --dt-accent-deep surfaces.
*/

/* --- New self-hosted OFL faces (Google Fonts repo via GitHub API,
       instanced to static woff2 2026-11-04; licence: assets/fonts/OFL-manrope.txt).
       Manrope 400/700 and Cairo 800/900 faces are declared in poster.css. --- */
@font-face { font-family: "Manrope"; src: url("../assets/fonts/manrope-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("../assets/fonts/manrope-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("../assets/fonts/cairo-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ==========================================================================
   1. Colour tokens — dual mode
   ========================================================================== */
:root {
  /* Light mode (mission palette) */
  --dt-bg-primary: #F2EEEE;          /* warm textured off-white canvas */
  --dt-bg-surface: #FCFCFB;          /* raised card paper */
  --dt-bg-sunken: #E9E4E1;           /* recessed field */
  --dt-accent-primary: #269685;      /* deep rich teal — anchors, fills, large text */
  --dt-accent-bright: #38E8CE;       /* electric mint — active states, glows */
  --dt-accent-muted: #38C7B1;        /* balanced secondary teal */
  --dt-accent-deep: #1B6B5F;         /* AA fix: teal deep enough for light-ink fills */
  --dt-accent-text: #1B6B5F;         /* AA-safe teal for body-size text on light bg (5.5:1) */
  --dt-earth-warmth: #D4A187;        /* bohemian terracotta — decorative fills only (2.0:1) */
  --dt-ink: #141414;                 /* body ink (16.0:1 on bg) */
  --dt-ink-muted: #5A5A5A;           /* secondary ink (7.4:1 on bg) */
  --dt-ink-on-accent: #FFFFFF;       /* ink on --dt-accent-deep surfaces (5.5:1) */
  --dt-ink-on-bright: #0F1312;       /* ink on --dt-accent-bright (12.1:1) */
  --dt-ink-success: #1B6B5F;         /* semantic success ink on light surfaces (6.2:1) */
  --dt-ink-warning: #8A5B00;         /* semantic warning ink on light surfaces (5.7:1) */
  --dt-ink-danger: #B42318;          /* semantic danger ink on light surfaces (6.4:1) */
  --dt-status-success-bg: #E7F2EE;   /* semantic status surface; paired with success ink */
  --dt-status-warning-bg: #FBF2D9;   /* semantic status surface; paired with warning ink */
  --dt-status-danger-bg: #FBEAE8;    /* semantic status surface; paired with danger ink */
  --dt-status-warning-fill: #8A5B00; /* solid warning fill for score/status badges */
  --dt-status-danger-fill: #B42318;  /* solid danger fill for score/status badges */
  --dt-ink-on-status: #FFFFFF;       /* readable foreground on semantic solid fills */

  /* Elevation + hairlines (C3) */
  --dt-elev-1: rgba(252, 252, 251, 0.66);      /* elevated glass over light canvas */
  --dt-elev-2: rgba(252, 252, 251, 0.86);      /* floating glass */
  --dt-hairline: rgba(56, 199, 177, 0.32);     /* razor cell border in muted accent */
  --dt-hairline-strong: rgba(38, 150, 133, 0.45);
  --dt-glow: 0 10px 32px -8px rgba(38, 150, 133, 0.35);
  --dt-glow-bright: 0 0 24px rgba(56, 232, 206, 0.28);
  --dt-shadow-float: 0 18px 44px -18px rgba(20, 20, 20, 0.35);
  /* Poster slab: obsidian field used as a dark plate on light pages */
  --dt-slab: #111A19;
  --dt-slab-ink: #EEF2F1;
  --dt-focus-ring: #1B6B5F;

  /* Semantic aliases kept mode-independent in name only */
  --dt-radius-none: 0px;
  --dt-radius-sm: 2px;
  --dt-radius-md: 6px;
  --dt-radius-lg: 8px;
  --dt-radius-xl: 12px;
  --dt-radius-2xl: 16px;
  --dt-radius-3xl: 24px;
  --dt-radius-full: 9999px;

  /* B2 spacing scale — the ONLY spacing values allowed (Spacing-0..900) */
  --dt-space-0: 0px;
  --dt-space-50: 2px;
  --dt-space-100: 4px;
  --dt-space-200: 8px;
  --dt-space-300: 12px;
  --dt-space-400: 16px;
  --dt-space-500: 24px;
  --dt-space-600: 32px;
  --dt-space-700: 40px;
  --dt-space-800: 48px;
  --dt-space-850: 64px;
  --dt-space-875: 80px;
  --dt-space-900: 96px;

  /* B7 motion */
  --dt-ease-base: cubic-bezier(0.22, 1, 0.36, 1);
  --dt-duration-base: 500ms;
  --dt-duration-hover: 300ms;   /* hover colour/opacity */
  --dt-duration-min: 200ms;     /* never below this */
  --dt-reveal-rise: 32px;       /* scroll reveal distance */
  --dt-reveal-duration: 700ms;  /* 600–800ms, fires once */
  --dt-menu-stagger: 60ms;      /* link rise stagger, total cap 400ms */

  /* Type families: ONE Latin face per B1 (Manrope); Arabic exception
     documented — Cairo (display) + IBM Plex Sans Arabic (text). */
  --dt-font-latin: "Manrope", sans-serif;
  --dt-font-arabic-display: "Cairo", "Manrope", sans-serif;
  --dt-font-arabic-text: "IBM Plex Sans Arabic", "Manrope", sans-serif;
}

[data-theme="dark"] {
  /* Dark mode (mission palette; C1: obsidian-teal canvas stands — documented
     deviation from framework B4 neutral dark list, owner prompt wins) */
  --dt-bg-primary: #111A19;          /* deep obsidian-teal canvas */
  --dt-bg-surface: #16211F;          /* tier 2 solid fallback */
  --dt-bg-sunken: #0C1413;           /* recessed field */
  --dt-accent-primary: #1B6B5F;      /* deep structural teal (corrected from invalid #1B6BSF) */
  --dt-accent-bright: #5CEAD6;       /* luminous cyan-mint glow (11.2:1 on canvas) */
  --dt-accent-muted: #2A9D8C;        /* mid-tier teal (5.3:1 on canvas) */
  --dt-accent-deep: #14544B;         /* fill variant */
  --dt-accent-text: #5CEAD6;         /* body-size teal text in dark mode */
  --dt-earth-warmth: #E0A98A;        /* soft terracotta (8.6:1 on canvas — text-safe here) */
  --dt-ink: #EEF2F1;                 /* body ink */
  --dt-ink-muted: #A9B6B3;           /* secondary ink */
  --dt-ink-on-accent: #EEF2F1;
  --dt-ink-on-bright: #0F1312;       /* dark ink on luminous mint (12.1:1) */
  --dt-ink-success: #5CEAD6;         /* semantic success ink on dark surfaces */
  --dt-ink-warning: #FEC84B;         /* semantic warning ink on dark surfaces */
  --dt-ink-danger: #FDA29B;          /* semantic danger ink on dark surfaces */
  --dt-status-success-bg: #173A34;
  --dt-status-warning-bg: #3B331E;
  --dt-status-danger-bg: #432927;
  --dt-status-warning-fill: #6B4B08;
  --dt-status-danger-fill: #7B2B2B;
  --dt-ink-on-status: #FFFFFF;

  --dt-elev-1: rgba(22, 33, 31, 0.55);   /* elevated glass over dark canvas */
  --dt-elev-2: rgba(28, 42, 40, 0.72);   /* floating glass */
  --dt-hairline: rgba(92, 234, 214, 0.18);
  --dt-hairline-strong: rgba(92, 234, 214, 0.34);
  --dt-glow: 0 10px 32px -8px rgba(92, 234, 214, 0.18);
  --dt-glow-bright: 0 0 28px rgba(92, 234, 214, 0.24);
  --dt-shadow-float: 0 18px 44px -18px rgba(0, 0, 0, 0.65);
  --dt-slab: #16211F;            /* slab rises one tier above the canvas */
  --dt-slab-ink: #EEF2F1;
  --dt-focus-ring: #5CEAD6;
}

/* ==========================================================================
   2. B1 named text styles — Tailwind scale, snap down, one definition each
   Sizes: 12/14/16/18/20/24/30/36/48/60. No italics anywhere (B1).
   ========================================================================== */
.heading-1, .heading-2, .heading-3,
.heading-4, .heading-5, .heading-6,
.title-1, .title-2, .title-3, .title-4, .title-5 {
  font-family: var(--dt-font-latin);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}
:lang(ar) .heading-1, :lang(ar) .heading-2, :lang(ar) .heading-3,
:lang(ar) .heading-4, :lang(ar) .heading-5, :lang(ar) .heading-6,
:lang(ar) .title-1, :lang(ar) .title-2, :lang(ar) .title-3,
:lang(ar) .title-4, :lang(ar) .title-5,
[dir="rtl"] .heading-1, [dir="rtl"] .heading-2, [dir="rtl"] .heading-3,
[dir="rtl"] .heading-4, [dir="rtl"] .heading-5, [dir="rtl"] .heading-6 {
  font-family: var(--dt-font-arabic-display);
  font-weight: 700;
  letter-spacing: 0;
}

.heading-1 { font-size: 60px; line-height: 60px; }   /* text-6xl 60/60 Semibold */
.heading-2 { font-size: 48px; line-height: 48px; }
.heading-3 { font-size: 36px; line-height: 40px; }
.heading-4 { font-size: 30px; line-height: 36px; }
.heading-5 { font-size: 24px; line-height: 32px; }
.heading-6 { font-size: 20px; line-height: 28px; }

.title-1 { font-size: 24px; line-height: 32px; font-weight: 500; }
.title-2 { font-size: 20px; line-height: 28px; font-weight: 500; }
.title-3 { font-size: 18px; line-height: 28px; font-weight: 500; }
.title-4 { font-size: 16px; line-height: 24px; font-weight: 500; }
.title-5 { font-size: 14px; line-height: 20px; font-weight: 500; }

.body-1, .body-2, .body-3, .body-4, .body-5, .body-6 {
  font-family: var(--dt-font-latin);
  font-weight: 400;
  text-wrap: pretty;
  margin: 0;
}
:lang(ar) .body-1, :lang(ar) .body-2, :lang(ar) .body-3,
:lang(ar) .body-4, :lang(ar) .body-5, :lang(ar) .body-6,
[dir="rtl"] .body-1, [dir="rtl"] .body-2, [dir="rtl"] .body-3,
[dir="rtl"] .body-4, [dir="rtl"] .body-5, [dir="rtl"] .body-6 {
  font-family: var(--dt-font-arabic-text);
}
.body-1 { font-size: 20px; line-height: 32px; }
.body-2 { font-size: 18px; line-height: 28px; }
.body-3 { font-size: 16px; line-height: 24px; }
.body-4 { font-size: 14px; line-height: 20px; }
.body-5 { font-size: 12px; line-height: 16px; }
.body-6 { font-size: 14px; line-height: 20px; font-weight: 500; }

.button-lg, .button-md, .button-sm, .button-xsm {
  font-family: var(--dt-font-latin);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--dt-space-200);
  padding: var(--dt-space-200) var(--dt-space-300);  /* B2 main buttons: 8px / 12px */
  border-radius: var(--dt-radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--dt-duration-hover) var(--dt-ease-base),
              color var(--dt-duration-hover) var(--dt-ease-base),
              opacity var(--dt-duration-hover) var(--dt-ease-base),
              transform var(--dt-duration-hover) var(--dt-ease-base);
}
.button-lg  { font-size: 18px; line-height: 28px; }
.button-md  { font-size: 16px; line-height: 24px; }
.button-sm  { font-size: 14px; line-height: 20px; padding: var(--dt-space-200) var(--dt-space-300); }
.button-xsm { font-size: 12px; line-height: 16px; padding: var(--dt-space-100) var(--dt-space-200); }

.caption-1, .caption-2, .caption-3, .caption-4, .caption-5 {
  font-family: var(--dt-font-latin);
  font-size: 12px;
  line-height: 16px;
  margin: 0;
}
.caption-1 { font-size: 14px; line-height: 20px; color: var(--dt-ink-muted); }
.caption-2 { color: var(--dt-ink-muted); }
.caption-3 { font-weight: 500; }
/* Futuristic micro-readouts (B: crosshairs/coordinates live here, >=12px) */
.caption-4 {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dt-accent-text);
  font-variant-numeric: tabular-nums;
}
.caption-5 {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dt-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Responsive snap-DOWN steps (all values stay on the Tailwind scale) */
@media (max-width: 1024px) {
  .heading-1 { font-size: 48px; line-height: 48px; }
  .heading-2 { font-size: 36px; line-height: 40px; }
  .heading-3 { font-size: 30px; line-height: 36px; }
}
@media (max-width: 640px) {
  .heading-1 { font-size: 36px; line-height: 40px; }
  .heading-2 { font-size: 30px; line-height: 36px; }
  .heading-3 { font-size: 24px; line-height: 32px; }
  .heading-4 { font-size: 24px; line-height: 32px; }
  .body-1 { font-size: 18px; line-height: 28px; }
}

/* ==========================================================================
   3. Swiss grid + Bento containers (layout skeleton)
   ========================================================================== */
.dt-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--dt-space-400);
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--dt-space-400);
}
@media (min-width: 768px) {
  .dt-grid { gap: var(--dt-space-500); padding-inline: var(--dt-space-600); }
}

/* Bento: modular cells, varying spans, razor hairline separation (C3) */
.dt-bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--dt-space-400);           /* gap < 32 -> nested radius = outer - gap */
}
@media (min-width: 768px) {
  .dt-bento { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--dt-space-400); }
}
.dt-bento-cell {
  border: 1px solid var(--dt-hairline);   /* full-perimeter precision border */
  border-radius: var(--dt-radius-xl);     /* outer radius 12px */
  background: var(--dt-elev-1);
  padding: var(--dt-space-500);
  position: relative;
  min-width: 0;
}
.dt-bento-cell .dt-bento-cell { border-radius: 0; } /* nested: 12 - 16 < 2 -> sharp */
.dt-span-2 { grid-column: span 2; }
.dt-span-4 { grid-column: span 2; }      /* mobile: 2-col max */
.dt-row-2 { grid-row: span 2; }
@media (min-width: 768px) {
  .dt-span-3 { grid-column: span 3; }
  .dt-span-4 { grid-column: span 4; }
}
@media (max-width: 480px) {
  .dt-bento { grid-template-columns: 1fr; }
  .dt-span-2, .dt-span-4 { grid-column: span 1; }
  .dt-row-2 { grid-row: span 1; }
}

/* ==========================================================================
   4. Elevation tiers (dark-mode elevation + futuristic, C3 brief supersedes)
   Tier 1 base = --dt-bg-primary. Tier 2 elevated = glass blur 12px.
   Tier 3 floating = glass + accent glow, levitating.
   ========================================================================== */
.dt-elevated {
  background: var(--dt-elev-1);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--dt-hairline);
}
.dt-floating {
  background: var(--dt-elev-2);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--dt-hairline-strong);
  box-shadow: var(--dt-glow), var(--dt-shadow-float);
}
.dt-glow-accent { box-shadow: var(--dt-glow-bright); }

/* Glowing status badge (futuristic micro-detail) */
.dt-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--dt-space-200);
  padding: var(--dt-space-100) var(--dt-space-300);
  border-radius: var(--dt-radius-full);
  border: 1px solid var(--dt-hairline-strong);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--dt-accent-text);
  font-variant-numeric: tabular-nums;
}
.dt-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--dt-radius-full);
  background: var(--dt-accent-bright);
  box-shadow: var(--dt-glow-bright);
  flex: none;
}
/* Earth-warmth badge (C4: human-centric elements only) */
.dt-badge-warm {
  color: var(--dt-earth-warmth);
  border-color: color-mix(in srgb, var(--dt-earth-warmth) 40%, transparent);
}
[data-theme="light"] .dt-badge-warm,
:root:not([data-theme="dark"]) .dt-badge-warm {
  color: var(--dt-ink);            /* light earth is 2.0:1 — never carries text */
}
.dt-badge-warm::before { background: var(--dt-earth-warmth); box-shadow: none; }

/* Crosshair alignment markers at card corners (+), decorative SVG */
.dt-crosshair::before,
.dt-crosshair::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 0v12M0 6h12' stroke='%232A9D8C' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  opacity: 0.8;
}
.dt-crosshair::before { top: -6px; inset-inline-start: -6px; }
.dt-crosshair::after { bottom: -6px; inset-inline-end: -6px; }

/* Wabi-sabi grain overlay — raw tactile texture, breaks sterility */
.dt-grain { position: relative; }
.dt-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.5;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
}

/* ==========================================================================
   5. Organic exceptions (C4: exactly two sanctioned classes)
   ========================================================================== */
.dt-organic-1 { border-radius: 25px 18px 30px 20px; }
.dt-organic-2 { border-radius: 18px 30px 20px 25px; }

/* ==========================================================================
   6. Interaction states (B7/B9) — motion on transform/opacity only
   ========================================================================== */
.dt-pressable:active { transform: scale(0.98); }
.dt-focusable:focus-visible {
  outline: 2px solid var(--dt-focus-ring);
  outline-offset: 2px;
  border-radius: var(--dt-radius-sm);
}
::selection {
  background: color-mix(in srgb, var(--dt-accent-bright) 45%, transparent);
  color: var(--dt-ink);
}

/* Scroll-reveal base (B7: rise 32px, 700ms, fires once via IO in poster.js) */
.dt-reveal {
  opacity: 0;
  transform: translateY(var(--dt-reveal-rise));
  transition: opacity var(--dt-reveal-duration) var(--dt-ease-base),
              transform var(--dt-reveal-duration) var(--dt-ease-base);
  will-change: opacity, transform;
}
.dt-reveal.dt-in {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .dt-reveal { opacity: 1; transform: none; transition: none; }
  .dt-pressable:active { transform: none; }
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}

/* ==========================================================================
   7. Bento affordance helpers (scannability)
   ========================================================================== */
.dt-cell-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--dt-space-300);
  width: 100%;
  text-align: start;
  background: transparent;
  border: 1px solid var(--dt-hairline-strong);
  border-radius: var(--dt-radius-lg);   /* nested inside 12px cell, gap 16 -> sharp-ish; kept 8 for tap clarity */
  padding: var(--dt-space-300) var(--dt-space-400);
  color: var(--dt-ink);
  cursor: pointer;
  transition: transform var(--dt-duration-hover) var(--dt-ease-base),
              border-color var(--dt-duration-hover) var(--dt-ease-base),
              box-shadow var(--dt-duration-hover) var(--dt-ease-base);
}
.dt-cell-action:hover {
  border-color: var(--dt-accent-muted);
  box-shadow: var(--dt-glow-bright);
}
.dt-cell-action:active { transform: scale(0.98); }

/* Coordinate-tracking micro-readout row (futuristic detail) */
.dt-readout {
  display: flex;
  justify-content: space-between;
  gap: var(--dt-space-400);
  font-size: 12px;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dt-ink-muted);
  font-variant-numeric: tabular-nums;
}
