/* Hungarian flag colors */
:root {
  --flag-red: #cf2335;
  --flag-white: #f0f0f0;
  --flag-green: #3e7b45;

  --bg: var(--flag-white);
  --surface: #ffffff;
  --text: #1b1f1c;
  --muted: #5a625c;
  --border: #dcdcdc;
  --accent: var(--flag-green);
  --accent-ink: #34683a;        /* green for text on light backgrounds */
  --accent-text: #ffffff;
  --accent-soft: #e3eee4;
  --red: var(--flag-red);
  --red-soft: #fbe5e7;
  --stripe-white: #ffffff;
  --radius: 14px;
  --player-h: 196px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --surface: #1b1f1c;
    --text: #ecefec;
    --muted: #9ba49d;
    --border: #2b312d;
    --accent: #5fae68;
    --accent-ink: #7cc684;
    --accent-text: #0c140d;
    --accent-soft: #1e3321;
    --red: #ec5466;
    --red-soft: #3a1c20;
    --stripe-white: var(--flag-white);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body::before {
  content: "";
  display: block;
  height: 9px;
  background: linear-gradient(to bottom,
    var(--flag-red) 0 33.33%, var(--stripe-white) 33.33% 66.66%, var(--flag-green) 66.66% 100%);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

body.has-player .wrap { padding-bottom: calc(var(--player-h) + 24px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--accent-ink); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 48px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-block { display: block; width: 100%; margin: 6px 0 10px; }
.btn-small { min-height: 40px; padding: 8px 16px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-saved { background: var(--accent-soft); color: var(--accent-ink); }
.badge-offline { background: var(--red); color: #fff; }

/* Index */
.site-header { margin: 12px 0 16px; }
.site-header h1::after,
.tour-header h1::after {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin-top: 10px;
  border-radius: 2px;
  background: var(--red);
}
.hint { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 0.92rem; }

.tour-list { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.tour-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}
.tour-card:active { background: var(--accent-soft); }
.tour-num {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.tour-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tour-title { font-weight: 650; font-size: 1.05rem; }
.tour-sub { font-size: 0.9rem; }
.tour-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.chev { font-size: 1.6rem; color: var(--muted); }

.progress { height: 8px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* Tour page */
.topnav { margin-bottom: 4px; }
.back { display: inline-block; padding: 8px 0; text-decoration: none; font-weight: 600; }

.meta { display: grid; gap: 4px; margin: 12px 0 16px; }
.meta div { display: flex; gap: 8px; }
.meta dt { color: var(--muted); min-width: 56px; }
.meta dd { margin: 0; font-weight: 500; }

.offline-card { padding: 12px 16px; margin-bottom: 12px; }
.offline-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 2px 16px; font-size: 0.95rem; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

.section-title { margin-top: 4px; }

.chapters { list-style: none; padding: 0; margin: 0; }
.chapter { scroll-margin: 16px 0 calc(var(--player-h) + 16px); }
.chapter-btn {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 12px 8px;
  min-height: 52px;
  cursor: pointer;
}
.chapter-btn:active { background: var(--accent-soft); }
.ch-num {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  color: var(--muted);
}
.ch-title { flex: 1; }
.ch-time { font-variant-numeric: tabular-nums; }

.chapter.part .chapter-btn { padding-top: 22px; }
.chapter.part .ch-title {
  color: var(--red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}

.chapter.current .chapter-btn { background: var(--accent-soft); border-radius: 10px; }
.chapter.current .ch-num { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chapter.current .ch-title { font-weight: 650; }

/* Player */
.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.08);
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.player::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 6px;
  background: linear-gradient(to bottom,
    var(--flag-red) 0 33.33%, var(--stripe-white) 33.33% 66.66%, var(--flag-green) 66.66% 100%);
}
.player { padding-top: 18px; }
.player > * { max-width: 608px; margin-left: auto; margin-right: auto; }

.now { display: flex; flex-direction: column; min-width: 0; }
.now-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scrub { position: relative; margin: 10px auto 2px; height: 28px; }
.ticks { position: absolute; left: 10px; right: 10px; top: 50%; height: 0; pointer-events: none; z-index: 1; }
.tick { position: absolute; top: -6px; width: 2px; height: 12px; margin-left: -1px; background: var(--muted); opacity: 0.45; border-radius: 1px; }
.tick.part { background: var(--red); opacity: 0.9; height: 16px; top: -8px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  --pct: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--border) var(--pct));
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--border) var(--pct));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
  position: relative;
  z-index: 2;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
}

.times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.ctl {
  appearance: none;
  border: 0;
  background: none;
  color: var(--text);
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
}
.ctl:active { background: var(--accent-soft); }
.ctl svg { width: 28px; height: 28px; fill: currentColor; }
.ctl text { fill: currentColor; font-family: inherit; }
.ctl-play { width: 64px; height: 64px; background: var(--accent); color: var(--accent-text); }
.ctl-play:active { background: var(--accent); opacity: 0.85; }
.ctl-play svg { width: 34px; height: 34px; }
.i-pause { display: none; }
body.playing .i-play { display: none; }
body.playing .i-pause { display: block; }
