/*
  CASE & ASE 2026 Spiritual Program – Modern Styles
  --------------------------------------------------
  Features: CSS variables, dark/light themes, glassmorphism,
  fluid typography, smooth animations, mobile-first responsive.
*/

/* === THEME TOKENS === */
:root {
  /* Light theme (default) */
  --bg: #f0f2f7;
  --bg-gradient: linear-gradient(135deg, #e8ecf4 0%, #f0f2f7 50%, #e3e8f3 100%);
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --surface-soft: #f5f7fc;
  --text: #1a1d2e;
  --text-secondary: #5e6478;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef0ff;
  --primary-text: #4338ca;
  --accent: #8b5cf6;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.13);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --blur: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  --surface: #1e293b;
  --surface-glass: rgba(30, 41, 59, 0.78);
  --surface-soft: #273349;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-soft: rgba(99, 102, 241, 0.15);
  --primary-text: #a5b4fc;
  --accent: #a78bfa;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.12);
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  line-height: 1.6;
  min-height: 100dvh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
.container {
  width: min(1140px, 92%);
  margin: 0 auto;
}

/* === LOADING OVERLAY === */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === OFFLINE BANNER === */
.offline-banner {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: var(--surface-glass);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  border: 1.5px solid var(--warning);
  border-radius: var(--radius-full);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(245, 158, 11, 0.15);
  animation: offlineSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  white-space: nowrap;
}

.offline-banner[hidden] {
  display: none !important;
}

.offline-banner svg {
  flex-shrink: 0;
  color: var(--warning);
}

.offline-banner .offline-dot {
  width: 6px;
  height: 6px;
  background: var(--warning);
  border-radius: 50%;
  animation: offlinePulse 2s ease-in-out infinite;
}

@keyframes offlineSlideIn {
  from { transform: translateX(-50%) translateY(-120%); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes offlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === HEADER === */
.site-header {
  background: linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #8b5cf6 100%);
  color: #fff;
  padding: 1.75rem 0 1.5rem;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 0%, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.header-text h1 {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  margin-top: 0.15rem;
  opacity: 0.85;
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* === LANGUAGE SELECTOR === */
.lang-select {
  height: 36px;
  padding: 0 0.5rem;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background var(--transition);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.lang-select option {
  background: var(--surface);
  color: var(--text);
}

.lang-select:hover {
  background: rgba(255,255,255,0.22);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background var(--transition), transform var(--transition);
}

.icon-btn:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.06);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* === SYNC TOAST === */
.sync-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 999;
  padding: 0.65rem 1.25rem;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sync-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === CONTROLS === */
.controls {
  margin-top: 1.25rem;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border var(--transition);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

label svg {
  opacity: 0.65;
}

select,
input[type="search"],
input[type="text"] {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* === TABS === */
.tabs {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.55rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.tab-btn svg {
  flex-shrink: 0;
}

/* === TAB PANELS === */
.tab-panel {
  margin-top: 1rem;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.25s ease;
  transition: background var(--transition), border var(--transition);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.panel-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* === CARD GRID === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-top: 0.9rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--surface-soft);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 4px 0 0 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card:hover::before {
  opacity: 1;
}

.card h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.meta {
  margin: 0.3rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.meta strong {
  color: var(--text);
  font-weight: 600;
}

.service-type {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.verse-text {
  margin-top: 0.6rem;
  padding: 0.65rem 0.8rem;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.empty-state {
  color: var(--text-secondary);
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.92rem;
}

.highlight {
  background: rgba(245, 158, 11, 0.25);
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
}

/* === CALENDAR === */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.calendar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 0;
  transition: background var(--transition), transform var(--transition);
}

.calendar-nav:hover {
  background: var(--primary-soft);
  transform: scale(1.05);
}

.calendar-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
}

.calendar-day-name,
.calendar-cell {
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.calendar-day-name {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.calendar-cell {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  min-height: 48px;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}

.calendar-cell.empty {
  border-color: transparent;
  background: transparent;
  color: transparent;
}

.calendar-cell.service {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
  font-weight: 700;
  cursor: pointer;
  position: relative;
}

.calendar-cell.service:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.calendar-cell.service::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
}

.calendar-cell.selected {
  outline: 2.5px solid var(--primary);
  outline-offset: 1px;
}

.calendar-details {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--surface-soft);
  transition: background var(--transition);
}

/* === BIBLE LOOKUP === */
.bible-lookup {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bible-search-row {
  display: flex;
  gap: 0.5rem;
}

.bible-search-row input {
  flex: 1;
}

.btn-primary {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bible-version-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bible-version-row select {
  min-width: 90px;
}

.bible-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 60px;
}

.bible-result .verse-ref {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.bible-result .verse-body {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
}

/* === BIBLE.COM LINK BUTTON === */
.bible-com-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.bible-com-link:hover {
  background: var(--primary-dark, #4f46e5);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.bible-com-link:active {
  transform: translateY(0);
}

.bible-com-link svg {
  flex-shrink: 0;
}

.bible-daily {
  margin-top: 1.25rem;
}

.bible-daily h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  color: var(--primary-text);
}

.bible-daily-content {
  padding: 1rem;
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* === FOOTER === */
.site-footer {
  margin-top: 2rem;
  padding: 1.25rem 0;
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.footer-meta {
  font-size: 0.78rem;
  opacity: 0.75;
}

#cache-status {
  font-size: 0.7rem;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: row;
    gap: 0.5rem;
  }

  .header-text h1 {
    font-size: 1.3rem;
  }

  .tabs {
    border-radius: var(--radius-md);
  }

  .tab-btn {
    font-size: 0.82rem;
    padding: 0.5rem 0.8rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .bible-search-row {
    flex-direction: column;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .container {
    width: 95%;
  }

  .site-header {
    padding: 1.25rem 0 1rem;
  }

  .tab-panel {
    padding: 0.85rem;
  }

  .calendar-cell {
    min-height: 40px;
    font-size: 0.82rem;
    padding: 0.3rem;
  }

  .calendar-day-name {
    font-size: 0.68rem;
  }

  .calendar-cell.service::after {
    width: 4px;
    height: 4px;
    bottom: 2px;
  }
}

@media (min-width: 1400px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print */
@media print {
  .site-header, .controls, .tabs, .site-footer, .icon-btn, .sync-toast, .offline-banner {
    display: none !important;
  }

  .tab-panel {
    display: block !important;
    background: #fff;
    border: none;
    box-shadow: none;
  }

  .tab-panel[hidden] {
    display: none !important;
  }
}
