/* --- Design tokens (Todd Wagner Ministries brand) --- */
:root {
  --black:   #000000;
  --dark:    #161616;
  --dark-2:  #1d1d1d;
  --dark-3:  #242424;
  --line:    #2a2a2a;
  --tan:     #c7c3b9;
  --white:   #ffffff;
  --muted:   #9a9a95;
  --muted-2: #6f6f6a;
  --orange:  #de6738;
  --orange-hover: #e87547;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;

  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Poppins', 'Inter', sans-serif;

  --sidebar-w: 280px;
  --player-h: 120px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html { background: var(--dark); }
body {
  background: var(--dark);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding-bottom: var(--player-h);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(22,22,22,0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; }
.brand-sig { height: 42px; width: auto; display: block; }

.topnav { display: flex; gap: 4px; margin-left: 32px; flex: 1; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 100px;
  transition: all 0.15s;
}
.nav-link:hover { color: var(--white); }
.nav-link.active { color: var(--white); background: var(--dark-3); }
.topbar-meta { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.count {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}

/* --- Layout --- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
}

/* --- Daily landing --- */
.daily {
  min-height: calc(100vh - var(--topbar-h) - var(--player-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  position: relative;
  overflow: hidden;
}
.daily::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(222, 103, 56, 0.14), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(199, 195, 185, 0.06), transparent 55%);
  pointer-events: none;
  z-index: 0;
}
.daily-inner {
  max-width: 780px;
  width: 100%;
  position: relative;
  z-index: 1;
  text-align: left;
}
.daily-eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 28px;
}
.daily-date { color: var(--orange); font-weight: 600; }
.daily-sep { color: var(--muted-2); }
.daily-cycle { color: var(--muted); }
.daily-label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 5vw, 52px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 20px;
  color: var(--tan);
  text-transform: uppercase;
}
.daily-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(22px, 3.2vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--white);
}
.daily-meta {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 18px;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  align-items: center;
}
.daily-meta .scripture { color: var(--tan); }
.daily-meta .series { color: var(--white); }
.daily-meta .date { color: var(--muted); }
.daily-meta .dot { width: 3px; height: 3px; background: var(--muted-2); border-radius: 50%; display: inline-block; }
.daily-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 36px;
  max-width: 640px;
}
.daily-actions {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center;
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--orange);
  color: var(--white);
  border: 0;
  padding: 14px 28px;
  border-radius: 100px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 6px 24px -8px rgba(222,103,56,0.5);
}
.btn-primary:hover { background: var(--orange-hover); transform: translateY(-1px); box-shadow: 0 10px 28px -8px rgba(222,103,56,0.6); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.playing { background: var(--white); color: var(--dark); }
.btn-primary svg { flex-shrink: 0; }

.btn-ghost {
  display: inline-flex; align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 14px 20px;
  border-radius: 100px;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.02em;
}
.btn-ghost:hover { color: var(--white); background: var(--dark-2); }

/* --- Sidebar --- */
.sidebar {
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex; flex-direction: column; gap: 18px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.search input {
  width: 100%;
  background: var(--dark-2);
  border: 1px solid var(--line);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.search input:focus { outline: none; border-color: var(--orange); }
.search input::placeholder { color: var(--muted-2); }

.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--dark-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
}
.toggle {
  background: transparent; color: var(--muted);
  border: 0; padding: 8px 10px;
  font-family: inherit; font-size: 12px;
  font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer; transition: all 0.15s;
}
.toggle:hover { color: var(--white); }
.toggle.active { background: var(--orange); color: var(--white); }

.source-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.pill {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 100px;
  font-family: inherit; font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { color: var(--white); border-color: var(--muted-2); }
.pill.active { background: var(--white); color: var(--dark); border-color: var(--white); }

.facet-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 4px;
  min-height: 0;
}
.facet-list::-webkit-scrollbar { width: 6px; }
.facet-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.facet {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--white);
  font-size: 13px;
  transition: background 0.1s;
  user-select: none;
  line-height: 1.35;
}
.facet:hover { background: var(--dark-2); }
.facet.active { background: var(--orange); color: var(--white); }
.facet.active:hover { background: var(--orange-hover); }
.facet .name {
  flex: 1; min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.facet .n { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-left: 8px; }
.facet.active .n { color: rgba(255,255,255,0.75); }
.facet.all-facet { font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 4px; padding-bottom: 10px; }
.facet.pinned-facet { font-weight: 500; }
.facet.pinned-facet + .facet:not(.pinned-facet) { margin-top: 6px; position: relative; }
.facet.pinned-facet + .facet:not(.pinned-facet)::before {
  content: ''; position: absolute; top: -4px; left: 10px; right: 10px;
  height: 1px; background: var(--line);
}

/* --- List --- */
.list-wrap { padding: 28px 32px 32px; min-width: 0; }
.list-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.list-header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0;
  text-transform: uppercase;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sort select {
  background: var(--dark-2); color: var(--white);
  border: 1px solid var(--line);
  padding: 6px 28px 6px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%239a9a95' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.sort select:focus { outline: none; border-color: var(--orange); }

.list { display: flex; flex-direction: column; gap: 2px; }

.row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  border: 0; outline: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.row:hover { background: var(--dark-2); }
.row:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.row.playing { background: var(--dark-2); }
.row.playing .play-small { background: var(--orange); color: var(--white); }
.row.playing .row-title { color: var(--orange); }

.play-small {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--dark-2);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.play-small svg { width: 14px; height: 14px; margin-left: 2px; }
.row:hover .play-small { background: var(--orange); border-color: var(--orange); }

.row-body { min-width: 0; }
.row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta .sep { color: var(--muted-2); margin: 0 6px; }
.row-meta .scripture { color: var(--tan); }

.row-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 180px; }
.row-tags .tag {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 100px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.row-tags .tag.rtrq { border-color: var(--orange); color: var(--orange); }

.list-sentinel { height: 40px; }

.loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--dark);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 100;
}
.loading.hidden { display: none; }
[hidden] { display: none !important; }

/* --- Player --- */
.player {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--player-h);
  background: rgba(13,13,13,0.95);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(250px, 2fr) auto;
  grid-template-rows: auto auto;
  gap: 10px 22px;
  align-items: center;
  padding: 16px 24px;
  z-index: 30;
}
.player[hidden] { display: none; }

.player-meta {
  grid-row: 1 / 3;
  min-width: 0;
}
.np-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.np-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.player-controls {
  grid-row: 1 / 3;
  display: flex; align-items: center; gap: 10px;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--white);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--dark-3); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.play {
  background: var(--white);
  color: var(--dark);
  width: 48px; height: 48px;
}
.icon-btn.play:hover { background: var(--orange); color: var(--white); }
.icon-btn.play svg { width: 22px; height: 22px; }

.player-scrub {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; width: 38px; flex-shrink: 0; }
.time:last-of-type { text-align: right; }
#scrub {
  flex: 1; min-width: 0;
  -webkit-appearance: none; appearance: none;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  background: var(--white);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s;
}
#scrub::-webkit-slider-thumb:hover { background: var(--orange); transform: scale(1.2); }
#scrub::-moz-range-thumb {
  width: 12px; height: 12px;
  background: var(--white);
  border: 0; border-radius: 50%; cursor: pointer;
}

.player-right {
  grid-row: 1 / 3;
  display: flex; align-items: center; gap: 6px;
}
.rate-btn {
  background: var(--dark-2);
  border: 1px solid var(--line);
  color: var(--white);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 56px;
  text-align: center;
}
.rate-btn:hover { border-color: var(--orange); color: var(--orange); }
.rate-btn.fast { background: var(--orange); border-color: var(--orange); color: var(--white); }

#ytHost {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  :root { --sidebar-w: 0; --player-h: 148px; }
  .layout { grid-template-columns: 1fr; }
  .topnav { margin-left: 16px; gap: 2px; }
  .nav-link { padding: 6px 10px; font-size: 11px; }
  .daily { padding: 28px 20px; align-items: flex-start; padding-top: 60px; }
  .daily-inner { text-align: left; }
  .daily-eyebrow { margin-bottom: 20px; }
  .daily-desc { margin-bottom: 28px; }
  body[data-view="archive"] .mobile-filters-btn { display: flex; }
  body[data-view="daily"] .mobile-filters-btn { display: none !important; }
  .sidebar {
    position: fixed;
    inset: var(--topbar-h) 0 auto 0;
    height: auto; max-height: calc(100vh - var(--topbar-h));
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--dark);
    z-index: 15;
    transform: translateY(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateY(0); }
  .list-wrap { padding: 20px 16px 24px; }
  .list-header h1 { font-size: 18px; }
  .row-tags { display: none; }
  .player {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    padding: 12px 14px;
    gap: 8px 12px;
  }
  .player-meta { grid-column: 1; grid-row: 1; }
  .player-controls { grid-column: 1 / 3; grid-row: 2; justify-content: center; }
  .player-scrub { grid-column: 1 / 3; grid-row: 3; }
  .player-right { grid-column: 2; grid-row: 1; }
  .icon-btn.close { display: none; }
  .topbar-meta { display: none; }
}

.mobile-filters-btn {
  display: none;
}
@media (max-width: 900px) {
  .mobile-filters-btn {
    display: flex;
    align-items: center; gap: 6px;
    background: var(--dark-2);
    border: 1px solid var(--line);
    color: var(--white);
    padding: 7px 12px;
    border-radius: 100px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
}
