/**
 * The Kintsugi Mender — Design Tokens & Theming
 * Kyoto Rainy Atelier Theme System
 */

:root {
  /* ==========================================================================
     Typography
     ========================================================================== */
  --font-serif: 'Shippori Mincho', 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --text-xs: 0.875rem;    /* 14px — readability floor */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* ==========================================================================
     Radii (Washi Paper & Tatami Curves)
     ========================================================================== */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  /* ==========================================================================
     Spacing & Layout Scales
     ========================================================================== */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --tap-min: 44px; /* Minimum accessible touch target */

  /* ==========================================================================
     Z-Index Hierarchy
     ========================================================================== */
  --z-backdrop: 0;
  --z-stage: 10;
  --z-hud: 100;
  --z-drawer: 200;
  --z-modal-backdrop: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* ==========================================================================
     Kintsugi Metals & Craft Techniques
     ========================================================================== */
  --kin-color: #d9a73e;
  --kin-glow: rgba(217, 167, 62, 0.45);
  --kin-shimmer: #fce29d;

  --gin-color: #cbd5e1;
  --gin-glow: rgba(203, 213, 225, 0.45);
  --gin-shimmer: #f1f5f9;

  --shu-color: #c93b2b;
  --shu-glow: rgba(201, 59, 43, 0.45);
  --shu-shimmer: #f58474;

  --yobitsugi-color: #3d638c;
  --yobitsugi-glow: rgba(61, 99, 140, 0.45);
  --yobitsugi-shimmer: #88b3db;

  /* Emotional Seal Colors */
  --wabi-amber: #c48b20;
  --wabi-mist: #737f8c;
  --wabi-crimson: #b83b28;
  --wabi-indigo: #3a4e6c;

  /* Ceramic Glazes */
  --glaze-shigaraki: #6b533f;
  --glaze-arita: #1e3a5f;
  --glaze-celadon: #8ea89d;
  --glaze-kuro: #211e1c;
  --glaze-kohiki: #ded7c8;

  /* Common Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 450ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows (Washi Paper Diffusion) */
  --shadow-sm: 0 1px 3px rgba(36, 27, 20, 0.08), 0 1px 2px rgba(36, 27, 20, 0.04);
  --shadow-md: 0 4px 14px rgba(36, 27, 20, 0.1), 0 2px 4px rgba(36, 27, 20, 0.06);
  --shadow-lg: 0 12px 32px rgba(36, 27, 20, 0.15), 0 4px 8px rgba(36, 27, 20, 0.08);
  --shadow-inner: inset 0 2px 4px rgba(36, 27, 20, 0.08);

  /* ==========================================================================
     Theme: Dusk (Default) — Warm Cedar Washi
     ========================================================================== */
  --bg-primary: #f2e7d8;
  --surface: #faf4ea;
  --surface-2: #e6d7c1;
  --border: #cfb99d;
  --text: #241b14;
  --text-muted: #6b5949;
  --accent-gold: #c48b20;
  --accent-gold-ink: #7a4f0c; /* gold for TEXT: meets WCAG AA on this theme's paper */
  --thread-red: #a3291c;
  --btn-primary-ink: #1f1611;
  --accent-gold-tint: rgba(196, 139, 32, 0.14);
  --accent-vermilion: #b83b28;
  --accent-silver: #737f8c;
  --accent-indigo: #3a4e6c;
  --overlay-bg: rgba(242, 231, 216, 0.88);
  --scrim: rgba(36, 27, 20, 0.52);

  --wood-grain: #5a412f;
  --wood-border: #422f20;
  --hanko-red: #c13324;
}

/* ==========================================================================
   Theme: Morning — Warm Sunlit Mist
   ========================================================================== */
[data-theme="morning"] {
  --bg-primary: #f5f0e6;
  --surface: #fbf8f2;
  --surface-2: #ede4d5;
  --border: #d7cab5;
  --text: #26201a;
  --text-muted: #6a5f53;
  --accent-gold: #b68422;
  --accent-gold-ink: #7a5310; /* gold for TEXT: meets WCAG AA on this theme's paper */
  --thread-red: #a3291c;
  --btn-primary-ink: #1f1611;
  --accent-gold-tint: rgba(182, 132, 34, 0.14);
  --accent-vermilion: #b93b29;
  --accent-silver: #707d8c;
  --accent-indigo: #3d546e;
  --overlay-bg: rgba(245, 240, 230, 0.86);
  --scrim: rgba(38, 32, 26, 0.45);

  --wood-grain: #6b533f;
  --wood-border: #4f3c2b;
  --hanko-red: #bf3426;

  --shadow-sm: 0 1px 3px rgba(38, 32, 26, 0.06), 0 1px 2px rgba(38, 32, 26, 0.03);
  --shadow-md: 0 4px 14px rgba(38, 32, 26, 0.08), 0 2px 4px rgba(38, 32, 26, 0.05);
  --shadow-lg: 0 12px 32px rgba(38, 32, 26, 0.12), 0 4px 8px rgba(38, 32, 26, 0.06);
}

/* ==========================================================================
   Theme: Dusk (Explicit Attribute Match)
   ========================================================================== */
[data-theme="dusk"] {
  --bg-primary: #f2e7d8;
  --surface: #faf4ea;
  --surface-2: #e6d7c1;
  --border: #cfb99d;
  --text: #241b14;
  --text-muted: #6b5949;
  --accent-gold: #c48b20;
  --accent-gold-ink: #7a4f0c; /* gold for TEXT: meets WCAG AA on this theme's paper */
  --thread-red: #a3291c;
  --btn-primary-ink: #1f1611;
  --accent-gold-tint: rgba(196, 139, 32, 0.14);
  --accent-vermilion: #b83b28;
  --accent-silver: #737f8c;
  --accent-indigo: #3a4e6c;
  --overlay-bg: rgba(242, 231, 216, 0.88);
  --scrim: rgba(36, 27, 20, 0.52);

  --wood-grain: #5a412f;
  --wood-border: #422f20;
  --hanko-red: #c13324;
}

/* ==========================================================================
   Theme: Night — Deep Kyoto Indigo-Charcoal
   ========================================================================== */
[data-theme="night"] {
  --bg-primary: #13171f;
  --surface: #1c2028;
  --surface-2: #262b35;
  --border: #3a404c;
  --text: #f2eadc;
  --text-muted: #a6a095;
  --accent-gold: #e5b94e;
  --accent-gold-ink: #e5b94e; /* gold for TEXT: meets WCAG AA on this theme's paper */
  --thread-red: #ff8f7a;
  --btn-primary-ink: #1f1611;
  --accent-gold-tint: rgba(229, 185, 78, 0.18);
  --accent-vermilion: #e05c48;
  --accent-silver: #cbd5e1;
  --accent-indigo: #7b9cc2;
  --overlay-bg: rgba(19, 23, 31, 0.88);
  --scrim: rgba(7, 9, 13, 0.75);

  --wood-grain: #2a221d;
  --wood-border: #1a1512;
  --hanko-red: #e05c48;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55), 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Keyframes & Atmospheric Animations
   ========================================================================== */
@keyframes fadeSlideUp {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rainPulse {
  0%, 100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.65;
  }
}

@keyframes lanternFlicker {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(229, 185, 78, 0.28));
  }
  25% {
    filter: drop-shadow(0 0 14px rgba(229, 185, 78, 0.42));
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(229, 185, 78, 0.22));
  }
  75% {
    filter: drop-shadow(0 0 16px rgba(229, 185, 78, 0.46));
  }
}

@keyframes breathOrb {
  /* 12s full loop: 4s inhale (0% - 33.3%), 4s hold (33.3% - 66.6%), 4s exhale (66.6% - 100%) */
  0% {
    transform: scale(1);
    box-shadow: 0 0 15px rgba(196, 139, 32, 0.2);
  }
  33.3% {
    transform: scale(1.38);
    box-shadow: 0 0 35px rgba(196, 139, 32, 0.55);
  }
  66.6% {
    transform: scale(1.38);
    box-shadow: 0 0 35px rgba(196, 139, 32, 0.55);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 15px rgba(196, 139, 32, 0.2);
  }
}

@keyframes goldShimmer {
  0% {
    filter: drop-shadow(0 0 2px var(--kin-color)) brightness(1);
  }
  50% {
    filter: drop-shadow(0 0 8px var(--kin-shimmer)) brightness(1.25);
  }
  100% {
    filter: drop-shadow(0 0 2px var(--kin-color)) brightness(1);
  }
}

@keyframes hankoStamp {
  0% {
    opacity: 0;
    transform: scale(2.4) rotate(-14deg);
    filter: blur(4px);
  }
  65% {
    opacity: 0.95;
    transform: scale(0.92) rotate(-1deg);
    filter: blur(0);
  }
  85% {
    transform: scale(1.05) rotate(-2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(-1.5deg);
  }
}
