/* ==========================================
   CSS Variables (Colors & Design Tokens)
   ========================================== */
:root {
  --bg: #f6f4ef;
  --card: #fff;
  --ink: #1f2937;
  --muted: #6b7280;
  --primary: #1862A8;
  --ring: rgba(24, 98, 168, 0.24);
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.06);
  --radius: 16px;
}

/* Dark mode variables */
.dark-mode {
  --bg: #1a1a1a;
  --card: #2d2d2d;
  --ink: #e5e5e5;
  --muted: #a0a0a0;
  --primary: #4a9ee8;
  --ring: rgba(74, 158, 232, 0.24);
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Reset & Base Styles
   ========================================== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  font-size: 16px;
}

/* Make text and buttons larger on mobile devices */
@media (max-width: 768px) {
  body {
    font-size: 20px;
  }
  
  p {
    font-size: 20px;
    line-height: 1.6;
  }
}

/* ==========================================
   Navigation
   ========================================== */
.nav {
  position: sticky;
  top: 0;
  background: #fbfaf7cc;
  border-bottom: 1px solid #eae7e1;
  backdrop-filter: saturate(140%) blur(8px);
  overflow-x: hidden; /* Prevent horizontal scrolling */
  width: 100%;
}

.dark-mode .nav {
  background: #1a1a1acc;
  border-bottom: 1px solid #404040;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.brand svg {
  width: 28px;
  height: 28px;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

/* Mobile navigation fixes */
@media (max-width: 768px) {
  .nav-inner {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .brand {
    font-size: 16px;
    gap: 6px;
    flex-shrink: 0;
  }
  
  .brand img {
    width: 40px !important;
    height: 40px !important;
  }
  
  .brand span {
    display: none; /* Hide "Digital Rosary" text on very small screens */
  }
  
  .nav-links {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1;
    min-width: 0; /* Allow flex items to shrink */
  }
  
  .nav-links a {
    font-size: 14px;
    padding: 6px 8px;
    white-space: nowrap;
  }
  
  .nav-links .button {
    padding: 8px 12px;
    font-size: 14px;
    min-height: 36px;
  }
  
  .dark-mode-toggle {
    font-size: 18px;
    padding: 6px 10px;
    min-width: 36px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .nav-inner {
    padding: 8px 10px;
  }
  
  .brand span {
    display: none; /* Always hide text on very small screens */
  }
  
  .nav-links {
    gap: 6px;
  }
  
  .nav-links a {
    font-size: 13px;
    padding: 5px 6px;
  }
  
  .nav-links .button {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 32px;
  }
  
  /* Hide "Log In" button on very small screens to save space */
  .nav-links .button:last-child {
    display: none;
  }
}

a {
  color: #374151;
  text-decoration: none;
  font-weight: 600;
}

.dark-mode a {
  color: #d4d4d4;
}

/* ==========================================
   Buttons
   ========================================== */
.button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #d9d6cf;
  background: #fff;
  font-weight: 600;
  font-size: 16px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  cursor: pointer;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.dark-mode .button {
  background: #2d2d2d;
  border-color: #404040;
  color: #e5e5e5;
}

.dark-mode-toggle {
  font-size: 20px;
  padding: 8px 12px;
  min-width: 44px;
}

.button:active {
  transform: scale(0.95);
}

/* Larger buttons on mobile for easier tapping */
@media (max-width: 768px) {
  .button {
    padding: 14px 24px;
    font-size: 20px;
    min-height: 56px; /* Minimum touch target size */
  }
}

.button.primary {
  background: var(--primary);
  color: #FDDB6F;
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(24, 98, 168, 0.18);
}

.button-secondary {
  background: #f9fafb;
  border-color: #d1d5db;
  color: var(--ink);
}

.dark-mode .button-secondary {
  background: #374151;
  border-color: #4b5563;
  color: var(--ink);
}

.button.clicked {
  animation: buttonClick 0.3s ease;
}

@keyframes buttonClick {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.93);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==========================================
   Layout (Container & Grid)
   ========================================== */
.wrap {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 20px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .wrap {
    padding: 0 16px;
    margin: 16px auto;
  }
}

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

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Right sidebar spacing - ensure cards have consistent vertical spacing */
.aside {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.aside > .card {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
}

/* Ensure first card in aside doesn't have extra margin */
.aside > .card:first-child {
  margin-top: 0;
}

/* Left section spacing - ensure consistent spacing */
section > .card {
  margin-left: 0;
  margin-right: 0;
}

/* Ensure consistent horizontal alignment for both sections */
.grid > section,
.grid > .aside {
  margin: 0;
  padding: 0;
}

/* ==========================================
   Cards
   ========================================== */
.card {
  background: var(--card);
  border: 1px solid #ece8e0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dark-mode .card {
  border-color: #404040;
}

.card.pad {
  padding: 22px;
}

/* Rosary info links section */
.rosary-info-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.rosary-info-links .button {
  flex: 1;
  min-width: 150px;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .rosary-info-links {
    flex-direction: column;
  }
  
  .rosary-info-links .button {
    width: 100%;
    min-width: auto;
  }
}

/* Larger padding on mobile for better touch targets */
@media (max-width: 768px) {
  .card.pad {
    padding: 20px 16px;
  }
  
  /* Make welcome card more prominent */
  .hero {
    padding: 0;
  }
  
  .prayer-panel {
    padding: 16px;
  }
}

/* ==========================================
   Typography
   ========================================== */
h1,
h2,
h3 {
  font-family: Merriweather, Georgia, "Times New Roman", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", serif;
  line-height: 1.2;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(28px, 2.6vw, 40px);
}

/* Larger h1 on mobile for hero section */
@media (max-width: 768px) {
  h1 {
    font-size: 36px;
    line-height: 1.3;
    margin-bottom: 16px;
  }
}

h2 {
  font-size: clamp(22px, 2vw, 28px);
  margin: 0;
}

/* IRG header: h2 with mystery pill and restart button */
.irg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.irg-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section header with dismiss button */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  flex: 1;
  margin-bottom: 0;
}

.button-icon {
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
  min-width: auto;
  min-height: auto;
  font-weight: 300;
}

.button-icon:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
}

.dark-mode .button-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.button-icon:active {
  transform: scale(0.9);
}

h3 {
  font-size: clamp(18px, 1.5vw, 24px);
}

/* Larger headings on mobile */
@media (max-width: 768px) {
  h2 {
    font-size: 26px;
  }
  
  .irg-header {
    margin-bottom: 16px;
  }
  
  .irg-header-actions {
    gap: 6px;
  }
  
  .irg-header-actions .button {
    padding: 6px 10px;
    min-width: auto;
  }
  
  h3 {
    font-size: 22px;
    margin-bottom: 14px;
  }
}

.muted {
  color: var(--muted);
}

/* ==========================================
   Hero Section
   ========================================== */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: center;
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  /* Make hero section more prominent on mobile */
  .hero > div:first-child {
    padding: 8px 0;
  }
  
  .hero p {
    font-size: 22px;
    line-height: 1.7;
    margin: 16px 0 24px;
  }
  
  .hero .button.primary {
    padding: 20px 28px;
    font-size: 22px;
    min-height: 64px;
    width: 100%;
    max-width: 100%;
  }
}

.mary_points_us {
  aspect-ratio: 16 / 10;
  border-radius: 12px;
}

.pill {
  background: #eef3fb;
  color: #1862A8;
  font-weight: 700;
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
}

.dark-mode .pill {
  background: #1e3a5f;
  color: #4a9ee8;
}

/* Larger pills on mobile */
@media (max-width: 768px) {
  .pill {
    padding: 8px 14px;
    font-size: 18px;
  }
}

/* Mystery name in welcome section - colored text */
.mystery-name {
  color: var(--primary);
  font-weight: 700;
  font-style: italic;
}

.dark-mode .mystery-name {
  color: #4a9ee8;
}

.today {
  color: #b91c1c;
  font-weight: 800;
}

/* ==========================================
   Guide & Prayer Section
   ========================================== */
.guide {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start; /* Align items to top */
}

@media (max-width: 1000px) {
  .guide {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

.image-frame {
  background: #fcfbf8;
  border: 1px solid #ebe5d8;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

.dark-mode .image-frame {
  background: #252525;
  border-color: #404040;
}

.step-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e9e4da;
  background: #fff;
  object-fit: cover;
  aspect-ratio: 4 / 3;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.step-img:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.step-img:active {
  opacity: 0.7;
  transform: scale(0.98);
  max-width: 100%; /* Prevent overflow */
}

/* Loading state for images */
.step-img.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.dark-mode .step-img.loading {
  background: linear-gradient(90deg, #2a2a2a 25%, #1a1a1a 50%, #2a2a2a 75%);
  background-size: 200% 100%;
}

.prayer-panel {
  background: #fcfbf8;
  border: 1px dashed #e8e2d6;
  border-radius: 12px;
  padding: 18px;
}

.dark-mode .prayer-panel {
  background: #252525;
  border-color: #404040;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.step {
  font-weight: 700;
}

/* Beads visualization for Hail Mary steps */
.beads-container {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: 8px;
  vertical-align: middle;
}

.bead {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: transparent;
  display: inline-block;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.bead-filled {
  background: var(--primary);
  transform: scale(1.1);
}

.bead-current {
  background: #dc2626;
  border-color: #dc2626;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

/* Larger beads on mobile for better visibility */
@media (max-width: 768px) {
  .beads-container {
    gap: 8px;
    margin-left: 10px;
  }
  
  .bead {
    width: 10px;
    height: 10px;
    border-width: 2px;
  }
}

/* Three-bead container styling (Faith, Hope, Charity) */
.three-beads-container {
  margin-top: 4px;
  margin-bottom: 4px;
}

/* Virtue styling for Faith, Hope, Charity */
.virtue-current {
  color: #dc2626;
  font-weight: 700;
}

.virtue-completed {
  font-weight: 700;
  color: inherit;
}

.virtue-future {
  font-weight: normal;
  color: inherit;
}

.prayer-text {
  margin-top: 8px;
  white-space: pre-wrap;
  font-size: inherit;
}

/* Scrollable prayer text for longer prayers */
.prayer-text.scrollable {
  overflow-y: auto;
  padding-right: 8px;
  /* Smooth scrolling */
  scroll-behavior: smooth;
  /* max-height will be set inline by JavaScript based on actual line-height */
}

/* Custom scrollbar styling for prayer text */
.prayer-text.scrollable::-webkit-scrollbar {
  width: 8px;
}

.prayer-text.scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.prayer-text.scrollable::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

.prayer-text.scrollable::-webkit-scrollbar-thumb:hover {
  background: var(--ink);
}

/* Meditation text displayed above Hail Mary prayers */
.meditation {
  font-style: italic;
  font-size: 0.9em;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
  display: block;
}

/* Larger prayer text on mobile for better readability */
@media (max-width: 768px) {
  .prayer-text {
    font-size: 20px;
    line-height: 1.7;
    margin-top: 16px;
  }
  
  .step {
    font-size: 22px;
    margin-top: 8px;
  }
  
  .panel-head {
    font-size: 20px;
  }
  
  .panel-head .muted {
    font-size: 18px;
  }
  
  .meditation {
    font-size: 18px;
    margin-bottom: 16px;
    line-height: 1.6;
  }
}

/* ==========================================
   Toolbar & Controls
   ========================================== */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

/* Larger toolbar buttons on mobile */
@media (max-width: 768px) {
  .toolbar {
    gap: 12px;
    margin-bottom: 20px;
  }
  
  .toolbar .button {
    flex: 1 1 auto;
    min-width: 120px;
  }
  
  .toolbar #jumpBtn {
    width: 100%;
    margin-top: 8px;
  }
}

.toolbar #restartBtn {
  flex: 0 0 auto;
}

.toolbar .button:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

/* ==========================================
   Stats & Progress
   ========================================== */
.kpi {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Larger KPI stats on mobile */
@media (max-width: 768px) {
  .kpi {
    font-size: 20px;
    gap: 10px;
    margin: 12px 0;
  }
  
  .kpi strong {
    font-size: 28px;
  }
  
  .kpi .muted {
    font-size: 18px;
  }
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #ece8e0;
  overflow: hidden;
}

.dark-mode .progress {
  background: #404040;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4a9ee8);
}

/* ==========================================
   Lists
   ========================================== */
.list {
  margin: 0;
  padding: 0 0 0 18px;
}

.list li {
  margin: 6px 0;
}

/* Larger list items on mobile */
@media (max-width: 768px) {
  .list {
    font-size: 20px;
    padding-left: 24px;
  }
  
  .list li {
    margin: 10px 0;
    line-height: 1.6;
  }
  
  .list a {
    font-size: 20px;
  }
}

/* ==========================================
   Footer
   ========================================== */
footer {
  color: #7b7f86;
  text-align: center;
  padding: 40px 0 60px;
}

.dark-mode footer {
  color: #a0a0a0;
}

/* ==========================================
   Accordion (Prayer Log)
   ========================================== */
.accordion details {
  border: 1px solid #eee7d9;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffcf6;
}

.dark-mode .accordion details {
  border-color: #404040;
  background: #252525;
}

.accordion details + details {
  margin-top: 10px;
}

.accordion summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #1f2937;
}

.dark-mode .accordion summary {
  color: #e5e5e5;
}

/* Larger accordion on mobile */
@media (max-width: 768px) {
  .accordion details {
    padding: 14px 16px;
    margin-top: 12px;
  }
  
  .accordion summary {
    font-size: 20px;
    padding: 8px 0;
  }
  
  .accordion ul {
    font-size: 18px;
    margin-top: 12px;
    padding-left: 24px;
  }
  
  .accordion li {
    margin: 10px 0;
    line-height: 1.6;
  }
}

/* Common Prayers section details on mobile */
@media (max-width: 768px) {
  details {
    padding: 14px 16px;
    margin-top: 12px;
    font-size: 18px;
  }
  
  details summary.step {
    font-size: 20px;
    padding: 8px 0;
    cursor: pointer;
    min-height: 44px; /* Touch target */
    display: flex;
    align-items: center;
  }
  
  details p.muted {
    font-size: 18px;
    line-height: 1.7;
    margin-top: 12px;
  }
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion .chev {
  transition: transform 0.2s ease;
  margin-left: 12px;
}

.accordion details[open] .chev {
  transform: rotate(90deg);
}

.accordion .today-tag {
  color: #b91c1c;
  font-weight: 800;
}

.dark-mode .accordion .today-tag {
  color: #f87171;
}

.accordion ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

/* ==========================================
   1-Click Hail Marys Toggle
   ========================================== */
.one-click-hail-marys-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--ink);
}

.toggle-label input[type="checkbox"] {
  appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #d9d6cf;
  border: 1px solid #c4c0b8;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.dark-mode .toggle-label input[type="checkbox"] {
  background: #404040;
  border-color: #505050;
}

.toggle-label input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-label input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-label input[type="checkbox"]:checked::before {
  transform: translateX(16px);
}

.toggle-label input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.toggle-text {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

.dark-mode .toggle-text {
  color: var(--muted);
}

/* Larger toggle on mobile for better touch targets */
@media (max-width: 768px) {
  .one-click-hail-marys-toggle {
    margin-top: 12px;
  }
  
  .toggle-label {
    gap: 12px;
  }
  
  .toggle-text {
    font-size: 13px; /* Keep same size as Tip on mobile too */
  }
  
  .toggle-label input[type="checkbox"] {
    width: 40px;
    height: 22px;
  }
  
  .toggle-label input[type="checkbox"]::before {
    width: 16px;
    height: 16px;
    top: 2px;
    left: 2px;
  }
  
  .toggle-label input[type="checkbox"]:checked::before {
    transform: translateX(18px);
  }
}

/* Complete Decade button styling */
#completeDecadeBtn {
  background: #f9fafb;
  border-color: #d1d5db;
  color: var(--ink);
}

.dark-mode #completeDecadeBtn {
  background: #374151;
  border-color: #4b5563;
  color: var(--ink);
}

#completeDecadeBtn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.dark-mode #completeDecadeBtn:hover {
  background: #4b5563;
  border-color: #6b7280;
}

/* Ensure Complete Decade button is hidden when it has the hidden attribute */
#completeDecadeBtn[hidden] {
  display: none !important;
}
ul li::marker {
  content: "✓ ";
  color: var(--primary);
}
