/* Worship Songs — base styles. No external fonts/frameworks; self-contained.
   Palette derived from the site's own hero imagery: warm gold light against
   deep, dramatic darkness. Gold is reserved for headings/accents/buttons —
   never small body text — to keep contrast comfortable. */

:root {
  --color-bg: #15120f;
  --color-surface: #211b15;
  --color-surface-2: #2c2419;
  --color-text: #f3ecdd;
  --color-text-muted: #b3a68f;
  --color-border: #3a3024;
  --color-primary: #aa8e64;
  --color-primary-dark: #7d6748;
  --color-primary-bright: #c6ac83;
  --color-accent: #c9781f;
  --color-danger: #d0524a;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --max-width: 1100px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Signature element: a thin gold rule with a small diamond, echoing the
   title-card treatment in the hero imagery. Used sparingly on major headings. */
.page-header h1 {
  font-family: var(--font-display);
}
.page-header h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 1px;
  background: var(--color-primary);
  margin: 0.6rem 0 0;
}

/* Homepage hero — deliberately separate from .page-header (used on every
   other page) so this centered, rule-free treatment doesn't leak elsewhere. */
.hero-header {
  text-align: center;
  margin-bottom: 1.75rem;
}
.hero-header h1 {
  font-family: var(--font-display);
  margin: 0;
  line-height: 1.3;
}
.hero-emphasis {
  display: inline-block;
  margin-top: 0.15em;
  font-size: 1.6em;
  font-weight: 700;
  color: var(--color-primary-bright);
  letter-spacing: 0.02em;
}

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

/* --- Header / nav --- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.85rem;
  line-height: 1; /* tighter than the inherited 1.5x — offsets the larger font-size so the header row doesn't grow */
  letter-spacing: 0.03em;
  color: var(--color-primary-bright); /* same flat gold as "Worship" in the hero — no gradient/glow/stroke */
}
.site-logo:hover { text-decoration: none; }

.primary-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.primary-nav a { color: var(--color-text-muted); font-weight: 500; }
.primary-nav a:hover { color: var(--color-primary); text-decoration: none; }

.nav-cta {
  background: var(--color-primary);
  color: var(--color-bg) !important;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 999px;
}
.nav-cta:hover { background: var(--color-primary-bright); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.nav-toggle-bar {
  width: 22px;
  height: 2px;
  background: var(--color-text);
  display: block;
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    gap: 0.85rem;
  }
  .primary-nav.is-open { display: flex; }
}

/* --- Layout --- */

.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: 60vh;
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin-bottom: 0.25rem; }
.page-header p { color: var(--color-text-muted); margin-top: 0; }

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 1.25rem;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 0.6rem;
}
.footer-links a { color: var(--color-text-muted); }
.footer-links a:hover { color: var(--color-primary); }

/* --- Buttons / forms --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-primary);
  color: var(--color-bg);
  border: 0;
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--color-primary-bright); text-decoration: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.form-group .hint { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400 !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--color-primary);
}

input[type="text"], input[type="email"], input[type="password"], input[type="file"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
  font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; }

.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 480px;
  box-shadow: var(--shadow);
}

.privacy-note {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  max-width: 480px;
}

.alert {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: rgba(208, 82, 74, 0.12); color: var(--color-danger); border: 1px solid rgba(208, 82, 74, 0.3); }
.alert-success { background: rgba(56, 193, 112, 0.14); color: #7ed9a8; border: 1px solid rgba(56, 193, 112, 0.35); }

/* --- Carousel ---
   Full-bleed: breaks out of .site-main's centered max-width to span the
   full viewport, independent of DOM nesting. overflow-x:hidden on body
   (set above) guards against the 100vw/scrollbar edge case. */

.carousel-outer {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: center;
}
.carousel {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 1800px; /* caps overall size on ultra-wide screens; aspect-ratio below keeps the shape correct at any size */
}
.carousel-track {
  position: relative;
  aspect-ratio: 16 / 9;
}
.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.carousel-slide.is-active { opacity: 1; pointer-events: auto; }
.carousel-trigger {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.carousel-trigger picture { display: block; width: 100%; height: 100%; }
.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom; /* protects the title text baked into the bottom of each image if any cropping is ever needed */
  transition: transform 0.4s ease, filter 0.4s ease;
}
.carousel-trigger:hover img,
.carousel-trigger:focus-visible img {
  transform: scale(1.03);
  filter: brightness(0.88);
}
@media (prefers-reduced-motion: reduce) {
  .carousel-trigger:hover img,
  .carousel-trigger:focus-visible img { transform: none; }
}
@media (max-width: 760px) {
  /* Only switches to the tall ratio once every category actually has a
     vertical image set (see .carousel.has-vertical-images in index.php) —
     otherwise a category still on its landscape fallback would get its
     16:9 image crammed into a portrait box and crop badly. */
  .carousel.has-vertical-images .carousel-track { aspect-ratio: 1090 / 1882; }
}

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-nav:hover { background: rgba(0,0,0,0.55); }
.carousel-prev { left: 0.75rem; }
.carousel-next { right: 0.75rem; }

.carousel-dots {
  position: absolute;
  bottom: 0.75rem;
  right: 1rem;
  display: flex;
  gap: 0.4rem;
}
.carousel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: 0;
  cursor: pointer;
  padding: 0;
}
.carousel-dot.is-active { background: #fff; }

/* --- Homepage: Categories + Recently Added --- */

.home-highlights {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 760px) {
  .home-highlights { grid-template-columns: 1fr; }
}

.home-highlights h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}

.category-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.category-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  min-height: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  background-size: cover;
  background-position: center bottom;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.category-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(21, 18, 15, 0.9), rgba(21, 18, 15, 0.3));
}
.category-card-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding: 1.1rem 1.25rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary-bright);
}
.category-card:hover,
.category-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--color-primary);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(170, 142, 100, 0.35);
}
@media (prefers-reduced-motion: reduce) {
  .category-card { transition: none; }
  .category-card:hover, .category-card:focus-visible { transform: none; }
}

.recent-list {
  display: flex;
  flex-direction: column;
}
/* Each row is a plain container with three independent controls (icon link,
   title link, play button) rather than one big link — see
   includes/song_list_row.php for why. */
.recent-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.6rem;
  border-radius: var(--radius);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s ease;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:hover, .recent-row:focus-within {
  background: var(--color-surface);
}
.recent-row-icon {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(170, 142, 100, 0.14);
  color: var(--color-primary);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.recent-row-icon:hover, .recent-row-icon:focus-visible {
  background: var(--color-primary);
  color: var(--color-bg);
  text-decoration: none;
}
/* Small "i" badge so the icon's purpose (song info) reads at a glance,
   without needing to tap it first to find out — matters on touch devices,
   which never get a hover tooltip. Sits on top of the note icon rather
   than replacing it. */
.recent-row-icon-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-bg);
  border: 2px solid var(--color-bg);
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.recent-row-body {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
}
.recent-row-body:hover, .recent-row-body:focus-visible {
  text-decoration: none;
}
.recent-row-body:hover .recent-row-title,
.recent-row-body:focus-visible .recent-row-title {
  color: var(--color-primary-bright);
}
.recent-row-title {
  font-family: var(--font-display);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}
.recent-row-meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-row-play {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.recent-row-play:hover, .recent-row-play:focus-visible {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}
.recent-row-play .icon-pause { display: none; }
.recent-row-play.is-playing {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}
.recent-row-play.is-playing .icon-play { display: none; }
.recent-row-play.is-playing .icon-pause { display: block; }

/* --- Now Playing bar: site-wide mini player that opens when a play button
   in any song list (Recently Added / category pages / All Songs) is
   pressed. Markup lives in includes/footer.php so it's on every page;
   assets/js/list-player.js drives it. Slides up from the bottom, stays
   until closed or navigated away from. */
.now-playing-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.now-playing-bar.is-open { transform: translateY(0); }
.now-playing-info {
  flex-shrink: 0;
  max-width: 30%;
  min-width: 0;
}
.now-playing-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.now-playing-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-playing-bar audio { flex: 1; min-width: 0; height: 40px; }
.now-playing-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.now-playing-close:hover, .now-playing-close:focus-visible {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
body.has-now-playing { padding-bottom: 76px; }
@media (max-width: 640px) {
  .now-playing-info { max-width: 40%; }
  .now-playing-label { display: none; }
  body.has-now-playing { padding-bottom: 68px; }
}

/* --- Song list grid (category pages + All Songs) ---
   Reuses the .recent-row row styling (defined above) inside a responsive
   grid: 1 column when there's not much content or room, 2 when there's
   enough of both — no per-page column choice needed. */

.song-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 2rem;
  max-width: 900px;
  margin: 0 auto;
}

/* --- Lightbox (carousel tap-to-enlarge) --- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}
.lightbox[hidden] { display: none; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.lightbox-close:hover { background: rgba(0, 0, 0, 0.65); }

/* --- Song detail --- */

.song-detail-header { margin-bottom: 1.5rem; }
.song-detail-header .category-tag {
  display: inline-block;
  background: rgba(170, 142, 100, 0.14);
  color: var(--color-primary-bright);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.player-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.player-bar audio { width: 100%; }
#playlist-shuffle-toggle.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.playlist-track-btn.is-active { font-weight: 700; text-decoration: underline; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.detail-section { margin-bottom: 1.5rem; }
.detail-section h2 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.detail-section .body-text { white-space: pre-wrap; color: var(--color-text); }

.login-prompt {
  background: rgba(201, 120, 31, 0.1);
  border: 1px solid rgba(201, 120, 31, 0.3);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.login-prompt a { font-weight: 600; }

/* --- Playlists --- */

.playlist-list { list-style: none; padding: 0; margin: 0; }
.playlist-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}
.playlist-list li:last-child { border-bottom: none; }

.song-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}
.song-row:last-child { border-bottom: none; }
.song-row .song-row-title { font-weight: 600; }
.song-row .song-row-actions { display: flex; gap: 0.5rem; align-items: center; }

/* --- Share widget --- */

.share-wrap { position: relative; display: inline-block; }
.share-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 30;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.5rem;
  min-width: 200px;
}
.share-menu.is-open { display: block; }
.share-menu button, .share-menu a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text);
  font-size: 0.9rem;
}
.share-menu button:hover, .share-menu a:hover { background: var(--color-surface-2); text-decoration: none; }
.share-feedback { font-size: 0.8rem; color: var(--color-text-muted); padding: 0.3rem 0.6rem 0; }

/* --- Tables (admin) --- */

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}
table.admin-table th { background: var(--color-bg); font-weight: 700; }
table.admin-table tr:last-child td { border-bottom: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary-bright);
}
.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 3rem 1rem;
}
