/* ==========================================================================
   Theme Polish Layer — Ijwi ry'Ikirundi AI
   Loaded last so its refinements win over Tailwind utilities and the legacy
   stylesheets. Purpose: a cohesive, modern visual system (design tokens,
   softer depth, calmer surfaces, tighter typography) without changing markup
   or behavior. Brand identity stays Burundi red + green.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  /* Brand */
  --brand-green: #16a34a;
  --brand-green-strong: #15803d;
  --brand-red: #e11d48;
  --brand-accent: #f59e0b;

  /* Surfaces & lines (light) */
  --surface-app: #f6f8f7;
  --surface-card: #ffffff;
  --surface-muted: #f1f5f4;
  --line-soft: #e8ece9;
  --line: #dfe4e1;

  /* Ink */
  --ink-strong: #10201a;
  --ink: #33403a;
  --ink-soft: #64726b;

  /* Radii */
  --r-sm: 0.625rem;
  --r-md: 0.875rem;
  --r-lg: 1.15rem;
  --r-xl: 1.5rem;

  /* Elevation — layered, low-alpha for a soft modern feel */
  --shadow-sm: 0 1px 2px rgba(16, 32, 26, 0.05), 0 1px 3px rgba(16, 32, 26, 0.04);
  --shadow-md: 0 4px 14px -4px rgba(16, 32, 26, 0.10), 0 2px 6px -2px rgba(16, 32, 26, 0.06);
  --shadow-lg: 0 14px 32px -10px rgba(16, 32, 26, 0.14), 0 4px 12px -4px rgba(16, 32, 26, 0.08);
  --shadow-xl: 0 28px 56px -18px rgba(16, 32, 26, 0.20), 0 10px 20px -10px rgba(16, 32, 26, 0.10);

  /* Focus */
  --ring: 0 0 0 3px rgba(22, 163, 74, 0.28);
}

.dark {
  --surface-app: #0d1512;
  --surface-card: #17211c;
  --surface-muted: #1e2a24;
  --line-soft: #26332c;
  --line: #2c3a32;

  --ink-strong: #f2f6f4;
  --ink: #d3ddd7;
  --ink-soft: #94a29b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px -4px rgba(0, 0, 0, 0.45), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 34px -12px rgba(0, 0, 0, 0.55), 0 6px 14px -6px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 30px 60px -20px rgba(0, 0, 0, 0.65), 0 12px 24px -12px rgba(0, 0, 0, 0.5);

  --ring: 0 0 0 3px rgba(74, 222, 128, 0.3);
}

/* --- Base ----------------------------------------------------------------- */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  /* Calmer, layered ambient background replaces the flat blue→green wash */
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(22, 163, 74, 0.10), transparent 60%),
    radial-gradient(1000px 560px at 92% 4%, rgba(225, 29, 72, 0.07), transparent 62%),
    var(--surface-app) !important;
  background-attachment: fixed;
}

.dark body {
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(22, 163, 74, 0.16), transparent 60%),
    radial-gradient(1000px 560px at 92% 4%, rgba(225, 29, 72, 0.12), transparent 62%),
    var(--surface-app) !important;
  background-attachment: fixed;
}

/* Headings: tighter tracking + balanced wrapping read as more intentional */
h1, h2, h3 {
  letter-spacing: -0.018em;
  text-wrap: balance;
}

/* --- Softer, unified elevation (refines Tailwind utilities globally) ------ */
.shadow,
.shadow-md {
  box-shadow: var(--shadow-md) !important;
}
.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}
.shadow-xl,
.shadow-2xl {
  box-shadow: var(--shadow-xl) !important;
}

/* --- Cards ---------------------------------------------------------------- */
.card-modern,
.main-card {
  background: var(--surface-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: none;
}

.card-modern:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

/* Rank card: quiet the neutral card so brand accents lead */
#main-menu .bg-white.rounded-2xl,
#main-menu .dark\:bg-gray-800.rounded-2xl {
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

/* --- Header --------------------------------------------------------------- */
header .bg-white\/95 {
  box-shadow: var(--shadow-md);
}

/* Thin brand rule under the header — crisper than the washed 3-stop bar */
header > .h-1,
header .h-1.bg-gradient-to-r {
  height: 3px;
  background: linear-gradient(90deg, var(--brand-red), var(--brand-accent) 45%, var(--brand-green)) !important;
}

/* --- Level buttons -------------------------------------------------------- */
.btn-modern {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  isolation: isolate;
}

/* Soft top-edge sheen gives the flat gradient buttons real depth */
.btn-modern::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 42%);
  pointer-events: none;
  z-index: -1;
}

.btn-modern:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.btn-modern:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* --- Semantic action buttons (submit / edit / skip) ----------------------- */
.btn-primary-action,
.btn-secondary-action,
.btn-info-action {
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.btn-primary-action:hover,
.btn-secondary-action:hover,
.btn-info-action:hover {
  box-shadow: var(--shadow-md);
}

/* --- Inputs --------------------------------------------------------------- */
input[type="text"],
textarea {
  border-radius: var(--r-md) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input[type="text"]:focus,
textarea:focus,
.input-focus:focus {
  border-color: var(--brand-green) !important;
  box-shadow: var(--ring) !important;
  outline: none;
}

/* --- Consistent, accessible focus ring across interactive elements -------- */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* --- Support chat launcher ------------------------------------------------ */
#support-chat-btn {
  background: var(--brand-green);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#support-chat-btn:hover {
  background: var(--brand-green-strong);
  transform: translateY(-2px) scale(1.03);
  box-shadow: var(--shadow-xl);
}

#support-chat-modal {
  border-radius: var(--r-xl);
  border-color: var(--line-soft);
  box-shadow: var(--shadow-xl);
}

/* --- Kirundi phrase card -------------------------------------------------- */
.kirundi-phrase {
  border-radius: var(--r-lg);
  border-width: 1px;
}

/* --- Reduced motion respect ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
