/* Bíbliuskúlin Keldan · audio library. Shared styles for the player and admin pages.
   Palette: warm parchment neutrals; navy, slate and light blue from the logo; the book's red as accent. */

:root {
  --bg: #f6f1e8;
  --bg-deep: #ede5d6;
  --surface: #fffcf7;
  --surface-2: #f1eadd;
  --text: #1f242b;
  --muted: #6d675d;
  --border: #e3d9c7;
  --navy: #15234a;
  --navy-2: #24407a;
  --blue: #004c94;
  --slate: #8296a9;
  --sky: #c0d7e9;
  --sky-soft: #e4edf5;
  --red: #891a22;
  --red-soft: #f3e2e0;
  --accent: var(--navy);
  --accent-contrast: #fbf7ef;
  --accent-soft: var(--sky-soft);
  --link: #1d4f8a;
  --success: #3b7a52;
  --danger: #a3271f;
  --shadow: 0 1px 2px rgba(48, 36, 18, 0.06), 0 8px 24px rgba(48, 36, 18, 0.08);
  --radius: 14px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --player-height: 140px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1b1e;
    --bg-deep: #141518;
    --surface: #23252a;
    --surface-2: #2c2f36;
    --text: #ece6da;
    --muted: #a49d90;
    --border: #383b44;
    --accent: #a9c4de;
    --accent-contrast: #101b33;
    --accent-soft: #26354a;
    --red: #d8685f;
    --red-soft: #3a2a2a;
    --link: #9fc0e6;
    --success: #7cc394;
    --danger: #e3837a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1b1e;
  --bg-deep: #141518;
  --surface: #23252a;
  --surface-2: #2c2f36;
  --text: #ece6da;
  --muted: #a49d90;
  --border: #383b44;
  --accent: #a9c4de;
  --accent-contrast: #101b33;
  --accent-soft: #26354a;
  --red: #d8685f;
  --red-soft: #3a2a2a;
  --link: #9fc0e6;
  --success: #7cc394;
  --danger: #e3837a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: var(--player-height); }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1200px 400px at 50% -100px, var(--bg-deep), transparent 70%);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  padding-bottom: calc(var(--player-height) + env(safe-area-inset-bottom));
}
body.admin { padding-bottom: 48px; }
a { color: var(--link); }
button { font: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 0.35em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 2.5vw + 1rem, 2.4rem); }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.container { max-width: 920px; margin: 0 auto; padding: 20px 16px; }

/* header */
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
header.top .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
header.top .brand img { height: 40px; width: auto; display: block; }
header.top .brand .logo-chip { display: inline-flex; padding: 4px 8px; border-radius: 8px; background: #fffcf7; }
header.top .brand .sub { font-family: var(--font-display); font-size: 1.05rem; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }
header.top nav { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
header.top nav .btn.small { min-height: 36px; }
.theme-toggle { font-size: 1.05rem; width: 36px; }
@media (max-width: 480px) { header.top .brand .sub { display: none; } header.top .brand img { height: 34px; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.9rem; border-radius: 8px; }
.btn.icon { width: 40px; padding: 0; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* forms */
label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row.cols-2 { grid-template-columns: 1fr 1fr; } .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, section + section { margin-top: 18px; }

/* hero */
.hero { padding: 8px 0 18px; }
.hero h1 { margin-bottom: 0.2em; }
.hero p { color: var(--muted); max-width: 52ch; margin-bottom: 0; }

/* continue listening */
.continue {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.continue .play-circle {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 1.2rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(137, 26, 34, 0.3);
}
.continue .play-circle:hover { filter: brightness(1.08); }
.continue .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.continue .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue .course { color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue .bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.continue .bar > span { display: block; height: 100%; background: var(--red); }
.continue .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
@media (max-width: 480px) { .continue { grid-template-columns: 48px 1fr; } .continue .time { display: none; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; }
.toolbar .search { flex: 1 1 200px; }

/* course cards: all the same size */
.course-grid { display: grid; gap: 14px; grid-template-columns: 1fr; grid-auto-rows: 1fr; list-style: none; padding: 0; margin: 0; }
@media (min-width: 620px) { .course-grid { grid-template-columns: 1fr 1fr; } }
.course-card {
  display: grid; grid-template-columns: 52px 1fr; height: 100%; min-height: 76px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform 0.15s ease, border-color 0.15s ease;
}
.course-card:hover { transform: translateY(-2px); border-color: var(--slate); }
.course-card .spine {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: rgba(255, 255, 255, 0.9);
  background: var(--spine, var(--navy));
  background-image: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(0,0,0,0.12));
}
.course-card .body { padding: 10px 14px; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.course-card h2 { font-size: 1.05rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-card .line { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-card .teacher { color: var(--muted); margin-top: 3px; }
.badge { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); margin-left: 6px; }

/* course view */
.course-head { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 18px; }
.course-head .crumbs a { text-decoration: none; }
.course-head .stats { color: var(--muted); font-size: 0.95rem; }
.course-head .desc { max-width: 60ch; }
.course-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* track list */
.track-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.track {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px 12px 10px; border: 0; border-top: 1px solid var(--border); border-left: 4px solid transparent;
  width: 100%; text-align: left; background: none; color: inherit; cursor: pointer;
}
li:first-child > .track { border-top: 0; }
.track:hover { background: var(--surface-2); }
.track[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--red); }
.track .num {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums;
}
.track[aria-current="true"] .num { background: var(--red); color: #fff; }
.track .num.done { background: var(--success); color: #fff; }
.track .title { font-weight: 600; }
.track .sub { color: var(--muted); font-size: 0.875rem; }
.track .dur { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.track .progress-mini { height: 3px; background: var(--border); border-radius: 2px; margin-top: 7px; overflow: hidden; max-width: 260px; }
.track .progress-mini > span { display: block; height: 100%; background: var(--red); }
.track .listened { font-size: 0.78rem; color: var(--success); margin-left: 8px; }

/* player bar */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(0,0,0,0.08);
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
}
.player .inner { max-width: 920px; margin: 0 auto; }
.player .now { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.player .now .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.player .now .c { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.85rem; }
.player .seek { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 2px 0; font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); }
.player input[type="range"] { width: 100%; accent-color: var(--red); height: 28px; margin: 0; }
.player .controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.player .controls .center { display: flex; align-items: center; justify-content: center; gap: 8px; }
.player .controls .btn { border-radius: 999px; }
.player .controls .play { width: 56px; height: 56px; font-size: 1.4rem; background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(137, 26, 34, 0.3); }
.player .controls .play:hover { filter: brightness(1.08); }
.player .controls svg, .ic { width: 1.2em; height: 1.2em; fill: currentColor; display: block; }
.player .controls .play svg { width: 26px; height: 26px; }
.player .controls .play .ic-pause { display: none; }
.player .controls .play.playing .ic-play { display: none; }
.player .controls .play.playing .ic-pause { display: block; }
.continue .play-circle svg { width: 24px; height: 24px; fill: currentColor; }
.track .num .ic { width: 14px; height: 14px; }
.player .controls .skip { width: 46px; height: 46px; font-size: 0.78rem; line-height: 1; font-weight: 600; }
.player .controls .edge { width: 40px; height: 40px; font-size: 0.95rem; }
.player .speed { justify-self: end; min-height: 36px; min-width: 60px; font-variant-numeric: tabular-nums; font-weight: 600; }
.player.empty .seek, .player.empty .controls { opacity: 0.45; pointer-events: none; }
@media (max-width: 560px) {
  .player .inner { position: relative; }
  .player .now { padding-right: 72px; }
  .player .speed { position: absolute; right: 0; top: -2px; min-width: 62px; min-height: 32px; padding: 0 8px; font-size: 0.85rem; }
  .player .controls { grid-template-columns: 1fr; }
  .player .controls > span:first-child { display: none; }
  .player .controls .center { gap: 6px; }
  .player .controls .play { width: 52px; height: 52px; }
  .player .controls .skip { width: 42px; height: 42px; }
  .player .controls .edge { width: 36px; height: 36px; }
}

/* admin */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px 16px; text-align: center; color: var(--muted);
  background: var(--surface-2); cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.upload-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.upload-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.upload-item .fname { font-size: 0.85rem; color: var(--muted); word-break: break-all; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--red); transition: width 0.15s linear; }
.status { font-size: 0.85rem; margin-top: 4px; }
.status.ok { color: var(--success); }
.status.err { color: var(--danger); }

.admin-tracks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.admin-track {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
}
.admin-track.dragging { opacity: 0.4; }
.admin-track.drop-before { border-top: 3px solid var(--accent); }
.admin-track .handle { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.admin-track .info .title { font-weight: 600; }
.admin-track .info .sub { font-size: 0.85rem; color: var(--muted); }
.admin-track .ops { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.admin-track .editor { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--border); }
.container.admin-wide { max-width: 1240px; }
.course-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 18px; }
@media (min-width: 960px) { .admin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; } }
.admin-grid > section { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--player-height) + 12px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 20; max-width: 90vw; font-size: 0.95rem;
}
body.admin .toast { bottom: 24px; }
.toast.err { background: var(--danger); color: #fff; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
