/* ==========================================================================
   Koby's Legacy — Memorial Website Stylesheet
   --------------------------------------------------------------------------
   A dignified, warm, calm memorial for the Sephardic Jewish liturgical
   recordings of Koby Benlolo ז״ל.

   Design notes:
   - Mobile-first: base styles target small screens; media queries enhance
     for wider viewports.
   - No web fonts / @font-face / external assets — fully offline, works on
     both file:// and a normal web server.
   - All theme colors live in :root custom properties so the family can
     re-theme the whole site from one place.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Theme tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette */
  --color-bg: #f6f1e7;          /* parchment / cream background */
  --color-surface: #fffdf8;     /* slightly lighter card/surface */
  --color-surface-alt: #efe8d8; /* alternating / hover surface */
  --color-text: #23314e;        /* deep navy / charcoal text */
  --color-text-soft: #5a6378;   /* muted secondary text */
  --color-gold: #b3924f;        /* muted gold accent */
  --color-gold-soft: #cdb37e;   /* lighter gold for borders/hover */
  --color-border: #e0d6c2;      /* soft warm border */
  --color-border-strong: #cdbfa3;
  --color-focus: #6f87bf;       /* visible focus ring (cool, calm) */
  --color-playing-bg: #f0ead9;  /* highlight for now-playing row */

  /* Typography */
  --font-serif: Georgia, 'Cormorant Garamond', 'Times New Roman', serif;
  --font-sans: -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Spacing / sizing */
  --max-width: 1180px;
  --player-height: 132px;       /* reserved space so content isn't hidden */
  --radius: 8px;
  --shadow-soft: 0 1px 3px rgba(35, 49, 78, 0.08);
  --shadow-raised: 0 -2px 14px rgba(35, 49, 78, 0.12);
}

/* --------------------------------------------------------------------------
   Reset / base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Smooth in-page anchoring without jarring jumps */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  /* Bottom padding reserves room for the fixed player bar so the last
     recordings are never hidden behind it. */
  padding-bottom: calc(var(--player-height) + 1rem);
  /* Layered, warm parchment background (pure CSS — no images, works offline).
     A soft light highlight + a faint gold glow near the top give gentle depth,
     over a subtle vertical cream gradient. Fixed so it stays calm on scroll. */
  background-color: var(--color-bg);
  background-image:
    radial-gradient(1200px 620px at 50% -8%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 62%),
    radial-gradient(1000px 560px at 50% 2%, rgba(179, 146, 79, 0.07), rgba(179, 146, 79, 0) 70%),
    linear-gradient(180deg, #f9f4ec 0%, #f4eddf 55%, #f0e8d6 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text);
}

a {
  color: var(--color-gold);
}

/* Container helper used by header and main */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* --------------------------------------------------------------------------
   Accessibility helpers
   -------------------------------------------------------------------------- */

/* Visually hidden but available to screen readers. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Skip link: hidden until focused, then slides into view. */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 1000;
  background: var(--color-text);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 0.15s ease-in-out;
}
.skip-link:focus {
  top: 1rem;
}

/* Consistent, clearly visible focus indicator for keyboard users. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Header / hero
   -------------------------------------------------------------------------- */
.site-header {
  /* A gentle luminous wash at the very top, fading into the page, with a
     hairline gold accent under the header to lift it from the parchment. */
  background:
    radial-gradient(720px 280px at 50% -40%, rgba(179, 146, 79, 0.10), rgba(179, 146, 79, 0) 70%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.75) 0%, rgba(246, 241, 231, 0) 100%);
  border-bottom: 1px solid var(--color-gold-soft);
  box-shadow: 0 1px 0 rgba(179, 146, 79, 0.18);
  text-align: center;
  padding: 2.75rem 0 2.25rem;
}

.hero-motif {
  /* The inline-SVG candle/flame motif. */
  display: block;
  margin: 0 auto 0.75rem;
  width: 46px;
  height: 64px;
}
.hero-motif .flame {
  /* Gentle, slow flicker — disabled for users who prefer reduced motion. */
  transform-origin: center bottom;
  animation: flicker 3.2s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.95; transform: scaleY(1); }
  50%      { opacity: 1;    transform: scaleY(1.06); }
}

.hero-title {
  margin: 0.25rem 0 0.35rem;
  font-size: 2.6rem;
  letter-spacing: 0.5px;
}

.hero-subtitle {
  margin: 0 0 1.25rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--color-text-soft);
}

/* Ornamental divider: a hairline with a centered gold diamond. */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.25rem auto;
  max-width: 360px;
  color: var(--color-gold);
}
.ornament::before,
.ornament::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold-soft), transparent);
}
.ornament .diamond {
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  background: var(--color-gold);
  flex: 0 0 auto;
}

.dedication {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  font-size: 1.05rem;
  color: var(--color-text-soft);
  line-height: 1.7;
}

/* Hero stats (total recordings + total listening time). */
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
}
.hero-stats .stat {
  min-width: 120px;
}
.hero-stats .stat-number {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.7rem;
  color: var(--color-gold);
  line-height: 1.1;
}
.hero-stats .stat-label {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
}

/* --------------------------------------------------------------------------
   Layout: nav + main content
   -------------------------------------------------------------------------- */
.layout {
  display: block;
  margin-top: 1.5rem;
}

/* Mobile nav toggle (hamburger). Hidden on wider screens. */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.nav-toggle:hover {
  background: var(--color-surface-alt);
}
.nav-toggle .bars {
  display: inline-block;
  width: 18px;
  height: 12px;
  position: relative;
}
.nav-toggle .bars,
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  border-top: 2px solid currentColor;
}
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
}
.nav-toggle .bars::before { top: 4px; }
.nav-toggle .bars::after  { top: 9px; }

/* Category navigation panel */
.category-nav {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
}
.category-nav h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-soft);
  margin: 0.25rem 0.5rem 0.75rem;
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.category-list li {
  margin: 0;
}

/* Buttons used as category / subcategory selectors. */
.cat-btn,
.subcat-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text);
  font: inherit;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  line-height: 1.3;
}
.cat-btn:hover,
.subcat-btn:hover {
  background: var(--color-surface-alt);
}

/* The active (selected) category/subcategory. */
.cat-btn.is-active,
.subcat-btn.is-active {
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--color-gold);
}

.cat-btn .label,
.subcat-btn .label {
  flex: 1 1 auto;
}

/* The little count pill next to each category. */
.count-pill {
  flex: 0 0 auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-soft);
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.cat-btn.is-active .count-pill,
.subcat-btn.is-active .count-pill {
  border-color: var(--color-gold-soft);
  color: var(--color-gold);
}

/* Sub-list under "Holidays". Collapsed by default via [hidden]. */
.subcat-list {
  list-style: none;
  margin: 0.15rem 0 0.4rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--color-border);
}
.subcat-btn {
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
}

/* Caret indicator for the expandable Holidays item. */
.caret {
  display: inline-block;
  margin-left: 0.4rem;
  transition: transform 0.15s ease;
  color: var(--color-text-soft);
  flex: 0 0 auto;
}
.cat-btn[aria-expanded="true"] .caret {
  transform: rotate(90deg);
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */
.search-area {
  margin-bottom: 1.25rem;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}
.search-field .search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--color-text-soft);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.4rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
}
.search-input::placeholder {
  color: var(--color-text-soft);
}
.search-clear {
  position: absolute;
  right: 0.4rem;
  background: transparent;
  border: none;
  color: var(--color-text-soft);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  border-radius: 6px;
}
.search-clear:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Main content / recording list
   -------------------------------------------------------------------------- */
.content-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}
.content-title {
  font-size: 1.55rem;
  margin: 0;
}
.content-meta {
  color: var(--color-text-soft);
  font-size: 0.95rem;
}

/* Friendly state messages (empty catalog / no search results). */
.notice {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--color-text-soft);
  font-size: 1.05rem;
}

/* The recordings list. */
.recording-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.recording-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.recording-row:last-child {
  border-bottom: none;
}
.recording-row:hover {
  background: var(--color-surface-alt);
}

/* Currently-playing row highlight. */
.recording-row.is-playing {
  background: var(--color-playing-bg);
  box-shadow: inset 3px 0 0 var(--color-gold);
}

/* Small play/now-playing glyph at the start of each row. */
.row-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gold);
}
.recording-row.is-playing .row-icon {
  color: var(--color-gold);
}

.row-main {
  flex: 1 1 auto;
  min-width: 0; /* allow text-overflow to work inside flex */
}
.row-title {
  display: block;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.row-category {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-soft);
}
.row-duration {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-soft);
  font-size: 0.92rem;
}

/* The animated "playing" bars shown on the active row. */
.equalizer {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}
.equalizer span {
  width: 3px;
  background: var(--color-gold);
  animation: eq 1s ease-in-out infinite;
}
.equalizer span:nth-child(1) { height: 6px;  animation-delay: 0s;    }
.equalizer span:nth-child(2) { height: 14px; animation-delay: 0.2s;  }
.equalizer span:nth-child(3) { height: 9px;  animation-delay: 0.4s;  }
@keyframes eq {
  0%, 100% { transform: scaleY(0.5); }
  50%      { transform: scaleY(1); }
}

/* --------------------------------------------------------------------------
   Player bar (fixed at bottom)
   -------------------------------------------------------------------------- */
.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-raised);
  padding: 0.6rem 1rem;
}

.player-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem 1rem;
  align-items: center;
}

/* Now-playing text block. */
.player-now {
  min-width: 0;
}
.player-track-title {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-track-cat {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Transport buttons (prev / play / next). */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}
.player-btn:hover:not(:disabled) {
  background: var(--color-surface-alt);
  border-color: var(--color-gold-soft);
}
.player-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.player-btn svg {
  width: 18px;
  height: 18px;
}
/* The main play/pause button is a touch larger and gold-accented. */
.player-btn.play-pause {
  width: 50px;
  height: 50px;
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: #fff;
}
.player-btn.play-pause:hover:not(:disabled) {
  background: #a3823f;
  border-color: #a3823f;
}
.player-btn.play-pause svg {
  width: 22px;
  height: 22px;
}

/* Seek / progress area. */
.player-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--color-text-soft);
  min-width: 3.2em;
  text-align: center;
}

/* Range inputs: seek + volume. Kept simple and accessible. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--color-border);
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-gold-soft);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-gold);
}
input[type="range"]:disabled {
  opacity: 0.5;
  cursor: default;
}
.seek-slider {
  flex: 1 1 auto;
}

/* Volume control. */
.player-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}
.player-volume svg {
  width: 18px;
  height: 18px;
  color: var(--color-text-soft);
  flex: 0 0 auto;
}
.volume-slider {
  width: 100px;
  flex: 0 0 auto;
}

/* Right-side auxiliary cluster: volume + autoplay toggle share the last cell. */
.player-aux {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
}

/* Autoplay on/off switch (role="switch"). */
.player-autoplay {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.autoplay-label {
  font-size: 0.82rem;
  color: var(--color-text-soft);
  white-space: nowrap;
}
.switch {
  position: relative;
  width: 42px;
  height: 23px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}
.switch-track {
  display: block;
  width: 42px;
  height: 23px;
  border-radius: 999px;
  background: var(--color-border-strong);
  transition: background 0.15s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(35, 49, 78, 0.3);
  transition: left 0.15s ease;
}
.switch[aria-checked="true"] .switch-track {
  background: var(--color-gold);
}
.switch[aria-checked="true"] .switch-thumb {
  left: 22px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  color: var(--color-text-soft);
  border-top: 1px solid var(--color-border);
  margin-top: 2rem;
}
.footer-hebrew {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}
.footer-translation {
  font-style: italic;
  margin: 0 0 1rem;
}
.footer-note {
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

/* --------------------------------------------------------------------------
   Responsive enhancements
   -------------------------------------------------------------------------- */

/* On narrow screens the nav is collapsed by default and toggled by the
   hamburger. The [hidden] attribute (set by JS) fully hides it. */
@media (max-width: 819px) {
  .category-nav.is-collapsed {
    display: none;
  }
}

/* Tablet / desktop: two-column layout, persistent nav, richer player. */
@media (min-width: 820px) {
  /* Hide the hamburger; nav is always visible. */
  .nav-toggle {
    display: none;
  }

  .layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    align-items: start;
  }

  /* Keep nav in view while scrolling the recordings. */
  .category-nav {
    position: sticky;
    top: 1rem;
    margin-bottom: 0;
    max-height: calc(100vh - var(--player-height) - 2rem);
    overflow-y: auto;
  }

  /* Player bar lays out as a single row with proportional regions. */
  .player-inner {
    grid-template-columns: minmax(160px, 1fr) auto minmax(220px, 2fr) auto;
    gap: 1.25rem;
  }
  .player-progress {
    grid-column: auto;
  }
}

/* Reserve a bit less bottom space on wide screens where the player is shorter. */
@media (min-width: 820px) {
  :root {
    --player-height: 92px;
  }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-motif .flame,
  .equalizer span {
    animation: none;
  }
  .skip-link,
  .caret {
    transition: none;
  }
}
