/* Uniwai — Editorial Bold Design System (v8 · slate ink)
 * ------------------------------------------------------------------
 * Serif-led editorial direction. DM Serif Display for headlines +
 * wordmark; Inter for body; JetBrains Mono for metadata labels.
 *
 * Palette:
 *   • Warm cream paper (#FBFAF8, #F5EFE0, #EDE6D3)
 *   • Ink black (#1A1A1C)
 *   • Accent: slate ink (#1E293B) — deep neutral, NYT/Harper's vibes
 * The accent intentionally lives in the neutral spectrum: no saturated
 * "brand color". Character comes from typography and italic display.
 * ------------------------------------------------------------------ */

:root {
  /* Warm surfaces */
  --bg:       #FBFAF8;
  --surface:  #FFFFFF;
  --cream:    #F5EFE0;
  --cream-2:  #EDE6D3;
  --cream-3:  #E6DDC4;

  /* Type ink */
  --ink:      #1A1A1C;
  --ink-2:    #3C3B3F;
  --muted:    #6B6A6E;
  /* --faint: darkened from #9E9CA1 (2.4:1, failed WCAG AA) to 4.7:1 on cream /
   * 5.4:1 on white, so it passes AA as text while staying near --muted. */
  --faint:    #6A6970;
  --faint-decorative: #9E9CA1;  /* only for non-text decoration (hairlines, disabled marks) */

  /* Lines / borders */
  --line:     #E8E4DD;
  --line-2:   #D9D2C4;

  /* SLATE INK — deep neutral accent.
   * Variable names kept as --blue-* for backward compatibility across templates;
   * the values are now slate, not blue. The editorial direction is "neutral accent". */
  --blue-50:   #F8FAFC;
  --blue-100:  #F1F5F9;
  --blue-200:  #E2E8F0;
  --blue-300:  #CBD5E1;
  --blue-400:  #94A3B8;
  --blue-500:  #64748B;
  --blue-600:  #334155;
  --blue-700:  #1E293B;  /* ← primary accent (slate ink) */
  --blue-800:  #0F172A;
  --blue-900:  #020617;

  /* Legacy indigo aliases → all point at the slate scale via --blue-* */
  --indigo-50:  var(--blue-50);
  --indigo-100: var(--blue-100);
  --indigo-200: var(--blue-200);
  --indigo-300: var(--blue-300);
  --indigo-400: var(--blue-400);
  --indigo-500: var(--blue-500);
  --indigo-600: var(--blue-600);
  --indigo-700: var(--blue-700);
  --indigo-800: var(--blue-800);
  --indigo-900: var(--blue-900);

  /* Secondary accents — warm, muted */
  --forest:   #15803D;
  --amber:    #B45309;
  --rose:     #B4435E;

  /* Legacy alias tokens — mapped to editorial palette */
  --en-navy-950: var(--ink);
  --en-navy-900: var(--ink);
  --en-navy-800: var(--ink-2);
  --en-navy-700: var(--ink-2);

  --en-stone-50:  var(--bg);
  --en-stone-100: var(--cream);
  --en-stone-200: var(--line);
  --en-stone-300: var(--line-2);
  --en-stone-400: var(--faint);
  --en-stone-500: var(--muted);
  --en-stone-600: var(--ink-2);
  --en-stone-700: var(--ink-2);
  --en-stone-800: var(--ink);
  --en-stone-900: var(--ink);

  --en-primary-50:  var(--blue-50);
  --en-primary-100: var(--blue-100);
  --en-primary-200: var(--blue-200);
  --en-primary-300: var(--blue-300);
  --en-primary-400: var(--blue-400);
  --en-primary-500: var(--blue-500);
  --en-primary-600: var(--blue-700);
  --en-primary-700: var(--blue-700);
  --en-primary-800: var(--blue-800);
  --en-primary-900: var(--blue-900);

  --en-success-50:  #F0FDF4;
  --en-success-500: #22C55E;
  --en-success-600: var(--forest);
  --en-success-700: #15803D;
  --en-success-800: #166534;

  --en-gold-50:  #FFFBEB;
  --en-gold-100: #FEF3C7;
  --en-gold-500: #F59E0B;
  --en-gold-600: var(--amber);
  --en-gold-700: #B45309;
  --en-gold-800: #92400E;
}

/* ------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

::selection { background: var(--blue-100); color: var(--blue-900); }

/* ------------------------------------------------------------------
 * Typography utilities
 * ------------------------------------------------------------------ */
.display,
.font-display,
h1.font-display,
h2.font-display,
h3.font-display,
h4.font-display {
  font-family: 'DM Serif Display', 'Playfair Display', Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.02;
}
.display em, .font-display em,
.display .em, .font-display .em {
  font-style: italic;
  color: var(--blue-700);
}

.mono, .font-mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.section-label::before {
  content: "";
  flex: 0 0 32px;
  height: 1px;
  background: var(--ink);
}
.section-label .txt,
.section-label > span:last-child {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ------------------------------------------------------------------
 * Wordmark — DM Serif Display + pure-blue underline under "Edu"
 * ------------------------------------------------------------------ */
.wordmark {
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1;
  position: relative;
  display: inline-block;
  padding-bottom: 3px;
  white-space: nowrap;
}
.wordmark::after {
  content: '';
  position: absolute;
  left: 0; right: 66%;
  bottom: 0;
  height: 2px;
  background: var(--blue-700);
  border-radius: 1px;
}
.wordmark-nav     { font-size: 28px; }
.wordmark-footer  { font-size: 32px; }
.wordmark-hero    { font-size: 44px; }
.wordmark-sidebar { font-size: 20px; }

/* ------------------------------------------------------------------
 * Accent text
 * ------------------------------------------------------------------ */
.en-gradient-text {
  color: var(--blue-700);
  font-style: italic;
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
}

/* ------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------ */
.en-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem;
  border-radius: .6rem;
  font-weight: 600;
  font-size: .9rem;
  line-height: 1;
  letter-spacing: -0.005em;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
}
.en-btn:active { transform: translateY(1px); }

.en-btn-primary {
  background: var(--blue-700);
  color: #FFFFFF;
}
.en-btn-primary:hover { background: var(--blue-800); }
.en-btn-primary:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 2px;
}

.en-btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-2);
}
.en-btn-ghost:hover {
  background: var(--cream);
  border-color: var(--ink-2);
  color: var(--ink);
}

.en-btn-ink {
  background: var(--ink);
  color: #FFFFFF;
}
.en-btn-ink:hover { background: #000; }

.en-btn-gold {
  background: var(--amber);
  color: #FFFFFF;
}
.en-btn-gold:hover { background: #92400E; }

/* ------------------------------------------------------------------
 * Pills / Badges
 * ------------------------------------------------------------------ */
.en-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .32rem .75rem; border-radius: 999px;
  background: var(--cream); color: var(--ink-2);
  font-size: .72rem; font-weight: 500; letter-spacing: .08em;
  border: 1px solid var(--line-2);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}
.en-pill-light {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.en-pill-gold {
  background: var(--en-gold-50);
  color: var(--en-gold-800);
  border-color: var(--en-gold-100);
}
.en-pill-success {
  background: var(--en-success-50);
  color: var(--en-success-800);
  border-color: #BBF7D0;
}

/* ------------------------------------------------------------------
 * Step badge — numbered circles used in how-it-works
 * ------------------------------------------------------------------ */
.en-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFFFFF;
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------ */
.en-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .75rem;
  box-shadow: none;
}
.en-card-hover {
  transition: border-color .15s ease, transform .12s ease;
}
.en-card-hover:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.en-card-cream {
  background: var(--cream);
  border-color: var(--line-2);
}

.value-card {
  background: var(--surface);
  padding: 40px 32px;
  display: flex; flex-direction: column;
  min-height: 260px;
}
.value-card .num {
  font-family: 'DM Serif Display', serif;
  font-size: 14px;
  color: var(--blue-700);
  margin-bottom: 18px;
}
.value-card h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--ink);
}
.value-card h3 em { font-style: italic; color: var(--blue-700); }
.value-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

/* ------------------------------------------------------------------
 * .quote-surface — INK BLACK ("un momento d'inchiostro").
 * Single dark moment per page: cream paper everywhere else,
 * one ink-black testimonial. Mockup A direction.
 * ------------------------------------------------------------------ */
.quote-surface {
  background: var(--ink);
  color: #FFFFFF;
  position: relative;
  overflow: hidden;
}
.quote-surface::before {
  content: '"';
  position: absolute;
  top: -100px; left: 60px;
  font-family: 'DM Serif Display', serif;
  font-size: 480px;
  line-height: 1;
  color: rgba(255,255,255,0.04);
  font-style: italic;
  pointer-events: none;
}
.quote-surface > * { position: relative; z-index: 1; }
/* Tailwind utilities that change meaning on ink — flip them inside .quote-surface. */
.quote-surface .font-display,
.quote-surface .text-brand-900,
.quote-surface .text-brand-950 { color: #FFFFFF; }
.quote-surface .text-brand-500,
.quote-surface .text-brand-600 { color: rgba(255,255,255,0.62); }
.quote-surface .bg-primary-700 { background: var(--blue-700); }

/* ------------------------------------------------------------------
 * .en-aurora — legacy page hero (compare, how_it_works).
 * In Mockup A direction this is just a cream paper banner with
 * an editorial accent — NOT a dark block. Templates still use
 * text-white/text-brand-200; we override those inside .en-aurora
 * so they stay readable on cream.
 * ------------------------------------------------------------------ */
.en-aurora {
  background: var(--cream);
  color: var(--ink);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line-2);
}
.en-aurora::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--blue-700);
}
.en-aurora > * { color: var(--ink); }
.en-aurora .text-white { color: var(--ink); }
.en-aurora h1,
.en-aurora h2,
.en-aurora h3,
.en-aurora .font-display { color: var(--ink); }
.en-aurora p,
.en-aurora .text-brand-200,
.en-aurora .text-brand-300 { color: var(--muted); }

.en-gradient-bg {
  background: var(--blue-700);
}
.en-gradient-bg-soft {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
}

/* ------------------------------------------------------------------
 * Option cards (wizard steps)
 * ------------------------------------------------------------------ */
.option-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: 1rem 1.15rem;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .05s ease;
  width: 100%;
}
.option-card:hover {
  border-color: var(--blue-700);
  background: var(--blue-50);
}
.option-card.selected {
  border-color: var(--blue-700);
  background: var(--blue-50);
  box-shadow: inset 0 0 0 1px var(--blue-700);
}
.option-card:active { transform: translateY(1px); }

/* ------------------------------------------------------------------
 * Score ring
 * ------------------------------------------------------------------ */
.score-ring {
  width: 80px; height: 80px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-weight: 400; font-size: 1.7rem;
  color: var(--ink);
  position: relative;
  letter-spacing: -0.02em;
}
.score-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  padding: 3px;
  background: conic-gradient(var(--blue-700) calc(var(--p,50%) * 1%), var(--line) 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.score-ring.score-high::before {
  background: conic-gradient(var(--forest) calc(var(--p,80%) * 1%), var(--line) 0);
}
.score-ring.score-top::before {
  background: conic-gradient(var(--amber) calc(var(--p,90%) * 1%), var(--line) 0);
}

/* ------------------------------------------------------------------
 * Chat bubbles (advisor)
 * ------------------------------------------------------------------ */
.chat-bubble-bot {
  background: var(--cream);
  color: var(--ink);
  border-radius: 1rem;
  border-top-left-radius: .25rem;
}
.chat-bubble-user {
  background: var(--blue-700);
  color: #FFFFFF;
  border-radius: 1rem;
  border-top-right-radius: .25rem;
}

/* ------------------------------------------------------------------
 * Logo mark — subtle cream square with a serif E
 * ------------------------------------------------------------------ */
.en-logo-mark {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink);
  border-radius: .5rem;
  color: #FFFFFF;
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
}

/* ------------------------------------------------------------------
 * Fade-in animations
 * ------------------------------------------------------------------ */
@keyframes en-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadein         { animation: en-fadein .6s ease both; }
.animate-fadein-delay-1 { animation: en-fadein .6s ease .1s both; }
.animate-fadein-delay-2 { animation: en-fadein .6s ease .2s both; }

/* ------------------------------------------------------------------
 * Focus — high-contrast ink ring (slate-400 failed the 3:1 UI minimum).
 * Ink at 2px with a 2px offset reads on every surface incl. slate buttons.
 * ------------------------------------------------------------------ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: .35rem;
}
/* On the ink testimonial surface, invert so the ring stays visible. */
.quote-surface :focus-visible { outline-color: #FFFFFF; }

/* ------------------------------------------------------------------
 * Inline prose links — resting underline so slate-colored links are
 * distinguishable from ink body text (affordance without a saturated hue).
 * Buttons (.en-btn) and nav/footer links are excluded.
 * ------------------------------------------------------------------ */
a.text-primary-700:not(.en-btn):not(.wordmark),
a.text-primary-600:not(.en-btn) {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line-2);
  transition: text-decoration-color .12s ease;
}
a.text-primary-700:not(.en-btn):hover,
a.text-primary-600:not(.en-btn):hover {
  text-decoration-color: currentColor;
}

/* ------------------------------------------------------------------
 * Footer utility
 * ------------------------------------------------------------------ */
.en-footer {
  background: var(--bg);
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.en-footer a { color: var(--muted); }
.en-footer a:hover { color: var(--ink); }

/* ------------------------------------------------------------------
 * Admin sidebar surface — warm paper (no more dark block)
 * ------------------------------------------------------------------ */
.admin-sidebar {
  background: var(--cream);
  color: var(--ink);
  border-right: 1px solid var(--line-2);
}
.admin-sidebar a.nav-link {
  color: var(--muted);
  transition: color .12s ease, background-color .12s ease;
}
.admin-sidebar a.nav-link:hover {
  color: var(--ink);
  background: rgba(26,26,28,0.04);
}
.admin-sidebar a.nav-link.active {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: 0 1px 2px rgba(26,26,28,0.04);
}
.admin-sidebar .avatar {
  background: var(--blue-700);
  color: #FFFFFF;
}

/* ------------------------------------------------------------------
 * Misc
 * ------------------------------------------------------------------ */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ------------------------------------------------------------------
 * Advisor typing indicator + recorded demo player (/{lang}/demo)
 * The dots are shared with the live advisor, whose markup (advisor.js) has
 * always carried the .typing-dot class without a rule to paint it — the
 * indicator rendered as three invisible boxes.
 * ------------------------------------------------------------------ */
.typing-dot {
  background: var(--blue-400);
  animation: en-typing 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }
@keyframes en-typing {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-3px); }
}

/* A Tailwind display utility (e.g. .flex) outranks the user-agent rule for the
 * [hidden] attribute, so any element toggled with hidden needs it back. */
[hidden] { display: none !important; }

.demo-turn { animation: en-fadein .45s ease both; }
.demo-mode-badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .demo-turn { animation: none; }
  .typing-dot { animation: none; opacity: .55; }
}
