/* ============================================
   Sabah ve Akşam Zikirleri — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Scheherazade+New:wght@400;500;600;700&family=Amiri:wght@400;700&display=swap');

/* ---- Theme variables ---- */
:root {
  /* Light mode (default) */
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-soft: #F2EDE4;
  --text-primary: #1B2A4E;
  --text-secondary: #5A6783;
  --text-muted: #8B95AD;
  --accent: #B8924C;
  --accent-soft: #E8DCC0;
  --arabic-color: #0F1729;
  --border: #E8E2D7;
  --border-soft: #F0EBE2;
  --shadow: 0 1px 3px rgba(27, 42, 78, 0.04), 0 4px 16px rgba(27, 42, 78, 0.06);
  --shadow-hover: 0 2px 8px rgba(27, 42, 78, 0.08), 0 12px 32px rgba(27, 42, 78, 0.10);

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Fraunces', Georgia, serif;
  --font-arabic: 'Scheherazade New', 'Amiri', serif;

  /* Sizing */
  --max-width: 720px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Arabic size (adjustable) */
  --arabic-size: 1.75rem;
  --arabic-line: 2.4;
}

[data-theme="dark"] {
  --bg: #0F1729;
  --surface: #1A2438;
  --surface-soft: #243049;
  --text-primary: #F0EDE5;
  --text-secondary: #B5BDD0;
  --text-muted: #8B9AB5;
  --accent: #D4B574;
  --accent-soft: #3D3322;
  --arabic-color: #F5F1E8;
  --border: #2A3550;
  --border-soft: #1F2A42;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* Arabic font choice */
[data-arabic-font="amiri"] {
  --font-arabic: 'Amiri', 'Scheherazade New', serif;
}

/* Arabic size variants */
[data-arabic-size="small"] { --arabic-size: 1.5rem; --arabic-line: 2.2; }
[data-arabic-size="medium"] { --arabic-size: 1.75rem; --arabic-line: 2.4; }
[data-arabic-size="large"] { --arabic-size: 2.1rem; --arabic-line: 2.6; }

/* ---- Reset & base ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Layout ---- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 242, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

[data-theme="dark"] .topbar {
  background: rgba(15, 23, 41, 0.85);
}

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

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar-back:hover {
  background: var(--surface-soft);
  color: var(--text-primary);
  text-decoration: none;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

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

.icon-btn svg { width: 20px; height: 20px; stroke-width: 1.6; }

/* ---- Home page ---- */
.home {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 1.25rem 4rem;
}

.home-hero {
  text-align: center;
  margin-bottom: 3rem;
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
  opacity: 0.9;
}

.ornament-line {
  display: block;
  width: 50px;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
}

.ornament-diamond {
  width: 6px;
  height: 6px;
  transform: rotate(45deg);
  background: currentColor;
}

.home-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.home-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-style: italic;
  font-weight: 400;
}

.home-cards {
  display: grid;
  gap: 1rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.home-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-soft);
  text-decoration: none;
}

.home-card-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--surface-soft);
}

.home-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.home-card:hover .home-card-image img {
  transform: scale(1.03);
}

.home-footer {
  text-align: center;
  margin-top: 4rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.home-footer a { color: var(--text-secondary); }

/* ---- List page ---- */
.list-header {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
}

.list-header h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.list-header-meta {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.progress-text {
  color: var(--accent);
  font-weight: 500;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 4rem;
}

/* ---- Intro card (Sabah/Aksam introduction text) ---- */
.intro-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem 0.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.intro-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.intro-quote {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  color: var(--accent);
  opacity: 0.25;
}

/* Collapsible container with fade-out gradient */
.intro-collapsible {
  position: relative;
  max-height: 4.6em; /* ~2.5 lines visible */
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.intro-card[data-expanded="true"] .intro-collapsible {
  max-height: 1000px; /* large enough for full content */
}

.intro-collapsible::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3em;
  background: linear-gradient(to bottom, transparent, var(--surface) 90%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.intro-card[data-expanded="true"] .intro-collapsible::after {
  opacity: 0;
}

.intro-text {
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.intro-text p {
  margin: 0;
}

.intro-text p + p {
  margin-top: 0.85rem;
}

.intro-text p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 500;
  color: var(--accent);
  float: left;
  line-height: 1;
  margin: 0.2rem 0.5rem 0 0;
  padding: 0.1rem 0;
}

.intro-source {
  margin-top: 1.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
  font-style: normal;
  letter-spacing: 0.01em;
}

.intro-source em {
  font-style: italic;
  color: var(--text-secondary);
}

/* Toggle button */
.intro-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.85rem 1rem;
  margin-top: 0.25rem;
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.intro-toggle:hover {
  background: var(--surface-soft);
}

.intro-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.intro-card[data-expanded="true"] .intro-toggle svg {
  transform: rotate(180deg);
}

/* ---- Dua card ---- */
.dua {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, opacity 0.2s ease;
  scroll-margin-top: 80px;
}

.dua.is-done {
  opacity: 0.65;
  border-color: var(--accent-soft);
}

.dua-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.dua-num {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-muted);
  min-width: 1.5rem;
  font-feature-settings: "tnum";
}

.dua-title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.08rem;
  line-height: 1.4;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}

.dua-badge {
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: 100px;
  letter-spacing: 0.02em;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

[data-theme="dark"] .dua-badge {
  color: var(--accent);
}

.dua-arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  line-height: var(--arabic-line);
  color: var(--arabic-color);
  direction: rtl;
  text-align: right;
  padding: 0.5rem 0 1rem;
  font-weight: 500;
  white-space: pre-line;
}

.dua-turkish {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  padding-bottom: 1rem;
}

/* Fazilet expandable */
.dua-fazilet {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.dua-fazilet-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  transition: color 0.15s ease;
}

.dua-fazilet-toggle:hover { color: var(--text-primary); }

.dua-fazilet-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.dua-fazilet[data-open="true"] .dua-fazilet-toggle svg { transform: rotate(180deg); }

.dua-fazilet-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.dua-fazilet[data-open="true"] .dua-fazilet-body { grid-template-rows: 1fr; }

.dua-fazilet-body > div {
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.dua-fazilet[data-open="true"] .dua-fazilet-body > div {
  padding: 0.5rem 0 1rem;
}

/* Action buttons */
.dua-actions {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.dua-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  min-width: 0;
}

.dua-action:hover {
  background: var(--surface-soft);
  color: var(--text-primary);
}

.dua-action svg { width: 17px; height: 17px; stroke-width: 1.7; flex-shrink: 0; }

.dua-action.is-playing { color: var(--accent); background: var(--accent-soft); }
.dua-action.is-done { color: var(--accent); }

/* ---- Settings panel ---- */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 41, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.settings-overlay.is-open { opacity: 1; pointer-events: auto; }

.settings-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .settings-panel {
    left: 50%;
    right: auto;
    bottom: 50%;
    transform: translate(-50%, calc(50% + 30px));
    width: 420px;
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--shadow-hover);
  }
  .settings-panel.is-open {
    transform: translate(-50%, 50%);
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 599px) {
  .settings-panel.is-open { transform: translateY(0); }
}

.settings-panel::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

@media (min-width: 600px) {
  .settings-panel::before { display: none; }
}

.settings-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.settings-group { margin-bottom: 1.25rem; }
.settings-group:last-child { margin-bottom: 0; }

.settings-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}

.settings-options {
  display: flex;
  gap: 0.4rem;
  background: var(--surface-soft);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.settings-option {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  text-align: center;
  min-width: 0;
}

.settings-option.is-active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

[data-theme="dark"] .settings-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Install app button */
.install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.install-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.install-btn:active {
  transform: translateY(0);
}

[data-theme="dark"] .install-btn {
  color: #0F1729;
}

.install-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.install-hint {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  margin: 0;
}

.install-hint strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 100px;
  font-size: 0.92rem;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow-hover);
}

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

/* ---- Reveal animation ---- */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(8px);
    animation: reveal 0.5s ease forwards;
  }
  @keyframes reveal {
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ---- Accessibility ---- */
.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;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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