/* =========================================
   theme.css — shared styles (cleaned)
   ========================================= */

/* ---------- CSS variables ---------- */
:root {
  --background: #ffffff;
  --text: #2d3748;
  --text-secondary: #718096;
  --box: #edf2f7;

  --primary: #3182ce;
  --primary-dark: #2b6cb0;

  /* Header (navbar) */
  --header-bg: var(--primary);
  --header-fg: #ffffff;
  --header-fg-subtle: rgba(255, 255, 255, 0.9);
  --header-hover-bg: rgba(255, 255, 255, 0.12);
  --header-active-bg: rgba(255, 255, 255, 0.2);
  --header-border: rgba(255, 255, 255, 0.12);

  /* Effects */
  --card-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  --radius: 12px;

  /* Sheet (preview) tokens */
  --sheet-g1: #f8fafc;
  --sheet-g2: #eef2f7;
  --sheet-rule: #e6edf6;
  --sheet-chip: #dfe9f7;
  --sheet-chip-alt: #cfe5fb;
  --sheet-stroke: #d4d9e0;
}

/* Dark theme overrides (body.dark toggled by JS) */
.dark {
  --background: #0b1220;
  --text: #e5e7eb;
  --text-secondary: #a0aec0;
  --box: #111827;

  --primary: #90cdf4;
  --primary-dark: #63b3ed;

  --header-bg: #0b3b5a;
  --header-fg: #e6f2ff;
  --header-fg-subtle: #d9e8ff;
  --header-hover-bg: rgba(230, 242, 255, 0.1);
  --header-active-bg: rgba(230, 242, 255, 0.18);
  --header-border: rgba(230, 242, 255, 0.14);

  /* Sheet (preview) tokens */
  --sheet-g1: #0b2035;
  --sheet-g2: #13273f;
  --sheet-rule: #203046;
  --sheet-chip: #183045;
  --sheet-chip-alt: #0b3b5a;
  --sheet-stroke: #334155;
}

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

/* ---------- Sheet / hero preview ---------- */
.sheet-bg {
  fill: transparent;
  stroke: var(--sheet-stroke);
  stroke-dasharray: 4 4;
}
.g1 {
  stop-color: var(--sheet-g1);
}
.g2 {
  stop-color: var(--sheet-g2);
}
.rule {
  fill: var(--sheet-rule);
}
.chip {
  fill: var(--sheet-chip);
}
.chip-alt {
  fill: var(--sheet-chip-alt);
}
.sheet {
  width: 100%;
  height: auto;
  max-width: 360px;
}

/* Support `.fs-sheet` wrapper as an alias */
.fs-sheet .sheet-bg {
  fill: transparent;
  stroke: var(--sheet-stroke);
  stroke-dasharray: 4 4;
}
.fs-sheet .g1 {
  stop-color: var(--sheet-g1);
}
.fs-sheet .g2 {
  stop-color: var(--sheet-g2);
}
.fs-sheet .rule {
  fill: var(--sheet-rule);
}
.fs-sheet .chip {
  fill: var(--sheet-chip);
}
.fs-sheet .chip-alt {
  fill: var(--sheet-chip-alt);
}
.fs-sheet svg {
  width: 100%;
  height: auto;
  max-width: 360px;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI,
    Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--background);
  color: var(--text);
  margin: 0;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.page-title {
  font-size: clamp(1.4rem, 2.2vw + 1rem, 2rem);
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0.2rem 0 0.6rem;
}

.muted {
  color: var(--text-secondary);
}
.small {
  font-size: 0.9em;
}
.micro {
  font-size: 0.75rem;
  opacity: 0.7;
}

.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;
}

/* Responsive type tweak */
@media (max-width: 480px) {
  h1 {
    font-size: 1.75rem;
  }
}

/* ---------- Home hero layout ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 1rem 1.5rem;
  align-items: start;
  margin-top: 0.25rem;
}
.hero-text {
  min-width: 0;
}
.hero-art img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-art {
    margin-top: 0.75rem;
  }
}

/* ---------- Links (content) ---------- */
a.nav-link,
.nav-right a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
a.nav-link:hover,
.nav-right a:hover {
  color: var(--primary);
}

/* ---------- Buttons ---------- */
.button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}
.button:hover {
  background: var(--primary-dark);
}
.button.primary {
  background: var(--primary);
}
.button.primary:hover {
  background: var(--primary-dark);
}
.button.ghost {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: inherit;
  border-radius: var(--radius);
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  top: 12px;
  right: 12px;
  display: grid;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--card-shadow);
  animation: fadeOut 4s forwards;
}
.toast-success {
  background: #38a169;
}
.toast-warning {
  background: #dd6b20;
}
.toast-error {
  background: #e53e3e;
}
@keyframes fadeOut {
  0%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    display: none;
  }
}

/* ---------- Forms & Inputs ---------- */
label,
input[type="checkbox"] + label,
.checkbox-label {
  color: var(--text);
}
.dark label,
.dark .checkbox-label,
.dark input[type="checkbox"] + label {
  color: #f7fafc;
}
.wide-input {
  width: 100%;
  padding: 10px;
}
.block {
  margin-bottom: 1.2rem;
}

/* ---------- Navbar ---------- */
.main-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 10px 16px;
  border-bottom: 1px solid var(--header-border);
  transition: box-shadow 0.18s ease;
}
.main-header.is-stuck {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.logo-nav {
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 14px;
}
.logo img {
  display: block;
  height: 40px;
  width: auto;
}

.nav-links {
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
}
.nav-links a {
  --pad-x: 10px;
  --pad-y: 6px;
  color: var(--header-fg);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: var(--pad-y) var(--pad-x);
  border-radius: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  outline: none;
}
.nav-links a:hover {
  background: var(--header-hover-bg);
}
.nav-links a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 10px;
}
.nav-links a[aria-current="page"],
.nav-links a.active {
  background: var(--header-active-bg);
}

.usage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--header-fg);
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
}

.auth-theme {
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 10px;
}
.user-name {
  color: var(--header-fg-subtle);
  font-weight: 800;
}
.auth-link {
  color: var(--header-fg);
  text-decoration: none;
  font-weight: 800;
}
.auth-link.logout {
  color: #ffe1e1;
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--header-border);
  background: transparent;
  color: var(--header-fg);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.theme-toggle:hover {
  background: var(--header-hover-bg);
}

/* Mobile menu */
.menu-toggle {
  display: none;
  appearance: none;
  border: 1px solid var(--header-border);
  color: var(--header-fg);
  background: transparent;
  border-radius: 10px;
  padding: 6px 10px;
  line-height: 1;
  cursor: pointer;
}
.menu-toggle:hover {
  background: var(--header-hover-bg);
}
.menu-toggle .bar {
  display: inline-block;
  width: 18px;
  height: 2px;
  background: currentColor;
  margin: 3px 0;
  border-radius: 2px;
}

/* Admin dropdown */
.admin-summary {
  color: var(--header-fg);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  text-decoration: none;
  display: inline-block;
  padding: 0 2px;
}
.admin-drop {
  position: relative;
  display: inline-block;
}
.admin-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--box);
  color: var(--text);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  min-width: 180px;
  z-index: 20;
}
.admin-drop[open] .admin-panel {
  display: block;
}
.admin-panel .nav-sublink {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.admin-panel .nav-sublink:hover {
  background: rgba(0, 0, 0, 0.04);
}
.admin-panel .nav-sublink[aria-current="page"] {
  text-decoration: underline;
}

/* Mobile nav layout */
@media (max-width: 880px) {
  .logo img {
    height: 34px;
  }
  .menu-toggle {
    display: inline-block;
  }
  .logo-nav {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
  }

  .nav-links {
    grid-auto-flow: row;
    gap: 4px;
    width: 100%;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.2s ease, opacity 0.15s ease;
    border-top: 1px dashed var(--header-border);
    margin-top: 8px;
    padding-top: 8px;
  }
  body.nav-open .nav-links {
    max-height: 420px;
    opacity: 1;
  }

  .nav-links a {
    padding: 10px 12px;
    border-radius: var(--radius);
  }

  .auth-theme {
    grid-auto-flow: row;
    justify-items: start;
    gap: 8px;
    border-top: 1px dashed var(--header-border);
    padding-top: 8px;
    margin-top: 8px;
  }
  .auth-theme .user-name {
    display: none;
  }

  /* Admin panel flows inline on mobile */
  .admin-drop {
    position: static;
  }
  .admin-panel {
    position: static;
    box-shadow: none;
    border: 1px dashed #e5e7eb;
  }
}

/* ---------- Banners ---------- */
.site-banner {
  margin: 8px auto 8px;
  max-width: 980px;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.25;
  box-shadow: var(--card-shadow);
}
.site-banner.strong {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #7a4a00;
}
.site-banner.subtle {
  background: var(--box);
  border: 1px solid #e5e7eb;
  color: var(--text);
}

/* ---------- Chips ---------- */
.chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85em;
  cursor: pointer;
}
.chip:hover {
  background: #eef2ff;
}

/* ---------- Pills / Badges ---------- */
.pill {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #111827;
  border: 1px solid #fde68a;
}
.pill.alt {
  background: #e0e7ff;
  border-color: #c7d2fe;
  margin-right: 6px;
}

/* Cursive badge */
.cursive-badge {
  background: #f6ad55;
  color: #fff;
  font-size: 0.75em;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.dark .cursive-badge {
  background: #dd6b20;
}

/* ---------- Lists / Cards (History, etc.) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0 1rem;
}
.toolbar-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

#searchInput,
#versionFilter {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  min-width: 190px;
  background: var(--box);
}

/* large grids render faster */
.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
  content-visibility: auto;
  contain-intrinsic-size: 1px 240px;
}

.card {
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: var(--box);
  padding: 12px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}
.card .actions {
  display: inline-flex;
  gap: 6px;
}

.row-top {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 0.75rem;
  align-items: center;
}
.row-check-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-block;
}
.row-check-wrap input {
  opacity: 0;
  position: absolute;
  inset: 0;
  cursor: pointer;
}
.custom-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid #94a3b8;
  display: inline-block;
  background: transparent;
}
.row-check-wrap input:checked + .custom-checkbox {
  background: #93c5fd;
  border-color: #3b82f6;
}

.title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.25;
  word-break: break-word;
  margin-bottom: 4px;
}
.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  text-decoration: none;
  font-size: 1.05rem;
}
.icon:hover {
  background: #cbd5e1;
}
.icon.danger {
  background: #fecaca;
}
.icon.danger:hover {
  background: #fca5a5;
}

.content .thumb {
  width: 100%;
  max-width: 160px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
  background: #f1f5f9;
}

.empty {
  text-align: center;
  padding: 24px;
  border: 1px dashed #e5e7eb;
  border-radius: 14px;
}
.empty-emoji {
  font-size: 2.25rem;
  margin-bottom: 0.25rem;
}

/* History legacy helpers */
.history-entry {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.history-entry input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 4px;
}
.history-entry .actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  .row-top {
    grid-template-columns: 30px 1fr;
  }
  .card .actions {
    grid-column: 2 / -1;
    margin-top: 0.35rem;
    flex-direction: row !important;
  }
  .icon {
    width: 34px;
    height: 34px;
  }
}
@media (max-width: 420px) {
  .icon {
    width: 30px;
    height: 30px;
  }
}

/* ---------- Generic action rows ---------- */
.actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .actions {
    flex-direction: column;
  }
}

/* ---------- Help / alerts ---------- */
.help {
  font-size: 0.9em;
  color: var(--text-secondary);
  margin-top: 6px;
}
.warn {
  margin-top: 0.5rem;
  border: 1px solid #7a1a1a;
  background: #5a0b0b22;
  color: #f8dada;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
}

/* ---------- Snackbar (inline toast) ---------- */
.snackbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  color: #e5e7eb;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.snackbar.show {
  opacity: 1;
}

/* ---------- Details content ---------- */
details > div {
  background: var(--box);
  color: var(--text);
  padding: 12px;
  border-radius: 6px;
  margin-top: 8px;
}

/* ---------- Dark-mode niceties ---------- */
body.dark,
.dark body {
  color: #e5e7eb;
  background: #0b1220;
}
.dark .page-title {
  color: #f8fafc;
}
.dark .muted {
  color: #cbd5e1;
}
.dark a {
  color: #93c5fd;
}
.dark .card,
.dark .box {
  background: #111827;
  border-color: #1f2937;
}
.dark .pill {
  background: #334155;
  border-color: #475569;
  color: #e5e7eb;
}
.dark .pill.alt {
  background: #065f46;
  border-color: #047857;
}
.dark .button {
  border-color: #475569;
}
.dark .button.ghost {
  color: #e5e7eb;
  border-color: #475569;
}
.dark .button.primary {
  background: #22c55e;
  color: #062a12;
  border-color: #16a34a;
}

/* ---------- Mobile global tweaks ---------- */
@media (max-width: 600px) {
  .button {
    width: 100%;
    text-align: center;
  }
  .container {
    padding: 1.2rem;
  }
}

/* ================================
   Generate — Quick Picks polish
   ================================ */
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}
.quick-picks-label {
  margin-right: 2px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
}
.quick-picks .chip {
  --qp-bg: #f8fafc;
  --qp-bd: #cbd5e1;
  --qp-fg: #0f172a;
  --qp-bg-hover: #eef2ff;
  --qp-bd-hover: #c7d2fe;
  background: var(--qp-bg);
  border-color: var(--qp-bd);
  color: var(--qp-fg);
  padding: 5px 10px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.03s;
}
.quick-picks .chip:hover {
  background: var(--qp-bg-hover);
  border-color: var(--qp-bd-hover);
}
.quick-picks .chip:active {
  transform: translateY(1px);
}
.quick-picks .chip:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* optional soft categories */
.quick-picks .chip.nt {
  --qp-bg: #eef2ff;
  --qp-bd: #c7d2fe;
} /* New Testament */
.quick-picks .chip.psalm {
  --qp-bg: #ecfeff;
  --qp-bd: #a5f3fc;
} /* Psalms */
.quick-picks .chip.gospel {
  --qp-bg: #f0fdf4;
  --qp-bd: #bbf7d0;
} /* Gospels */
.dark .quick-picks .chip {
  --qp-bg: #0f172a;
  --qp-bd: #334155;
  --qp-fg: #e5e7eb;
  --qp-bg-hover: #111827;
  --qp-bd-hover: #475569;
}
.dark .quick-picks .chip.nt {
  --qp-bg: #11183a;
  --qp-bd: #39458f;
}
.dark .quick-picks .chip.psalm {
  --qp-bg: #0e1d22;
  --qp-bd: #1e3a3f;
}
.dark .quick-picks .chip.gospel {
  --qp-bg: #0f1f15;
  --qp-bd: #1f3a27;
}

/* Prevent layout shift while images decode (thumbs) */
.thumb-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #0b1220;
}

/* ---------- Plus hero ---------- */
.plus-hero {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 360px);
  gap: 1rem 1.25rem;
  align-items: start;
  margin-bottom: 1rem;
}
.plus-preview img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
@media (max-width: 900px) {
  .plus-hero {
    grid-template-columns: 1fr;
  }
  .plus-preview {
    justify-self: start;
  }
}
