/* Hebrew Learning App — Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@300;400;700;900&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap');

:root {
  --ink: #0d1117;
  --paper: #f5f0e8;
  --gold: #c8a84b;
  --gold-light: #e8ca75;
  --accent: #1B4F8A;
  --accent-light: #2a6bbf;
  --muted: #5a5248;
  --muted-light: #8a8078;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.18);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.12);
  --ink-2: #161b22;
  --ink-3: #1e242c;
  --success: #2d9e5f;
  --danger: #c0392b;
  --nav-height: 68px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--ink);
  color: var(--paper);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1 { font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--muted-light); line-height: 1.6; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

/* ── Hebrew text ── */
.hebrew {
  font-family: 'Frank Ruhl Libre', serif;
  direction: rtl;
  font-size: min(15vw, 96px);
  line-height: 1.1;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}
.hebrew-sm {
  font-family: 'Frank Ruhl Libre', serif;
  direction: rtl;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
}
.hebrew-md {
  font-family: 'Frank Ruhl Libre', serif;
  direction: rtl;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
}
.hebrew-ui {
  font-family: 'Frank Ruhl Libre', serif;
  direction: rtl;
  font-size: 1.2rem;
  font-weight: 400;
}

/* ── Layout ── */
.page-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-header {
  padding: 20px 16px 12px;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.card-dark {
  background: var(--ink-2);
  color: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid rgba(200, 168, 75, 0.15);
}

.card-gold-border {
  border: 2px solid var(--gold);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-gold {
  background: var(--gold);
  color: var(--ink);
}
.btn-gold:hover { background: var(--gold-light); transform: translateY(-1px); }
.btn-gold:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 2px solid var(--gold);
}
.btn-outline:hover { background: rgba(200, 168, 75, 0.1); }

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #d44; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #3ab870; }

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
}

/* ── Set filter bar ── */
.set-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.set-filter::-webkit-scrollbar { display: none; }

.set-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: 1.5px solid rgba(200,168,75,0.3);
  background: transparent;
  color: var(--muted-light);
  transition: all 0.15s;
}
.set-btn.active, .set-btn:hover {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--ink-2);
  border-top: 1px solid rgba(200, 168, 75, 0.2);
  display: flex;
  align-items: stretch;
  z-index: 100;
  max-width: 640px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.15s;
  padding: 6px 0;
}
.nav-item:hover { color: var(--paper); }
.nav-item.active { color: var(--gold); }

.nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

/* ── Progress bar ── */
.progress-bar-wrap {
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 99px;
  transition: width 0.35s ease;
}

/* ── Progress ring (SVG) ── */
.progress-ring {
  transform: rotate(-90deg);
}
.progress-ring__track {
  fill: none;
  stroke: rgba(200,168,75,0.15);
}
.progress-ring__fill {
  fill: none;
  stroke: var(--gold);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

/* ── Stat chips ── */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(200,168,75,0.12);
  border: 1px solid rgba(200,168,75,0.25);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
}

/* ── Tags / badges ── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.tag-gold    { background: rgba(200,168,75,0.18); color: var(--gold); }
.tag-accent  { background: rgba(27,79,138,0.25);  color: #6baed6; }
.tag-muted   { background: rgba(255,255,255,0.07); color: var(--muted-light); }
.tag-success { background: rgba(45,158,95,0.18);  color: #5fba8c; }

/* ── Section separator ── */
.section-sep {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 16px 0;
}

/* ── Grid utilities ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ── Mode cards on dashboard ── */
.mode-card {
  background: var(--ink-2);
  border-radius: var(--radius);
  border: 1px solid rgba(200,168,75,0.13);
  padding: 18px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, transform 0.15s;
}
.mode-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  color: var(--paper);
}
.mode-card-icon { font-size: 2rem; }
.mode-card-name { font-weight: 600; font-size: 0.9rem; }
.mode-card-sub  { font-size: 0.75rem; color: var(--muted-light); }

/* ── Streak card ── */
.streak-card {
  background: linear-gradient(135deg, #1a1200, #2a1e00);
  border: 1px solid rgba(200,168,75,0.35);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.streak-flame { font-size: 2.4rem; }
.streak-count { font-size: 2rem; font-weight: 900; color: var(--gold); line-height: 1; }
.streak-label { font-size: 0.78rem; color: var(--muted-light); }

/* ── Toast notification ── */
.badge-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-2);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
.badge-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.badge-toast-icon { font-size: 1.5rem; }

/* ── Utility ── */
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--muted-light); }
.text-center { text-align: center; }
.text-small  { font-size: 0.82rem; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(200,168,75,0.25); border-radius: 2px; }

/* ── Focus visible ── */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ═══════════════════════════════════════════
   LANDSCAPE PHONE — compact nav + safe areas
   Targets: width > height AND height ≤ 500px
   (portrait phones are ~700-900px tall — this
    only fires on actual landscape orientation)
   ═══════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --nav-height: 48px;
  }

  .bottom-nav {
    height: var(--nav-height);
  }

  .nav-item {
    font-size: 0.6rem;
    gap: 1px;
    padding: 4px 0;
  }

  .nav-icon {
    font-size: 1.05rem;
  }

  /* Badge toast clears the shrunken nav */
  .badge-toast {
    bottom: calc(var(--nav-height) + 10px);
  }
}

/* ── Safe area insets (iPhone notch / Dynamic Island) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
}

/* ── Responsive max-width: center content on tablets/desktop ── */
@media (min-width: 641px) {
  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 640px;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  body {
    max-width: 640px;
    margin: 0 auto;
  }
}
