/* ============================================================================
   BUBAPC — "Ember"
   A warm, editorial theme laid entirely on Bootstrap 5.3 primitives.

   Nothing here re-implements a Bootstrap component. Colours, radii and
   shadows are published as --bs-* tokens, so every built-in (btn, card,
   badge, alert, table, form, dropdown…) picks up the brand on its own.
   The custom classes exist only where Bootstrap has no primitive:
     · colour helpers  (.text-*, .bg-*, .border-*, .badge-*)
     · the two button accents this site uses (.btn-gold, .btn-soft)
     · a short list of bespoke pieces the markup already calls by name
       (brand mark, drop zone, devotional article, reading bar, stat tile).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Fonts — Fraunces and Plus Jakarta Sans ship as variable files, so one
   face covers every weight. Declaring a fixed 400 was why headings looked flat:
   the browser was synthesising bold instead of using the real axis.
   --------------------------------------------------------------------------- */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../webfonts/fraunces-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('../webfonts/plus-jakarta-sans-latin.woff2') format('woff2');
}

/* ---------------------------------------------------------------------------
   2. Design tokens.
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --bs-font-sans-serif: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.65;

  /* Surfaces */
  --bs-body-bg: #fdf8f1;
  --bs-body-bg-rgb: 253, 248, 241;
  --bs-body-color: #3a2b20;
  --bs-body-color-rgb: 58, 43, 32;
  --bs-heading-color: #2b1f16;
  --bs-secondary-color: #8a7561;
  --bs-secondary-bg: #f5ecdf;
  --bs-tertiary-bg: #f8f0e5;
  --bs-border-color: rgba(58, 43, 32, 0.14);
  --bs-border-color-translucent: rgba(58, 43, 32, 0.08);

  /* Brand — terracotta */
  --bs-primary: #b0522b;
  --bs-primary-rgb: 176, 82, 43;
  --bs-primary-text-emphasis: #7a3517;
  --bs-primary-bg-subtle: #f7e2d6;
  --bs-primary-border-subtle: #ecc2ab;

  /* Accent — gold */
  --bs-warning: #eaa23c;
  --bs-warning-rgb: 234, 162, 60;
  --bs-warning-text-emphasis: #8a5a12;
  --bs-warning-bg-subtle: #fdefd5;
  --bs-warning-border-subtle: #f8d99c;

  --bs-dark: #2b1f16;
  --bs-dark-rgb: 43, 31, 22;

  /* Links */
  --bs-link-color-rgb: var(--bs-primary-rgb);
  --bs-link-hover-color-rgb: 122, 53, 23;
  --bs-link-decoration: none;

  /* Shape */
  --bs-border-radius: 0.6rem;
  --bs-border-radius-sm: 0.4rem;
  --bs-border-radius-lg: 0.9rem;
  --bs-border-radius-xl: 1.15rem;
  --bs-border-radius-xxl: 1.5rem;

  /* Depth */
  --bs-box-shadow-sm: 0 1px 2px rgba(43, 31, 22, 0.07), 0 7px 16px -6px rgba(43, 31, 22, 0.20);
  --bs-box-shadow: 0 2px 5px rgba(43, 31, 22, 0.09), 0 15px 32px -12px rgba(43, 31, 22, 0.30);
  --bs-box-shadow-lg: 0 4px 10px rgba(43, 31, 22, 0.11), 0 26px 54px -18px rgba(43, 31, 22, 0.40);

  /* Theme extras */
  --brand-deep: #4a2413;
  --gold: var(--bs-warning);
  --gold-dark: #a96a17;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --snap: 0.18s var(--ease);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bs-body-bg: #1e1510;
  --bs-body-bg-rgb: 30, 21, 16;
  --bs-body-color: #f3e8d6;
  --bs-body-color-rgb: 243, 232, 214;
  --bs-heading-color: #fdf5e6;
  --bs-emphasis-color: #fff;
  --bs-secondary-color: #c3ad93;
  --bs-secondary-bg: #2a1e17;
  --bs-tertiary-bg: #2f221a;
  --bs-border-color: rgba(255, 240, 220, 0.13);
  --bs-border-color-translucent: rgba(255, 240, 220, 0.08);

  --bs-primary-text-emphasis: #eda884;
  --bs-primary-bg-subtle: #3a2316;
  --bs-primary-border-subtle: #5b3722;
  --bs-warning-text-emphasis: #f3cf87;
  --bs-warning-bg-subtle: #382c12;
  --bs-warning-border-subtle: #5c461c;

  --bs-link-color-rgb: 230, 156, 116;
  --bs-link-hover-color-rgb: 244, 186, 150;

  --brand-deep: #33200f;
  --gold-dark: #e7b768;

  --bs-box-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px -14px rgba(0, 0, 0, 0.6);
  --bs-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), 0 18px 38px -20px rgba(0, 0, 0, 0.7);
  --bs-box-shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5), 0 30px 60px -28px rgba(0, 0, 0, 0.75);

  --bs-navbar-color: rgba(255, 255, 255, 0.78);
  --bs-navbar-hover-color: #fff;
  --bs-navbar-active-color: #fff;
}

/* ---------------------------------------------------------------------------
   3. Base & typography.
   --------------------------------------------------------------------------- */
body {
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  letter-spacing: -0.015em;
  font-optical-sizing: auto;
}

.text-uppercase { letter-spacing: 0.06em; }
hr { opacity: 0.14; }
::selection { background: rgba(var(--bs-primary-rgb), 0.22); }

/* ---------------------------------------------------------------------------
   4. Links.
   --------------------------------------------------------------------------- */
a {
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.08em;
  transition: color var(--snap);
}
a:not(.btn):not(.nav-link):not(.navbar-brand):not(.dropdown-item):not(.page-link):not(.list-group-item):not(.badge):hover {
  text-decoration: underline;
  text-decoration-color: rgba(var(--bs-link-color-rgb), 0.5);
}

/* ---------------------------------------------------------------------------
   5. Buttons — every Bootstrap button becomes a pill with centred content.
   --------------------------------------------------------------------------- */
.btn {
  --bs-btn-border-radius: var(--bs-border-radius-pill);
  --bs-btn-font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  transition: transform var(--snap), box-shadow var(--snap), color var(--snap),
              background-color var(--snap), border-color var(--snap);
}
.btn:active { transform: translateY(1px); }
.btn-lg { --bs-btn-font-size: 1.05rem; }
/* Icon-only buttons are square, so a circle never turns into an ellipse. */
.btn.rounded-circle {
  --bs-btn-padding-x: 0;
  --bs-btn-padding-y: 0;
  width: 2.5rem;
  height: 2.5rem;
}
.btn-sm.rounded-circle { width: 2rem; height: 2rem; }
.btn-lg.rounded-circle { width: 3rem; height: 3rem; }

.btn-gold {
  --bs-btn-color: #3a2a1c;
  --bs-btn-bg: var(--bs-warning);
  --bs-btn-border-color: var(--bs-warning);
  --bs-btn-hover-color: #3a2a1c;
  --bs-btn-hover-bg: #dd9527;
  --bs-btn-hover-border-color: #dd9527;
  --bs-btn-active-color: #3a2a1c;
  --bs-btn-active-bg: #cf8a1f;
  --bs-btn-active-border-color: #cf8a1f;
  --bs-btn-focus-shadow-rgb: var(--bs-warning-rgb);
}

.btn-soft {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-bg: rgba(var(--bs-primary-rgb), 0.12);
  --bs-btn-border-color: rgba(var(--bs-primary-rgb), 0.12);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--bs-primary);
  --bs-btn-active-border-color: var(--bs-primary);
  --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

/* Input groups: give only the outer ends a pill radius so a text field lines
   up with the pill buttons and icon addons it sits beside. */
.input-group > :first-child {
  border-start-start-radius: var(--bs-border-radius-pill);
  border-end-start-radius: var(--bs-border-radius-pill);
}
.input-group > :last-child {
  border-start-end-radius: var(--bs-border-radius-pill);
  border-end-end-radius: var(--bs-border-radius-pill);
}

/* Form fields take the same pill shape as the buttons, so a field and the
   button beside it line up. Textareas keep a softer radius, because a pill
   would bow the text once it wraps onto a second line. */
.form-control:not(textarea),
.form-select {
  border-radius: var(--bs-border-radius-pill);
}

/* ---------------------------------------------------------------------------
   6. Badges & colour helpers.
   --------------------------------------------------------------------------- */
.badge { --bs-badge-font-weight: 600; }

.bg-brand { background-color: var(--bs-primary) !important; }
.bg-brand-deep { background-color: var(--brand-deep) !important; }
.bg-brand-soft { background-color: rgba(var(--bs-primary-rgb), 0.12) !important; }
.bg-gold { background-color: var(--bs-warning) !important; }

.text-brand { color: var(--bs-primary) !important; }
.text-gold { color: var(--gold) !important; }
.text-gold-dark { color: var(--gold-dark) !important; }
.text-bg-brand { color: #fff !important; background-color: var(--bs-primary) !important; }

[data-theme="dark"] .text-primary,
[data-theme="dark"] .text-brand,
[data-theme="dark"] .stat-icon.text-primary { color: var(--bs-primary-text-emphasis) !important; }

.badge-gold {
  --bs-badge-color: #3a2a1c;
  color: #3a2a1c !important;
  background-color: var(--bs-warning) !important;
}

.brand-band { --bs-breadcrumb-divider-color: rgba(255, 255, 255, 0.55); }
.brand-band .breadcrumb-item a { color: rgba(255, 255, 255, 0.85); }
.brand-band .breadcrumb-item a:hover { color: #fff; }
.brand-band .breadcrumb-item.active { color: #fff; }

/* ---------------------------------------------------------------------------
   7. Cards.
   --------------------------------------------------------------------------- */
.card {
  --bs-card-border-width: 0;
  --bs-card-cap-bg: transparent;
  --bs-card-title-color: var(--bs-heading-color);
  box-shadow: var(--bs-box-shadow-sm);
  transition: transform var(--snap), box-shadow var(--snap);
}
[data-theme="dark"] .card .text-dark { color: var(--bs-body-color) !important; }

/* Song & artist cards: square, uniform artwork with a gentle zoom on hover. */
.song-card, .artist-card { overflow: hidden; }
.song-card .card-img-top,
.artist-card .card-img-top {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.45s var(--ease);
}
@media (hover: hover) {
  .song-card:hover, .artist-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--bs-box-shadow) !important;
  }
  .song-card:hover .card-img-top,
  .artist-card:hover .card-img-top { transform: scale(1.05); }
}

.song-card-controls { padding-top: 0.25rem; }
.song-card-controls .btn-play-song { min-width: 2.4rem; }
.song-card-controls .btn-outline-secondary,
.song-card-controls .btn-outline-danger {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
}
.card-actions { display: inline-flex; gap: 0.35rem; }

/* Dashboard stat tile. */
.stat-card .card-body { gap: 1rem; }
.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--bs-border-radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex: 0 0 auto;
}
/* The tile is one link, so the whole card lifts rather than the label alone
   underlining itself. The card's own transition carries it, and hover is
   guarded so a phone never gets a number that sticks 3px down after a tap. */
@media (hover: hover) {
  .stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bs-box-shadow) !important;
  }
}

/* ---------------------------------------------------------------------------
   8. Media helpers.
   --------------------------------------------------------------------------- */
.zoomable { overflow: hidden; }
.zoomable img { transition: transform 0.5s var(--ease); }
@media (hover: hover) { .zoomable:hover img { transform: scale(1.06); } }

/* ---------------------------------------------------------------------------
   9. Masthead — top strip, site header, brand, search, theme toggle.
   --------------------------------------------------------------------------- */
.topbar { font-size: 0.8125rem; }
.topbar a { color: rgba(255, 255, 255, 0.82); }
.topbar a:hover { color: #fff; }

.site-header {
  background: var(--bs-body-bg) !important;
  box-shadow: 0 1px 0 var(--bs-border-color), 0 12px 30px -24px rgba(43, 31, 22, 0.5);
}
.site-header .navbar { --bs-navbar-padding-y: 0.55rem; }
.site-header .nav-link.active { color: var(--bs-primary); font-weight: 600; }
[data-theme="dark"] .site-header .nav-link.active { color: var(--bs-primary-text-emphasis); }
.site-header .dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); }

.brand-mark { width: 2.75rem; height: 2.75rem; flex: 0 0 auto; }
.brand-mark svg { width: 1.6rem; height: 1.6rem; }
.brand-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--bs-heading-color);
}
.brand-tagline {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-top: 0.15rem;
}
.navbar-brand:hover .brand-name { color: var(--bs-primary); }

#bubapc-search { background: var(--bs-body-bg); }

.theme-toggle .fa-sun { display: none; }
[data-theme="dark"] .theme-toggle .fa-sun { display: inline-flex; }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

/* ---------------------------------------------------------------------------
   10. Bespoke pieces named by the markup.
   --------------------------------------------------------------------------- */
.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 3px;
  width: 0;
  z-index: 1080;
  background: linear-gradient(90deg, var(--bs-primary), var(--bs-warning));
  transition: width 0.1s linear;
}

.devotional-article { font-size: 1.0625rem; line-height: 1.85; }
.devotional-article h2 { margin-top: 2.5rem; }
.devotional-article p { margin-bottom: 1.25rem; }
.devotional-brand {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-dark);
}

.dropzone {
  position: relative;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-xl);
  background: var(--bs-tertiary-bg);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--snap), background-color var(--snap);
}
.dropzone:hover,
.dropzone.is-dragover { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), 0.06); }
.dropzone-icon { font-size: 2rem; color: var(--bs-primary); margin-bottom: 0.5rem; }
.dropzone-preview img { max-height: 220px; border-radius: var(--bs-border-radius-lg); }
.dropzone.has-file .dropzone-picker { display: none; }

.error-code {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 800;
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--bs-primary);
}

.devotional-message { min-height: 1.25rem; }
.min-width-0 { min-width: 0; }

/* ---------------------------------------------------------------------------
   11. Admin shell — the dark offcanvas sidebar (Bootstrap offcanvas-lg).
   --------------------------------------------------------------------------- */
.admin-shell { min-height: 100vh; align-items: stretch; }
.admin-shell #adminSidebar { --bs-offcanvas-width: 280px; scrollbar-width: none; }
.admin-shell #adminSidebar::-webkit-scrollbar { display: none; }
.admin-shell #adminSidebar .offcanvas-body { scrollbar-width: none; }
.admin-shell #adminSidebar .offcanvas-body::-webkit-scrollbar { display: none; }

/* The menu is dark in both themes, so its brand has to say so: the brand name
   and tagline are normally the heading and secondary colours of the page,
   which are near-black on the light theme and vanish against this background. */
.admin-shell #adminSidebar .brand-name { color: #fff; }
.admin-shell #adminSidebar .brand-tagline { color: rgba(255, 255, 255, 0.55); }

@media (min-width: 992px) {
  .admin-shell #adminSidebar {
    width: 280px;
    flex: 0 0 280px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

/* ---------------------------------------------------------------------------
   12. Accessibility & motion.
   --------------------------------------------------------------------------- */
a:focus-visible,
.category-pill:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  border-radius: var(--bs-border-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
