/* Avenue brand */
:root {
  --blue: #1a3cfa;
  --blue-soft: #e8ecff;
  --orange: #ff9601;
  --green: #2fbf71;
  --lightblue: #3aa3f5;
  --yellow: #ffd93b;
  --ink: #545454;
  --muted: #737373;
  --line: #d9dce3;
  --bg: #f5f6fa;
  --accent: var(--blue);
  --accent-text: var(--blue);
  --accent-soft: var(--blue-soft);
  --card-bg: #ffffff;
  --radius: 18px;
  --heading-font: 'century-gothic', 'Jost', 'Century Gothic', 'Futura', 'Trebuchet MS', sans-serif;
  --body-font: 'Heebo', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@font-face {
  font-family: 'Jost';
  src: url('../fonts/jost.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Heebo';
  src: url('../fonts/heebo.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body-font);
  -webkit-font-smoothing: antialiased;
}

.noscript { padding: 2rem; text-align: center; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-back {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  cursor: pointer;
  flex: none;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex: 1;
}
.brand-logo {
  flex: none;
  display: block;
  height: 26px;
  width: auto;
}
.brand-logo.small { height: 18px; margin-left: auto; }
.topbar-title {
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-picker {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 4px 6px;
}

/* ---------- Home: module list ---------- */
.home {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}
.home-heading {
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.35rem;
  margin: 6px 2px 2px;
}
.home-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 2px 18px;
}
.module-list { display: grid; gap: 12px; }
.module-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(20, 30, 90, 0.06);
  transition: transform 0.08s ease;
}
.module-tile:active { transform: scale(0.98); }
.module-tile-art { flex: none; width: 64px; height: auto; border-radius: 10px; }
.module-tile-text { min-width: 0; flex: 1; }
.module-tile-title {
  display: block;
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--accent-text);
  font-size: 1.05rem;
  line-height: 1.25;
}
.module-tile-meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.module-tile-arrow { flex: none; color: var(--accent); }

/* ---------- Icon chips ---------- */
.chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}
.chip svg { width: 62%; height: 62%; }
.chip.orange { background: var(--orange); }
.chip.green { background: var(--green); }
.chip.lightblue { background: var(--lightblue); }
.chip.yellow { background: var(--yellow); color: var(--ink); }
.chip.round { border-radius: 50%; }

/* ---------- Card viewer ---------- */
.viewer {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 57px - env(safe-area-inset-top));
}
.deck-label {
  text-align: center;
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 12px 16px 4px;
}
.carousel {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 14px;
  padding: 10px 16px 6px;
}
.carousel::-webkit-scrollbar { display: none; }
.card-slide {
  flex: none;
  width: 100%;
  max-width: 480px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
}
@media (min-width: 520px) {
  .card-slide { width: calc(100% - 40px); margin: 0 auto; }
  .carousel { justify-content: safe center; }
}

/* The card itself — mirrors the printed card chrome */
.card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid #c9ccd6;
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(20, 30, 90, 0.08);
  padding: 20px 18px 44px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.card-title {
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--accent-text);
  font-size: clamp(1.15rem, 5.5vw, 1.45rem);
  line-height: 1.25;
  text-align: center;
  margin: 2px 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.card-badge {
  display: inline-grid;
  place-items: center;
  width: 1.5em; height: 1.5em;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72em;
}
.title-decoration { display: block; margin: 0 auto 8px; }
.card-body { display: grid; gap: 16px; margin-top: 12px; }

/* Standard section */
.section { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.section-num {
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--accent-text);
}
.section-head-row { display: flex; align-items: baseline; gap: 6px; }
.section-heading {
  font-family: var(--body-font);
  font-weight: 700;
  color: var(--accent-text);
  font-size: 1rem;
  line-height: 1.3;
}
.section.accent .section-heading { color: var(--orange); font-size: 0.92rem; }
.section-subheading {
  font-weight: 700;
  color: var(--orange);
  font-size: 0.85rem;
  margin-top: 1px;
}
.section-bullets {
  margin: 5px 0 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.45;
}
.section-bullets li { margin: 2px 0; }
.section-bullets b { color: var(--ink); }
.subsection-label {
  font-weight: 700;
  color: var(--orange);
  font-size: 0.85rem;
  margin-top: 6px;
}

/* Letters layout (PADL) */
.letter-section { display: grid; gap: 4px; }
.letter-row { display: flex; align-items: center; gap: 2px; }
.letter-chip {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: 1.5rem;
}
.letter-word {
  font-family: var(--body-font);
  font-weight: 700;
  color: var(--accent-text);
  font-size: 1.15rem;
}
.letter-text { color: var(--ink); font-size: 0.9rem; line-height: 1.45; margin: 2px 0 0 2px; }

/* Ladder layout */
.ladder { position: relative; display: grid; gap: 10px; padding: 6px 10px; }
.ladder::before, .ladder::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 5px;
  border-radius: 3px;
  background: var(--orange);
}
.ladder::before { left: 0; }
.ladder::after { right: 0; }
.ladder-rung {
  border-top: 4px solid var(--orange);
  padding: 8px 8px 8px;
  font-weight: 700;
  color: var(--accent-text);
  font-size: 0.88rem;
}
.ladder-rung:last-child { border-bottom: 4px solid var(--orange); }

/* Card footer branding */
.card-footer {
  position: absolute;
  right: 14px; bottom: 10px;
  text-align: right;
}
.card-footer .copyright {
  display: block;
  color: var(--muted);
  font-size: 0.6rem;
  margin-top: 2px;
}

/* Dots + nav */
.viewer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
}
.dots { display: flex; gap: 7px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line);
  border: none;
  padding: 0;
  cursor: pointer;
}
.dot.active { background: var(--accent); }
.nav-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  cursor: pointer;
}
.nav-btn:disabled { opacity: 0.35; }

/* Not-translated notice */
.notice {
  max-width: 520px;
  margin: 24px auto;
  padding: 18px;
  background: #fff8ec;
  border: 1px solid #ffd9a0;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 0.9rem;
  text-align: center;
}
