/* FlatMatch Design Tokens & Icon System */
@layer tokens {
  @property --icon-start {
    syntax: "*";
    inherits: false;
  }

  @property --icon-end {
    syntax: "*";
    inherits: false;
  }

  @property --fade-start {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }

  @property --fade-end {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }

  :root {
    color-scheme: light dark;

    /* Typography */
    --font-sans: "Plus Jakarta Sans", "Noto Sans Devanagari", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;

    /* Type scale (max <= 2.5x min for WCAG 1.4.4 resize text) */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: clamp(1.5rem, 1.25rem + 1.2vw, 2.125rem);
    --text-3xl: clamp(1.875rem, 1.4rem + 2.2vw, 3rem);

    /* Core User Palette Tokens (Mocha Brown • Platinum Silver • Pale Lavender) */
    --mocha-brown: #6F4E37;
    --mocha-deep: #523928;
    --mocha-ink: #2B1D14;
    --platinum-silver: #E5E4E2;
    --pale-lavender: #E6E0F0;

    /* Surfaces (Platinum Silver #E5E4E2 + Soft Pale Lavender #E6E0F0) */
    --bg-canvas: #E5E4E2;
    --bg-surface: #FFFFFF;
    --bg-subtle: #E6E0F0;
    --bg-muted: #D8D4DA;
    --bg-elevated: #FFFFFF;

    /* Ink (Roasted Espresso-Mocha derived from #6F4E37) */
    --text-primary: #2B1D14;
    --text-secondary: #4D3627;
    --text-muted: #6F4E37;

    /* Brand Accents: Mocha Brown (#6F4E37) • Platinum Silver (#E5E4E2) • Pale Lavender (#E6E0F0) */
    --brand-primary: #6F4E37;
    --brand-primary-hover: #563C29;
    --brand-primary-soft: #E6E0F0;
    --brand-primary-text: #4F3523;
    --brand-on-primary: #FAF8FC;

    --brand-trust: #5D4A78;
    --brand-trust-hover: #493860;
    --brand-trust-soft: #E6E0F0;
    --brand-trust-text: #43325A;
    --brand-on-trust: #FAF8FC;

    --brand-amber: #7D4E1D;
    --brand-amber-soft: #EFE7EC;
    --brand-amber-border: #B5957E;

    --status-danger: #9B2C2C;
    --status-danger-soft: #F7E8EA;
    --status-success: #2F5D47;
    --status-success-soft: #E4EDE8;

    /* Borders & Rings */
    --border-subtle: #CEC9C7;
    --border-strong: #6F4E37;
    --focus-ring: #5D4A78;
    --accent-color: #6F4E37;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgb(43 29 20 / 0.07), 0 1px 3px rgb(43 29 20 / 0.05);
    --shadow-md: 0 8px 24px -4px rgb(43 29 20 / 0.10), 0 2px 6px -1px rgb(43 29 20 / 0.05);
    --shadow-lg: 0 20px 44px -8px rgb(43 29 20 / 0.18), 0 6px 14px -4px rgb(43 29 20 / 0.07);

    /* Radii & Spacing */
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    --radius-pill: 999px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4.5rem;

    --container-max: 76rem;
    --header-height: 4.5rem;

    /* SVG Icon Tokens (Data URIs) */
    --icon-style-size: 1.1em;
    --icon-style-spacing: 0.42em;
    --icon-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E");
    --icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
    --icon-shield-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l7 3v6c0 4.5-3 8.2-7 9.5-4-1.3-7-5-7-9.5V6l7-3z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
    --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 13 4 4L19 7'/%3E%3C/svg%3E");
    --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2.5 19.5h19L12 3z'/%3E%3Cpath d='M12 9.5v4.5M12 17h.01'/%3E%3C/svg%3E");
    --icon-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 1 1 8 0v4'/%3E%3C/svg%3E");
    --icon-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8.5 8.5 0 0 1-12.5 7.5L3 21l1.5-5.2A8.5 8.5 0 1 1 21 12Z'/%3E%3C/svg%3E");
    --icon-video: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='6' width='14' height='12' rx='2'/%3E%3Cpath d='m16.5 10 5-3v10l-5-3v-4z'/%3E%3C/svg%3E");
    --icon-coffee: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 8h1.5a3 3 0 0 1 0 6H17'/%3E%3Cpath d='M4 8h13v7a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z'/%3E%3Cpath d='M8 3v2M12 3v2'/%3E%3C/svg%3E");
    --icon-spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 2.3 5.7L20 11l-5.7 2.3L12 19l-2.3-5.7L4 11l5.7-2.3L12 3Z'/%3E%3C/svg%3E");
    --icon-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5.5v-6h-5v6H4a1 1 0 0 1-1-1v-9.5Z'/%3E%3C/svg%3E");
    --icon-flag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4m0 0h11l-1.5 4L16 12H5'/%3E%3C/svg%3E");
    --icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
    --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --icon-sun-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
  }

  /* Dark / Editorial Mocha Mode: Mocha Brown (#6F4E37) • Pale Lavender (#E6E0F0) • Platinum Silver (#E5E4E2) */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg-canvas: #6F4E37;
      --bg-surface: #553B29;
      --bg-subtle: #483122;
      --bg-muted: #805C43;
      --bg-elevated: #5F422F;

      --text-primary: #E6E0F0;
      --text-secondary: #E5E4E2;
      --text-muted: #DDD9DC;

      --brand-primary: #E6E0F0;
      --brand-primary-hover: #FFFFFF;
      --brand-primary-soft: #483122;
      --brand-primary-text: #E6E0F0;
      --brand-on-primary: #2B1D14;

      --brand-trust: #E5E4E2;
      --brand-trust-hover: #FFFFFF;
      --brand-trust-soft: #422F3C;
      --brand-trust-text: #E6E0F0;
      --brand-on-trust: #2B1D14;

      --brand-amber: #E6E0F0;
      --brand-amber-soft: #4C3424;
      --brand-amber-border: #E5E4E2;

      --status-danger: #F7D4D8;
      --status-danger-soft: #4F262A;
      --status-success: #D7EEDF;
      --status-success-soft: #2A4032;

      --border-subtle: rgba(229, 228, 226, 0.28);
      --border-strong: #E6E0F0;
      --focus-ring: #E6E0F0;
      --accent-color: #E6E0F0;

      --shadow-sm: 0 2px 6px rgb(24 14 8 / 0.35);
      --shadow-md: 0 10px 26px -4px rgb(24 14 8 / 0.45);
      --shadow-lg: 0 24px 48px -8px rgb(24 14 8 / 0.62);
    }
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg-canvas: #6F4E37;
    --bg-surface: #553B29;
    --bg-subtle: #483122;
    --bg-muted: #805C43;
    --bg-elevated: #5F422F;

    --text-primary: #E6E0F0;
    --text-secondary: #E5E4E2;
    --text-muted: #DDD9DC;

    --brand-primary: #E6E0F0;
    --brand-primary-hover: #FFFFFF;
    --brand-primary-soft: #483122;
    --brand-primary-text: #E6E0F0;
    --brand-on-primary: #2B1D14;

    --brand-trust: #E5E4E2;
    --brand-trust-hover: #FFFFFF;
    --brand-trust-soft: #422F3C;
    --brand-trust-text: #E6E0F0;
    --brand-on-trust: #2B1D14;

    --brand-amber: #E6E0F0;
    --brand-amber-soft: #4C3424;
    --brand-amber-border: #E5E4E2;

    --status-danger: #F7D4D8;
    --status-danger-soft: #4F262A;
    --status-success: #D7EEDF;
    --status-success-soft: #2A4032;

    --border-subtle: rgba(229, 228, 226, 0.28);
    --border-strong: #E6E0F0;
    --focus-ring: #E6E0F0;
    --accent-color: #E6E0F0;

    --shadow-sm: 0 2px 6px rgb(24 14 8 / 0.35);
    --shadow-md: 0 10px 26px -4px rgb(24 14 8 / 0.45);
    --shadow-lg: 0 24px 48px -8px rgb(24 14 8 / 0.62);
  }

  :root[data-theme="light"] {
    color-scheme: light;
  }

  /* Forced colors mode resilience */
  @media (forced-colors: active) {
    :root {
      --border-subtle: ButtonText;
      --border-strong: ButtonText;
      --focus-ring: Highlight;
    }
  }
}
