/* ===== Theme ===== */
:root {
  --bg: #f7f4ec;
  --surface: #ffffff;
  --surface-2: #efe9db;
  --text: #1d2a25;
  --muted: #5d6b64;
  --line: #e2dccb;
  --brand: #123a2f;      /* deep green */
  --brand-2: #1d5747;
  --accent: #b58a2e;     /* gold */
  --on-accent: #1b1407;  /* text on an accent background */
  --header-accent: var(--accent);  /* subtitle in the header */
  --on-brand: #f7f1e1;
  --shadow: 0 1px 2px rgba(18, 58, 47, .06), 0 6px 20px rgba(18, 58, 47, .08);
  --radius: 14px;
  --link: var(--brand-2);
  color-scheme: light;
}
/* The page opens in the Blue theme (data-theme="blue" on <html>) unless the visitor picks another in Settings.
   "System" removes data-theme: light below, or dark when the device is in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e1513;
    --surface: #16201d;
    --surface-2: #1d2a26;
    --text: #e9e6dc;
    --muted: #9fada6;
    --line: #26342f;
    --brand: #0b2620;
    --brand-2: #2c7a64;
    --accent: #d8b15a;
    --on-brand: #f1ead6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
    --link: var(--accent);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513;
  --surface: #16201d;
  --surface-2: #1d2a26;
  --text: #e9e6dc;
  --muted: #9fada6;
  --line: #26342f;
  --brand: #0b2620;
  --brand-2: #2c7a64;
  --accent: #d8b15a;
  --on-brand: #f1ead6;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
  --link: var(--accent);
}
:root[data-theme="blue"] {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-2: #e5edf7;
  --text: #15233a;
  --muted: #586780;
  --line: #d4deeb;
  --brand: #14396b;      /* navy */
  --brand-2: #1e58a3;
  --accent: #2c6fcb;     /* blue */
  --on-accent: #ffffff;
  --header-accent: #9cc4ff;
  --on-brand: #eef4ff;
  --shadow: 0 1px 2px rgba(20, 57, 107, .06), 0 6px 20px rgba(20, 57, 107, .1);
  --link: var(--brand-2);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.header-inner {
  display: flex; align-items: center; gap: 16px;
  padding-top: 12px; padding-bottom: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { flex: none; padding: 0; border: 0; background: none; border-radius: 10px; line-height: 0; }
.brand-icon img { border-radius: 10px; transition: transform .15s; }
.brand-icon:hover img { transform: scale(1.06); }
.brand-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; text-decoration: none; }
.brand strong {
  font: 600 22px/1.1 "Cormorant Garamond", Georgia, serif; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand small { color: var(--header-accent); font-size: 12px; letter-spacing: .4px; }

.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 0 14px; height: 40px; width: min(340px, 45vw);
}
.search:focus-within { background: rgba(255,255,255,.16); border-color: var(--accent); }
.search svg { width: 18px; height: 18px; fill: currentColor; opacity: .75; flex: none; }
.search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0;
  color: var(--on-brand); font-size: 15px;
}
.search input::placeholder { color: rgba(247,241,225,.65); }

/* ===== Categories menu (hamburger) ===== */
.menu { position: relative; flex: none; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px 0 12px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: transparent; color: var(--on-brand);
  font-size: 14px; font-weight: 600; max-width: 260px;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: rgba(255,255,255,.1); border-color: var(--accent); }
.menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bars { display: inline-flex; flex-direction: column; justify-content: space-between; width: 18px; height: 13px; flex: none; }
.bars span { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s, opacity .2s; }
.menu-btn[aria-expanded="true"] .bars span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .bars span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
.menu-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  width: 300px; max-height: min(70vh, 560px); overflow-y: auto; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.menu-panel[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 10px; text-decoration: none; font-size: 15px;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item[aria-current="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.menu-item .n { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.menu-item[aria-current="true"] .n { color: var(--on-accent); background: rgba(255,255,255,.35); }
.menu-item.empty-cat { color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ===== Content ===== */
main { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.intro h1 {
  margin: 0; font: 600 34px/1.15 "Cormorant Garamond", Georgia, serif; color: var(--text);
}
.intro p { margin: 4px 0 20px; color: var(--muted); }

.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  display: flex; flex-direction: column; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; padding: 0; color: inherit; box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden;
}
.thumb img, .thumb video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: var(--on-brand); font: 600 18px/1.2 "Cormorant Garamond", Georgia, serif;
}
.play {
  position: absolute; left: 12px; bottom: 12px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: grid; place-items: center;
  transition: background .15s;
}
.play::before {
  content: ""; margin-left: 3px; border-style: solid; border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #fff;
}
.card:hover .play { background: var(--accent); }
.badge {
  position: absolute; right: 10px; top: 10px; font-size: 11px; font-weight: 600; letter-spacing: .3px;
  background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 6px;
}
.card-body { padding: 12px 14px 14px; }
.card-cat { font-size: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.card-title { margin: 2px 0 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.card-views { margin-top: 4px; font-size: 12px; color: var(--muted); }
.card-views:empty { display: none; }
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-count { flex: none; font-size: 13px; font-weight: 600; color: var(--muted); }

.section-head {
  grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.section-head h2 { margin: 0; font: 600 26px/1.2 "Cormorant Garamond", Georgia, serif; }
.section-count { font-size: 13px; color: var(--muted); }
.section-head a { font-size: 14px; color: var(--link); text-decoration: none; font-weight: 600; }

.group-card { text-decoration: none; }
.group-card .thumb::after {   /* stacked look: a second "card" peeking behind the cover */
  content: ""; position: absolute; inset: 0; box-shadow: inset 0 -4px 0 var(--accent); pointer-events: none;
}
.back-link { color: var(--link); font-weight: 600; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; padding-top: 16px; padding-bottom: 20px; }

/* ===== Player ===== */
dialog#player {
  width: min(1100px, 100vw - 32px); max-width: none; padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--text); overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
dialog#player::backdrop { background: rgba(5, 12, 10, .82); }
.player-media { aspect-ratio: 16 / 9; background: #000; }
.player-media video { -webkit-touch-callout: none; user-select: none; }
.player-media video, .player-media iframe { width: 100%; height: 100%; display: block; border: 0; background: #000; }
.player-info { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 16px; }
.player-views { font-size: 12px; color: var(--muted); }
.player-views:not(:empty)::before { content: " · "; }
.player-cat { font-size: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.player-info h2 { margin: 2px 0 0; font: 600 24px/1.2 "Cormorant Garamond", Georgia, serif; }
.player-actions { display: flex; gap: 6px; flex: none; }
.player-actions button {
  height: 36px; min-width: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 14px;
}
.player-actions button:hover { border-color: var(--accent); }
.player-actions button:disabled { opacity: .35; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
}

/* ===== Small screens ===== */
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; }
  .search { width: 100%; margin-left: 0; order: 3; }
  .brand { flex: 1; }
  .menu-label { display: none; }
  .menu-btn { width: 40px; padding: 0; justify-content: center; }
  .menu-panel { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; }
  .brand strong { font-size: 20px; }
  .intro h1 { font-size: 28px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-title { font-size: 14px; }
  .play { width: 32px; height: 32px; left: 8px; bottom: 8px; }
  .play::before { border-width: 6px 0 6px 10px; }
  .thumb .ph { font-size: 15px; padding-bottom: 36px; }
  dialog#player { width: 100vw; max-height: 100vh; border-radius: 0; margin: auto 0; }
  .player-info { flex-direction: column; }
  .player-info h2 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }

/* ===== Custom video player (no browser menu / download) ===== */
.vplayer { position: relative; width: 100%; height: 100%; background: #000; outline: none; overflow: hidden; }
.vplayer video { width: 100%; height: 100%; display: block; object-fit: contain; cursor: pointer; }
.vplayer.idle, .vplayer.idle video { cursor: none; }
.vp-btn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #fff;
}
.vp-btn svg { width: 22px; height: 22px; fill: currentColor; }
.vp-btn:hover { background: rgba(255,255,255,.14); }
.vp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.vp-big {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 72px; height: 72px; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.vp-big svg { width: 36px; height: 36px; margin-left: 4px; }
.vplayer.paused .vp-big { opacity: 1; pointer-events: auto; }
.vp-big:hover { background: var(--accent); }
.vp-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px;
  padding: 24px 10px 8px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  transition: opacity .25s;
}
.vplayer.idle:not(.paused) .vp-bar { opacity: 0; pointer-events: none; }
.vp-time { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.vp-seek, .vp-vol { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; cursor: pointer; background: rgba(255,255,255,.3); }
.vp-seek { flex: 1; min-width: 60px; background: linear-gradient(to right, var(--accent) var(--p, 0%), rgba(255,255,255,.3) var(--p, 0%)); }
.vp-vol { width: 80px; }
.vp-seek::-webkit-slider-thumb, .vp-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.vp-seek::-moz-range-thumb, .vp-vol::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.vp-spinner {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; display: none;
  border: 4px solid rgba(255,255,255,.25); border-top-color: var(--accent); border-radius: 50%; animation: vp-spin .9s linear infinite;
}
.vplayer.loading .vp-spinner { display: block; }
@keyframes vp-spin { to { transform: rotate(360deg); } }
.vplayer:fullscreen { width: 100vw; height: 100vh; }
.vplayer:-webkit-full-screen { width: 100vw; height: 100vh; }
@media (max-width: 640px) { .vp-vol { display: none; } .vp-time { font-size: 12px; } }

/* ===== Home: one featured video per category ===== */
.feature { display: flex; flex-direction: column; gap: 8px; }
.feature .card { flex: 1; }
.feature-link { font-size: 14px; font-weight: 600; color: var(--link); text-decoration: none; padding: 0 4px; }
.feature-link:hover { text-decoration: underline; }
.shuffle-btn {
  margin-left: 6px; padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.shuffle-btn:hover { border-color: var(--accent); }

/* ===== Settings dialog ===== */
dialog#settings {
  width: min(380px, 100vw - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.settings-box { padding: 18px 20px 20px; }
dialog#settings::backdrop { background: rgba(5, 12, 10, .6); }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-head h2 { margin: 0; font: 600 26px/1.2 "Cormorant Garamond", Georgia, serif; }
.settings-close {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 14px;
}
.settings-close:hover { border-color: var(--accent); }
.settings-row { margin: 0; padding: 14px 0; border: 0; border-top: 1px solid var(--line); }
.settings-row legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 600; }
.seg { clear: both; display: flex; padding: 3px; gap: 3px; background: var(--surface-2); border-radius: 999px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 7px 0; border-radius: 999px; font-size: 14px; cursor: pointer; color: var(--muted);
}
.seg input:checked + span { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-version { display: flex; justify-content: space-between; padding-bottom: 0; }
.settings-install { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-install span { display: block; font-weight: 600; }
.settings-install small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.install-btn {
  flex: none; height: 36px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 600;
}
.install-btn:hover { filter: brightness(1.08); }
.install-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.install-btn[hidden] { display: none; }
.settings-version span { font-weight: 600; }
.settings-version strong { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
