@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "./styles/mobile.css";

@custom-variant dark (&:is(.dark *));

@theme inline {
    --font-heading: var(--font-sans);
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --color-sidebar-ring: var(--sidebar-ring);
    --color-sidebar-border: var(--sidebar-border);
    --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
    --color-sidebar-accent: var(--sidebar-accent);
    --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
    --color-sidebar-primary: var(--sidebar-primary);
    --color-sidebar-foreground: var(--sidebar-foreground);
    --color-sidebar: var(--sidebar);
    --color-chart-5: var(--chart-5);
    --color-chart-4: var(--chart-4);
    --color-chart-3: var(--chart-3);
    --color-chart-2: var(--chart-2);
    --color-chart-1: var(--chart-1);
    --color-ring: var(--ring);
    --color-input: var(--input);
    --color-border: var(--border);
    --color-destructive: var(--destructive);
    --color-accent-foreground: var(--accent-foreground);
    --color-accent: var(--accent);
    --color-muted-foreground: var(--muted-foreground);
    --color-muted: var(--muted);
    --color-secondary-foreground: var(--secondary-foreground);
    --color-secondary: var(--secondary);
    --color-primary-foreground: var(--primary-foreground);
    --color-primary: var(--primary);
    --color-popover-foreground: var(--popover-foreground);
    --color-popover: var(--popover);
    --color-card-foreground: var(--card-foreground);
    --color-card: var(--card);
    --color-foreground: var(--foreground);
    --color-background: var(--background);
    --radius-sm: calc(var(--radius) * 0.6);
    --radius-md: calc(var(--radius) * 0.8);
    --radius-lg: var(--radius);
    --radius-xl: calc(var(--radius) * 1.4);
    --radius-2xl: calc(var(--radius) * 1.8);
    --radius-3xl: calc(var(--radius) * 2.2);
    --radius-4xl: calc(var(--radius) * 2.6);
}

:root {
    /* Atelier palette (global — applied across entire app) */
    --at-brand: #3D4BD7;
    --at-brand-ink: #1A2280;
    --at-brand-soft: #E9ECFE;
    --at-brand-softer: #F4F5FE;
    --at-ink: #0F1114;
    --at-ink-2: #2A2D33;
    --at-ink-3: #3E4149;
    --at-mute: #6B6F76;
    --at-mute-2: #9CA0A8;
    --at-line: #E8E5DE;
    --at-line-2: #EFECE4;
    --at-paper: #FAF8F3;
    --at-paper-2: #F4F1EA;
    --at-surface: #FFFFFF;
    --at-good: #2F7D4A;
    --at-good-soft: #E4F0E7;
    --at-good-ink: #1B4B2C;
    --at-warm: #D26A3B;
    --at-warm-soft: #F8E9DE;
    --at-warm-ink: #6B2A14;
    --at-bad: #C1443E;
    --at-bad-soft: #F4DEDC;
    --at-streak: #C15A34;
    --at-streak-soft: #F7E6DC;

    --at-serif: "Fraunces", "Instrument Serif", Georgia, serif;
    --at-sans: "Geist", "Geist Variable", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --at-mono: "Geist Mono", ui-monospace, SF Mono, Menlo, monospace;

    --background: oklch(1 0 0);
    --foreground: oklch(0.145 0 0);
    --card: oklch(1 0 0);
    --card-foreground: oklch(0.145 0 0);
    --popover: oklch(1 0 0);
    --popover-foreground: oklch(0.145 0 0);
    --primary: oklch(54.6% 0.245 262.3); /* #2563EB */
    --primary-foreground: oklch(1 0 0);
    --secondary: oklch(0.97 0 0);
    --secondary-foreground: oklch(0.205 0 0);
    --muted: oklch(0.97 0 0);
    --muted-foreground: oklch(0.556 0 0);
    --accent: oklch(0.97 0 0);
    --accent-foreground: oklch(0.205 0 0);
    --destructive: oklch(0.577 0.245 27.325);
    --border: oklch(0.922 0 0);
    --input: oklch(0.922 0 0);
    --ring: oklch(0.708 0 0);
    --chart-1: oklch(0.87 0 0);
    --chart-2: oklch(0.556 0 0);
    --chart-3: oklch(0.439 0 0);
    --chart-4: oklch(0.371 0 0);
    --chart-5: oklch(0.269 0 0);
    --radius: 0.625rem;
    --sidebar: oklch(0.985 0 0);
    --sidebar-foreground: oklch(0.145 0 0);
    --sidebar-primary: oklch(0.205 0 0);
    --sidebar-primary-foreground: oklch(0.985 0 0);
    --sidebar-accent: oklch(0.97 0 0);
    --sidebar-accent-foreground: oklch(0.205 0 0);
    --sidebar-border: oklch(0.922 0 0);
    --sidebar-ring: oklch(0.708 0 0);
}

.dark {
    --background: oklch(0.145 0 0);
    --foreground: oklch(0.985 0 0);
    --card: oklch(0.205 0 0);
    --card-foreground: oklch(0.985 0 0);
    --popover: oklch(0.205 0 0);
    --popover-foreground: oklch(0.985 0 0);
    --primary: oklch(0.922 0 0);
    --primary-foreground: oklch(0.205 0 0);
    --secondary: oklch(0.269 0 0);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.269 0 0);
    --muted-foreground: oklch(0.708 0 0);
    --accent: oklch(0.269 0 0);
    --accent-foreground: oklch(0.985 0 0);
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.556 0 0);
    --chart-1: oklch(0.87 0 0);
    --chart-2: oklch(0.556 0 0);
    --chart-3: oklch(0.439 0 0);
    --chart-4: oklch(0.371 0 0);
    --chart-5: oklch(0.269 0 0);
    --sidebar: oklch(0.205 0 0);
    --sidebar-foreground: oklch(0.985 0 0);
    --sidebar-primary: oklch(0.488 0.243 264.376);
    --sidebar-primary-foreground: oklch(0.985 0 0);
    --sidebar-accent: oklch(0.269 0 0);
    --sidebar-accent-foreground: oklch(0.985 0 0);
    --sidebar-border: oklch(1 0 0 / 10%);
    --sidebar-ring: oklch(0.556 0 0);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    background: var(--at-paper);
    color: var(--at-ink);
    font-family: var(--at-sans);
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
  }
  html {
    @apply font-sans;
  }
}

/* Atelier global helpers — usable outside .atelier scope */
.at-serif { font-family: var(--at-serif); }
.at-mono { font-family: var(--at-mono); }
.at-eyebrow {
  font-family: var(--at-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--at-mute);
}
.at-title {
  font-family: var(--at-serif);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--at-ink);
}
.at-title i { font-style: italic; color: var(--at-brand); font-weight: 400; }
.at-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--at-line-2);
  color: var(--at-ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.at-chip-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.at-chip-brand { background: var(--at-brand-soft); color: var(--at-brand-ink); }
.at-chip-good  { background: var(--at-good-soft); color: var(--at-good-ink); }
.at-chip-warm  { background: var(--at-warm-soft); color: var(--at-warm); }
.at-bar {
  height: 6px;
  background: var(--at-line-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.at-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--at-brand);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.at-pullquote {
  padding: 18px;
  border-radius: 16px;
  background: var(--at-brand-soft);
  position: relative;
  overflow: hidden;
}
.at-pullquote-q {
  font-family: var(--at-serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.45;
  color: var(--at-brand-ink);
  letter-spacing: -0.01em;
}
.at-tip {
  padding: 16px;
  background: var(--at-warm-soft);
  border-radius: 14px;
  border: 1px solid rgba(210, 106, 59, 0.18);
}
.at-tip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--at-warm);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.at-tip-label::before {
  content: "";
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--at-warm);
}

/* ── Flashcard 3D flip ── */
.flashcard-scene {
  perspective: 1000px;
}
.flashcard-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.flashcard-inner.is-flipped {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
}
.flashcard-back {
  transform: rotateY(180deg);
}

/* ── Material Symbols ── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* ── Page fade-in ── */
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-enter {
  animation: page-in 0.2s ease both;
}

/* ── Timer urgent pulse ── */
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.timer-urgent {
  animation: timer-pulse 1s ease-in-out infinite;
}

/* ────────────────────────────────────────────────────────────
   The Atelier — flashcard learn page scope
   Tokens + typography + 3D flip card
   Fonts: Fraunces + Geist + Geist Mono (loaded by route)
   ──────────────────────────────────────────────────────────── */
.atelier {
  --at-accent: #3D4BD7;
  --at-accent-soft: #E9ECFE;
  --at-accent-ink: #1A2280;
  --at-ink: #0F1114;
  --at-ink-2: #2A2D33;
  --at-mute: #6B6F76;
  --at-mute-2: #9CA0A8;
  --at-line: #E8E5DE;
  --at-line-2: #EFECE4;
  --at-paper: #FAF8F3;
  --at-paper-2: #F4F1EA;
  --at-good: #2F7D4A;
  --at-good-soft: #E4F0E7;
  --at-warm: #D26A3B;
  --at-warm-soft: #F8E9DE;

  --at-serif: "Fraunces", "Instrument Serif", Georgia, serif;
  --at-sans: "Geist", "Geist Variable", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --at-mono: "Geist Mono", ui-monospace, SF Mono, Menlo, monospace;

  background: var(--at-paper);
  color: var(--at-ink);
  font-family: var(--at-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.atelier .at-serif { font-family: var(--at-serif); }
.atelier .at-mono { font-family: var(--at-mono); }

/* Card */
.atelier .at-card-outer {
  perspective: 2000px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  /* Size by available viewport height — never overflow */
  height: min(560px, calc(100vh - 14rem));
  max-height: 560px;
}
.atelier .at-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  animation: at-cardIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes at-cardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.atelier .at-card.is-flipped { transform: rotateY(180deg); }
.atelier .at-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #fff;
  border-radius: 28px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--at-line);
  box-shadow:
    0 1px 2px rgba(15,17,20,0.04),
    0 20px 40px -16px rgba(15,17,20,0.12),
    0 4px 12px -4px rgba(15,17,20,0.06);
}
.atelier .at-card-back { transform: rotateY(180deg); }

.atelier .at-word {
  font-family: var(--at-serif);
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--at-ink);
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
}
.atelier .at-meaning {
  font-family: var(--at-serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--at-ink);
}

.atelier .at-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--at-accent-soft);
  color: var(--at-accent-ink);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.atelier .at-chip-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--at-accent);
}
.atelier .at-chip-mute { background: var(--at-line-2); color: var(--at-mute); }
.atelier .at-chip-mute .at-chip-dot { background: var(--at-mute); }

.atelier .at-kbd {
  font-family: var(--at-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border: 1px solid var(--at-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--at-ink-2);
  background: var(--at-paper-2);
}

.atelier .at-example {
  padding: 14px 16px;
  background: var(--at-paper-2);
  border-radius: 12px;
  border-left: 2px solid var(--at-accent);
}

.atelier .at-action {
  flex: 1;
  padding: 13px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--at-line);
  background: #fff;
  color: var(--at-ink-2);
  transition: all 0.15s ease;
}
.atelier .at-action:hover:not(:disabled) { border-color: var(--at-ink); color: var(--at-ink); transform: translateY(-1px); }
.atelier .at-action:disabled { opacity: 0.4; cursor: not-allowed; }
.atelier .at-action-known {
  background: var(--at-good);
  color: white;
  border-color: var(--at-good);
}
.atelier .at-action-known:hover:not(:disabled) { background: #236238; border-color: #236238; color: white; }
.atelier .at-action-review {
  background: var(--at-warm-soft);
  color: var(--at-warm);
  border-color: rgba(210, 106, 59, 0.3);
}
.atelier .at-action-review:hover:not(:disabled) { background: var(--at-warm); color: white; border-color: var(--at-warm); }

.atelier .at-progress-bar {
  height: 6px;
  background: var(--at-line-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.atelier .at-progress-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--at-accent), color-mix(in oklab, var(--at-accent) 80%, white));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.atelier .at-pct {
  font-family: var(--at-serif);
  font-size: 22px;
  color: var(--at-accent);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
}

/* Swipe-off FX */
@keyframes at-knownFx {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-8px) rotate(2deg); }
  100% { transform: translateX(120%) rotate(8deg); opacity: 0; }
}
@keyframes at-reviewFx {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-8px) rotate(-2deg); }
  100% { transform: translateX(-120%) rotate(-8deg); opacity: 0; }
}
.atelier .at-card.fx-known  { animation: at-knownFx  0.55s cubic-bezier(0.4,0,0.2,1) forwards; }
.atelier .at-card.fx-review { animation: at-reviewFx 0.55s cubic-bezier(0.4,0,0.2,1) forwards; }