/* ==========================================================
   Impara l'Italiano · shared stylesheet
   Dark-gray background with white Italian text for readability;
   green is kept only as a structural accent on titles and pills.
   Font sizes are ~1.2x the previous tokens.
   ========================================================== */

:root {
  --green: #4FBF6A;
  --green-dim: #1F7A38;
  --red: #E63946;
  --white: #FFFFFF;
  --bg: #2A2A2E;         /* dark gray page background */
  --card: #3A3A3E;       /* lifted surface on top of --bg */
  --card2: #45454A;
  --border: rgba(255,255,255,0.10);
  --text: #FFFFFF;       /* body text — white for max legibility */
  --muted: #B5B5B8;      /* secondary text — lighter than before against the gray bg */
  --r: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg) !important; margin: 0; padding: 0; }

body {
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; background: none; border: none; color: inherit; cursor: pointer; }

/* ── Header ── */
.header {
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 22px 20px;
  background: linear-gradient(155deg, rgba(0,102,51,0.18) 0%, var(--bg) 60%);
  position: relative;
  overflow: hidden;
  border-bottom: 0.5px solid var(--border);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}
.back-btn,
.menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--card);
  border: 0.5px solid var(--border);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.back-btn { font-size: 26px; }
.menu-btn:active { background: rgba(79,191,106,.12); }
.brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: .12em;
  color: var(--green);
  text-transform: uppercase;
}

/* ── Slide-in category drawer ── */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 1000;
}
.drawer-scrim.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 84vw);
  background: var(--card);
  border-right: 0.5px solid var(--border);
  transform: translateX(-100%);
  transition: transform .22s ease;
  z-index: 1001;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 0 calc(env(safe-area-inset-bottom, 0px) + 20px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.drawer.open {
  transform: translateX(0);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.drawer-brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: .04em;
  color: var(--green);
  padding: 6px 22px 16px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 10px;
}
.drawer-section {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 22px 6px;
}
.drawer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.drawer-item:hover {
  background: rgba(79,191,106,0.06);
}
.drawer-item.active {
  color: var(--green);
  background: rgba(79,191,106,0.10);
  border-left-color: var(--green);
  font-weight: 600;
}
.drawer-item-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.drawer-item.active .drawer-item-count {
  color: var(--green);
}
.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 53px;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--green);
  margin-top: 14px;
}
.subtitle {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 6px;
  letter-spacing: .02em;
}

/* ── Tile grid (landing) ── */
.tiles {
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tile {
  display: block;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 22px 20px;
  position: relative;
  overflow: hidden;
  transition: transform .12s, border-color .12s;
}
.tile:active { transform: scale(0.985); }
.tile-emoji {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 10px;
}
.tile-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 34px;
  letter-spacing: .04em;
  color: var(--green);
  margin-bottom: 4px;
}
.tile-desc {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.5;
}
.tile-count {
  position: absolute;
  top: 20px;
  right: 20px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  color: var(--white);
  opacity: 0.6;
  letter-spacing: .02em;
}

/* ── Category pills (phrases + flashcards) ── */
.pills-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(42,42,46,0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 12px 16px 12px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pills-bar::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 0.5px solid var(--border);
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}
.pill.active {
  background: var(--green);
  color: var(--bg);
  border-color: var(--green);
}

/* ── Phrase list ── */
.phrase-list { padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 10px; }
.phrase-card {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  cursor: pointer;
}
.phrase-it {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 31px;
  color: var(--white);
  letter-spacing: .02em;
  line-height: 1.15;
}
.phrase-en {
  font-size: 18px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.phrase-note {
  font-size: 16px;
  color: var(--muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0.5px solid var(--border);
  line-height: 1.5;
  display: none;
}
.phrase-card.expanded .phrase-note { display: block; }

/* ── Flashcards ── */
.flashcard-wrap {
  flex: 1;
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.flashcard-progress {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.flashcard-progress b { color: var(--green); font-weight: 700; }
.flashcard {
  flex: 1;
  min-height: 360px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s;
}
.flashcard-side-label {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .18em;
  text-transform: uppercase;
}
.flashcard-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 53px;
  color: var(--white);
  line-height: 1.1;
  letter-spacing: .02em;
}
.flashcard-text.en {
  font-family: 'DM Sans', sans-serif;
  font-size: 31px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0;
}
.flashcard-hint {
  position: absolute;
  bottom: 14px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .08em;
}
.flashcard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action-btn {
  padding: 15px 12px;
  border-radius: var(--r);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: filter .15s;
}
.action-btn:active { filter: brightness(0.85); }
.action-review { background: var(--card); border: 0.5px solid var(--border); color: var(--text); }
.action-know { background: var(--green); color: var(--bg); }
.action-restart {
  background: var(--card);
  border: 0.5px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 auto;
  display: block;
}

/* ── Stories list ── */
.story-list { padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.story-card {
  display: block;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  transition: transform .12s;
}
.story-card:active { transform: scale(0.985); }
.story-level {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 6px;
}
.story-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 31px;
  color: var(--white);
  letter-spacing: .02em;
  line-height: 1.15;
}
.story-title-en {
  font-size: 16px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .04em;
}
.story-desc {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 10px;
}

/* ── Story reader ── */
.story-body { padding: 16px 20px 40px; }
.story-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 22px;
  padding: 4px;
  margin: 0 auto 18px;
  width: fit-content;
}
.mode-btn {
  padding: 9px 18px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.mode-btn.active { background: var(--green); color: var(--bg); }
.sentence {
  padding: 16px 0;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
}
.sentence:last-of-type { border-bottom: none; }
.sentence-it {
  font-size: 22px;
  color: var(--white);
  line-height: 1.5;
}
.sentence-en {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
  display: none;
}
body[data-mode="bilingual"] .sentence-en,
.sentence.revealed .sentence-en {
  display: block;
}

.glossary {
  margin-top: 30px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
}
.glossary-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 12px;
}
.glossary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 18px;
}
.glossary-row:last-child { border-bottom: none; }
.glossary-it { color: var(--white); font-weight: 500; }
.glossary-en { color: var(--muted); }

/* ── Empty / loading ── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 18px;
}

/* ── Desktop / tablet ── */
@media (min-width: 700px) {
  body { max-width: 720px; }
  .tiles { padding: 32px 32px 24px; }
  .title { font-size: 67px; }
}
