/*
 * Learn Lebnene design tokens.
 *
 * Mirrors Learn Lebnene/Theme/YallaColors.swift, YallaFonts.swift and
 * YallaLayout.swift. The Swift files are the source of truth; when they change,
 * change this file to match.
 *
 * Palette lock (Sprint 10): red + green + amber ONLY. One color, one meaning.
 * No blue, no purple, no orange, no off-token olive. See .claude/DESIGN_SYSTEM.md.
 */

:root {
  /* ---- Scheme-independent brand colors ---- */
  --ll-red: #d02931; /* brand, wrong answers, word highlights */
  --ll-wrong-red: #d02931;
  --ll-word-highlight: #d02931;
  --ll-correct-green: #00843d; /* quiz grade buttons only */
  --ll-streak-amber: #f5a623; /* time-sensitive only: streak, goal, due counts */

  /* Only allowed neutral hexes */
  --ll-progress-track: #e5e7eb;
  --ll-image-placeholder: #f0f1f3;

  /* ---- Light scheme (default) ---- */
  --ll-bg: #ffffff;
  --ll-card: #f4f5f7;
  --ll-text-primary: #1c1c1e;
  --ll-text-secondary: #8e8e93;
  --ll-divider: rgba(0, 0, 0, 0.06);
  --ll-action-green: #556b2f;
  --ll-icon-bg-green: #eaeedc;
  --ll-celebration-from: #f7f9ec;
  --ll-celebration-to: #eef2dd;
  --ll-card-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
  --ll-card-shadow-soft: 0 3px 10px rgba(0, 0, 0, 0.06);
  --ll-track-fill: rgba(0, 0, 0, 0.07);

  /* ---- Typography (YallaFonts.swift) ----
     SwiftUI uses .system(design: .rounded); ui-rounded is the web equivalent. */
  --ll-font-sans: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
  --ll-font-arabic: "Noto Naskh Arabic", "Geeza Pro", serif;
  --ll-weight-regular: 400;
  --ll-weight-medium: 500;
  --ll-weight-semibold: 600;
  --ll-weight-bold: 700;
  --ll-weight-black: 900;

  /* ---- Corner radii (YallaColors.swift) ---- */
  --ll-radius-sm: 12px; /* chips, tags, small badges */
  --ll-radius-md: 18px; /* cards, row items */
  --ll-radius-lg: 24px; /* sheets, modals, hero cards */
  --ll-radius-xl: 32px; /* full-bleed rounded panels */

  /* ---- Layout (YallaLayout.swift) ----
     Swift derives these proportionally from screen size, capped at 480x1000.
     Resolved here at the iPhone 16 reference (390 x 844 pt) that the Swift
     comments themselves quote. */
  --ll-screen-padding: 19.89px; /* w * 0.051 */
  --ll-section-gap: 23.63px; /* h * 0.028 */
  --ll-card-padding: 15.99px; /* w * 0.041 */
  --ll-pair-gap: 14.82px; /* w * 0.038 */
  --ll-card-spacing: 12.09px; /* w * 0.031 */
  --ll-deck-card-size: 140.01px; /* w * 0.359 */
  --ll-pill-height: 43.89px; /* h * 0.052 */
  --ll-icon-size: 47.97px; /* w * 0.123 */
  --ll-card-radius: 15.96px; /* deckCardSize * 0.114 */
  --ll-container-radius: 17.94px; /* w * 0.046 */
}

/* Dark scheme: follows the OS by default, and an explicit data-theme wins
   in both directions so a host can force either look. */
@media (prefers-color-scheme: dark) {
  :root {
    --ll-bg: #18181b;
    --ll-card: #28282c;
    --ll-text-primary: #ffffff;
    --ll-text-secondary: #aeaeb2;
    --ll-divider: rgba(255, 255, 255, 0.08);
    --ll-action-green: #a9b665;
    --ll-icon-bg-green: #2e3320;
    --ll-celebration-from: #1e2213;
    --ll-celebration-to: #171a0e;
    --ll-card-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    --ll-card-shadow-soft: 0 3px 10px rgba(0, 0, 0, 0.3);
    --ll-track-fill: rgba(255, 255, 255, 0.12);
  }
}

:root[data-theme="dark"],
[data-ll-theme="dark"] {
  --ll-bg: #18181b;
  --ll-card: #28282c;
  --ll-text-primary: #ffffff;
  --ll-text-secondary: #aeaeb2;
  --ll-divider: rgba(255, 255, 255, 0.08);
  --ll-action-green: #a9b665;
  --ll-icon-bg-green: #2e3320;
  --ll-celebration-from: #1e2213;
  --ll-celebration-to: #171a0e;
  --ll-card-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  --ll-card-shadow-soft: 0 3px 10px rgba(0, 0, 0, 0.3);
  --ll-track-fill: rgba(255, 255, 255, 0.12);
}

:root[data-theme="light"],
[data-ll-theme="light"] {
  --ll-bg: #ffffff;
  --ll-card: #f4f5f7;
  --ll-text-primary: #1c1c1e;
  --ll-text-secondary: #8e8e93;
  --ll-divider: rgba(0, 0, 0, 0.06);
  --ll-action-green: #556b2f;
  --ll-icon-bg-green: #eaeedc;
  --ll-celebration-from: #f7f9ec;
  --ll-celebration-to: #eef2dd;
  --ll-card-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
  --ll-card-shadow-soft: 0 3px 10px rgba(0, 0, 0, 0.06);
  --ll-track-fill: rgba(0, 0, 0, 0.07);
}

/* ---- Component styles ---- */

.ll-root {
  font-family: var(--ll-font-sans);
  color: var(--ll-text-primary);
  background: var(--ll-bg);
  -webkit-font-smoothing: antialiased;
}

.ll-arabic {
  font-family: var(--ll-font-arabic);
  direction: rtl;
}

/* Card */
.ll-card {
  background: var(--ll-card);
  border-radius: var(--ll-radius-md);
  box-shadow: var(--ll-card-shadow);
  padding: 16px;
  box-sizing: border-box;
}
.ll-card--lg {
  border-radius: var(--ll-radius-lg);
  box-shadow: var(--ll-card-shadow-soft);
}
.ll-card--flat {
  box-shadow: none;
}

/* PillButton */
.ll-pill {
  font-family: var(--ll-font-sans);
  font-size: 17px;
  font-weight: var(--ll-weight-semibold);
  border: none;
  border-radius: var(--ll-radius-md);
  height: 56px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}
.ll-pill:disabled {
  cursor: default;
}
.ll-pill--primary {
  background: var(--ll-action-green);
  color: #ffffff;
}
.ll-pill--secondary {
  background: var(--ll-card);
  color: var(--ll-text-primary);
}
.ll-pill--capsule {
  border-radius: 999px;
  height: var(--ll-pill-height);
  width: auto;
  font-size: 15px;
  font-weight: var(--ll-weight-bold);
}
.ll-pill--disabled {
  opacity: 0.35;
}

/* IconRow */
.ll-icon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: none;
  border: none;
  padding: 14px 18px;
  font-family: var(--ll-font-sans);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.ll-icon-row__badge {
  width: var(--ll-icon-size);
  height: var(--ll-icon-size);
  border-radius: 999px;
  background: var(--ll-icon-bg-green);
  color: var(--ll-action-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 19px;
}
.ll-icon-row__title {
  font-size: 15px;
  font-weight: var(--ll-weight-medium);
  color: var(--ll-text-primary);
}
.ll-icon-row__subtitle {
  font-size: 12px;
  color: var(--ll-text-secondary);
  margin-top: 2px;
}
.ll-icon-row__count {
  margin-left: auto;
  font-size: 13px;
  font-weight: var(--ll-weight-bold);
  color: #1c1c1e;
  background: var(--ll-streak-amber);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ProgressBar */
.ll-progress {
  width: 100%;
  border-radius: 999px;
  background: var(--ll-track-fill);
  overflow: hidden;
}
.ll-progress__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.7s ease-out;
}

/* TabBar */
.ll-tabbar {
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: var(--ll-card);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
[data-ll-theme="dark"] .ll-tabbar,
:root[data-theme="dark"] .ll-tabbar {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ll-tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 104px;
  padding: 8px 0;
  border: none;
  background: transparent;
  border-radius: var(--ll-radius-md);
  color: var(--ll-text-secondary);
  font-family: var(--ll-font-sans);
  font-size: 12px;
  font-weight: var(--ll-weight-medium);
  cursor: pointer;
  position: relative;
}
.ll-tabbar__item--selected {
  color: var(--ll-action-green);
  font-weight: var(--ll-weight-semibold);
  background: color-mix(in srgb, var(--ll-action-green) 14%, transparent);
}
:root[data-theme="dark"] .ll-tabbar__item--selected,
[data-ll-theme="dark"] .ll-tabbar__item--selected {
  background: color-mix(in srgb, var(--ll-action-green) 22%, transparent);
}
.ll-tabbar__icon {
  font-size: 20px;
  height: 24px;
  display: flex;
  align-items: center;
}
.ll-tabbar__badge {
  position: absolute;
  top: 2px;
  left: 60%;
  background: var(--ll-red);
  color: #fff;
  font-size: 11px;
  font-weight: var(--ll-weight-bold);
  border-radius: 999px;
  padding: 1px 5px;
}

/* DeckCard */
.ll-deck {
  position: relative;
  width: var(--ll-deck-card-size);
  height: var(--ll-deck-card-size);
  border-radius: var(--ll-card-radius);
  overflow: hidden;
  background: var(--ll-image-placeholder);
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  flex: 0 0 auto;
}
.ll-deck__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ll-deck__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.25) 45%,
    rgba(0, 0, 0, 0.82) 100%
  );
}
.ll-deck__label {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 10px;
  text-align: left;
}
.ll-deck__title {
  font-size: 13px;
  font-weight: var(--ll-weight-bold);
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.ll-deck__count {
  font-size: 11px;
  font-weight: var(--ll-weight-medium);
  margin-top: 2px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.ll-deck--image .ll-deck__title {
  color: #fff;
}
.ll-deck--image .ll-deck__count {
  color: rgba(255, 255, 255, 0.9);
}
/* The no-artwork fallback fills with #F0F1F3, which is a fixed light color in
   BOTH schemes — so its label must be fixed dark, not the scheme-aware text
   token. (The SwiftUI original uses Color.primary here, which goes white in
   dark mode and leaves the title unreadable on the light fill.) */
.ll-deck--plain .ll-deck__title {
  color: #1c1c1e;
  text-shadow: none;
}
.ll-deck--plain .ll-deck__count {
  color: #6b6b70;
  text-shadow: none;
}
.ll-deck--plain .ll-deck__check {
  background: rgba(0, 0, 0, 0.35);
}
.ll-deck__corner {
  position: absolute;
  top: 8px;
  right: 8px;
}
.ll-deck__check {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: var(--ll-weight-bold);
}
.ll-badge-new {
  font-size: 10px;
  font-weight: var(--ll-weight-bold);
  color: #1c1c1e;
  background: var(--ll-streak-amber);
  border-radius: 999px;
  padding: 3px 7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* PhraseCategoryCard */
.ll-phrase-cat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--ll-radius-lg);
  background: var(--ll-card);
  box-shadow: var(--ll-card-shadow-soft);
  border: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  font-family: var(--ll-font-sans);
  box-sizing: border-box;
}
.ll-phrase-cat__icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--ll-icon-bg-green);
  color: var(--ll-action-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex: 0 0 auto;
}
.ll-phrase-cat__title {
  font-size: 17px;
  font-weight: var(--ll-weight-semibold);
  color: var(--ll-text-primary);
}
.ll-phrase-cat__blurb {
  font-size: 13px;
  color: var(--ll-text-secondary);
  margin-top: 6px;
  line-height: 1.35;
}
.ll-count-pill {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: var(--ll-weight-semibold);
  color: var(--ll-action-green);
  background: var(--ll-icon-bg-green);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Flashcard */
.ll-flashcard {
  border-radius: 28px;
  background: var(--ll-card);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
  height: 340px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
}
:root[data-theme="dark"] .ll-flashcard,
[data-ll-theme="dark"] .ll-flashcard {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.ll-flashcard__media {
  width: 100%;
  height: 80px;
  border-radius: 20px;
  background: var(--ll-image-placeholder);
  flex: 0 0 auto;
  object-fit: cover;
}
.ll-flashcard__tabs {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.ll-flashcard__tab {
  font-size: 13px;
  font-weight: var(--ll-weight-semibold);
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  font-family: var(--ll-font-sans);
  background: var(--ll-divider);
  color: var(--ll-text-secondary);
}
.ll-flashcard__tab--active {
  background: var(--ll-red);
  color: #fff;
}
/* StyledText renders a <span>; without display:block the centering and top
   margin below are silently dropped wherever the parent isn't a centering
   flex container. */
.ll-flashcard__lebanese {
  display: block;
  width: 100%;
  font-size: 28px;
  font-weight: var(--ll-weight-bold);
  color: var(--ll-red);
  text-align: center;
  margin-top: 16px;
}
.ll-flashcard__arabic {
  display: block;
  width: 100%;
  font-family: var(--ll-font-arabic);
  direction: rtl;
  font-size: 20px;
  color: var(--ll-red);
  opacity: 0.85;
  text-align: center;
  margin-top: 6px;
}
.ll-flashcard__english {
  display: block;
  width: 100%;
  font-size: 28px;
  font-weight: var(--ll-weight-bold);
  color: var(--ll-text-primary);
  text-align: center;
  margin-top: 16px;
}
.ll-flashcard__speaker {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #333333;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
:root[data-theme="dark"] .ll-flashcard__speaker,
[data-ll-theme="dark"] .ll-flashcard__speaker {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* QuizAnswer */
.ll-quiz-answer {
  min-height: 60px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 8px 10px;
  background: var(--ll-card);
  color: var(--ll-text-primary);
  font-family: var(--ll-font-sans);
  font-size: 15px;
  font-weight: var(--ll-weight-semibold);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
}
.ll-quiz-answer--correct {
  background: var(--ll-correct-green);
  color: #fff;
}
.ll-quiz-answer--wrong {
  background: var(--ll-red);
  color: #fff;
}
.ll-quiz-answer__sub {
  font-size: 12px;
  font-weight: var(--ll-weight-regular);
  opacity: 0.85;
}
.ll-quiz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 520px; /* readableWidth() cap */
}

/* SessionComplete */
.ll-session {
  background: linear-gradient(
    to bottom right,
    var(--ll-celebration-from),
    var(--ll-celebration-to)
  );
  border-radius: var(--ll-radius-lg);
  padding: 40px 24px;
  text-align: center;
  font-family: var(--ll-font-sans);
  color: var(--ll-text-primary);
}
.ll-session__trophy {
  font-size: 72px;
  line-height: 1;
}
.ll-session__title {
  font-size: 30px;
  font-weight: var(--ll-weight-bold);
  margin-top: 24px;
}
.ll-session__subtitle {
  font-size: 15px;
  color: var(--ll-text-secondary);
  margin-top: 8px;
}
.ll-session__stats {
  display: flex;
  gap: 16px;
  margin-top: 32px;
}
.ll-session__stat {
  flex: 1;
  padding: 16px 0;
  border-radius: var(--ll-radius-md);
  background: color-mix(in srgb, var(--ll-card) 70%, transparent);
}
.ll-session__stat-icon {
  font-size: 20px;
}
.ll-session__stat-value {
  font-size: 22px;
  font-weight: var(--ll-weight-bold);
  margin-top: 6px;
}
.ll-session__stat-label {
  font-size: 12px;
  font-weight: var(--ll-weight-medium);
  color: var(--ll-text-secondary);
  margin-top: 6px;
}
.ll-session__xp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  background: var(--ll-action-green);
  color: #fff;
  font-size: 15px;
  font-weight: var(--ll-weight-bold);
  border-radius: 999px;
  padding: 10px 20px;
}
.ll-session__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}
