@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cinzel:wght@400;500;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --gold: #c9a14a;
  --gold-dark: #8a6d2a;
  --border-gold: #d4af6a;
  --matin-bg-1: #f4e4c1;
  --matin-bg-2: #f8d49a;
  --matin-bg-3: #2a4a6b;
  --matin-overlay: rgba(255, 248, 230, 0.92);
  --soir-bg-1: #1a2530;
  --soir-bg-2: #2c3e50;
  --soir-bg-3: #4a5b6e;
  --soir-overlay: rgba(232, 232, 228, 0.92);
  --text-dark: #1a1a1a;
  --pattern: rgba(201, 161, 74, 0.08);
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Cormorant Garamond', serif;
  background: #f0e6d2;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile language toggle (hidden on desktop) */
.lang-toggle {
  display: none;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  justify-content: center;
  background: rgba(0,0,0,0.15);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.lang-toggle button {
  flex: 1;
  max-width: 140px;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  transition: all 0.2s;
}

.lang-toggle button.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(212, 175, 106, 0.4);
}

/* ============ HOME SCREEN ============ */
.home-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 220, 150, 0.4), transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(74, 91, 110, 0.3), transparent 50%),
    linear-gradient(135deg, #f4e9d3 0%, #efe2c4 100%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath fill='none' stroke='%23c9a14a' stroke-width='0.5' stroke-opacity='0.15' d='M40 5l10 15 17 5-12 13 3 17-18-9-18 9 3-17-12-13 17-5z'/%3E%3C/svg%3E");
  background-size: 80px 80px;
}

.home-title-banner {
  background: linear-gradient(180deg, #fdf6e3 0%, #f5ebd3 100%);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 2.5rem 3rem;
  box-shadow: 0 8px 32px rgba(138, 109, 42, 0.25);
  text-align: center;
  margin-bottom: 3rem;
  max-width: 700px;
  position: relative;
}

.home-title-banner::before,
.home-title-banner::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gold);
  border-radius: 50%;
}

.home-title-banner::before { top: -10px; left: -10px; }
.home-title-banner::after { bottom: -10px; right: -10px; }

.home-title-banner h1 {
  font-family: 'Cinzel', serif;
  font-size: 2.5rem;
  font-weight: 500;
  color: #2c1a0a;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.home-title-banner h1 .matin {
  font-weight: 700;
  color: #b8541a;
  font-size: 3rem;
  font-style: italic;
}

.home-title-banner h1 .soir {
  font-weight: 700;
  color: #1a2530;
  font-size: 3rem;
  font-style: italic;
}

.author {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  color: #5a4a2a;
  margin-top: 0.5rem;
}

.mode-selection {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-card {
  width: 280px;
  padding: 2rem 1.5rem;
  border-radius: 12px;
  border: 2px solid var(--border-gold);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.mode-card.matin {
  background: linear-gradient(135deg, #fef0d6 0%, #f9c98a 60%, #f4a361 100%);
  color: #4a2c10;
}

.mode-card.soir {
  background: linear-gradient(135deg, #2c3e50 0%, #4a5b6e 100%);
  color: #f5ebd3;
}

.mode-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.mode-card .icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.mode-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.mode-card .arabic-title {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.mode-card .count {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-top: 0.5rem;
}

.mode-card .progress-mini {
  margin-top: 1rem;
  height: 5px;
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.mode-card.soir .progress-mini { background: rgba(255,255,255,0.15); }

.mode-card .progress-mini-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.4s ease;
}

/* ============ APP SCREEN ============ */
.app-screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background-size: cover;
  background-position: center;
  transition: background 0.6s ease;
}

.app-screen.active { display: flex; }

.app-screen.matin {
  background:
    linear-gradient(135deg,
      rgba(255, 200, 120, 0.6) 0%,
      rgba(255, 150, 80, 0.5) 30%,
      rgba(100, 130, 180, 0.6) 100%),
    linear-gradient(135deg, #f4e9d3 0%, #2a4a6b 100%);
}

.app-screen.soir {
  background:
    linear-gradient(135deg,
      rgba(26, 37, 48, 0.7) 0%,
      rgba(74, 91, 110, 0.5) 50%,
      rgba(40, 55, 70, 0.8) 100%),
    linear-gradient(135deg, #1a2530 0%, #4a5b6e 100%);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(0,0,0,0.1);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.back-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  transition: all 0.2s;
}

.back-btn:hover { background: rgba(255,255,255,0.25); }

.app-title {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: 0.15em;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}

.progress-info {
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.2);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ffd700);
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(212, 175, 106, 0.6);
}

/* ============ INVOCATION CARDS ============ */
.cards-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: hidden;
  position: relative;
}

.invocation-card {
  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  animation: slideIn 0.5s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.card-panel {
  border: 2px solid var(--border-gold);
  border-radius: 10px;
  padding: 2rem 1.8rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.app-screen.matin .card-panel {
  background: var(--matin-overlay);
}

.app-screen.soir .card-panel {
  background: var(--soir-overlay);
}

.panel-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(138, 109, 42, 0.3);
}

.panel-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  color: #2c1a0a;
  margin-bottom: 0.75rem;
}

.app-screen.soir .panel-header h2 { color: #1a2530; }

.arabic-header {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  color: #2c1a0a;
  direction: rtl;
}

.panel-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #c9621a, #8a3a10);
  color: #fff;
  border-radius: 50%;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  margin-top: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.app-screen.soir .panel-number {
  background: linear-gradient(135deg, #2c3e50, #1a2530);
}

.subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: #8a541a;
  margin-top: 0.5rem;
}

.app-screen.soir .subtitle { color: #2c3e50; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}

.arabic-text {
  font-family: 'Amiri', serif;
  font-size: 1.5rem;
  line-height: 2.4;
  color: #1a1a1a;
  direction: rtl;
  text-align: center;
  white-space: pre-line;
  padding: 1rem 0;
}

.french-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  line-height: 1.7;
  color: #1a1a1a;
  text-align: center;
  white-space: pre-line;
  padding: 1rem 0;
}

.repeat-info {
  margin-top: 1rem;
  padding: 0.75rem;
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: #b8541a;
  border-top: 1px solid rgba(138, 109, 42, 0.2);
}

.app-screen.soir .repeat-info { color: #2c3e50; }

/* ============ COUNTER ============ */
.counter-section {
  padding: 1rem 1.5rem;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.counter-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.15);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.3);
}

.counter-label {
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
}

.counter-display {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  color: var(--gold);
  font-weight: 600;
  min-width: 80px;
  text-align: center;
  text-shadow: 0 0 8px rgba(212, 175, 106, 0.6);
}

.counter-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: 2px solid #fff;
  color: #fff;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: bold;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.counter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(212, 175, 106, 0.5);
}

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

.counter-btn.reset {
  background: rgba(255,255,255,0.15);
  width: 50px;
  height: 50px;
  font-size: 1rem;
}

/* ============ NAV BUTTONS ============ */
.nav-section {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(0,0,0,0.1);
}

.nav-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 0.85rem 1.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.3);
  transform: translateY(-2px);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn.next {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-color: var(--gold);
  font-weight: 600;
}

.nav-btn.next:hover:not(:disabled) {
  background: linear-gradient(135deg, #d4af6a, #a8853a);
  box-shadow: 0 4px 15px rgba(212, 175, 106, 0.4);
}

.read-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: rgba(76, 175, 80, 0.85);
  color: #fff;
  border-radius: 20px;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  border: 1px solid rgba(255,255,255,0.3);
}

.read-badge.hidden { display: none; }

/* ============ COMPLETION SCREEN ============ */
.completion-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.5s ease;
}

.completion-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.completion-card {
  background: linear-gradient(135deg, #fdf6e3, #f5ebd3);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 3rem 3rem;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(212, 175, 106, 0.4);
  animation: scaleUp 0.5s ease;
}

@keyframes scaleUp {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.completion-card .check-icon {
  font-size: 4rem;
  color: #4caf50;
  margin-bottom: 1rem;
}

.completion-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  color: #2c1a0a;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
}

.completion-card .arabic-praise {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  color: #b8541a;
  margin: 1rem 0;
  direction: rtl;
}

.completion-card p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  color: #4a2c10;
  margin-bottom: 1.5rem;
  font-style: italic;
}

.completion-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.completion-actions button {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  border: none;
  transition: all 0.2s;
}

.completion-actions .primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
}

.completion-actions .secondary {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold-dark);
}

.completion-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .invocation-card {
    grid-template-columns: 1fr;
  }
  .card-panel {
    max-height: calc((100vh - 250px) / 2);
    padding: 1.2rem;
  }
  .arabic-text { font-size: 1.4rem; line-height: 2.2; }
  .french-text { font-size: 1.05rem; }
  .home-title-banner h1 { font-size: 1.8rem; }
  .home-title-banner h1 .matin,
  .home-title-banner h1 .soir { font-size: 2.2rem; }
}

/* MOBILE: single panel at a time, full-screen, swipe-friendly */
@media (max-width: 768px) {
  .home-screen {
    padding: 1rem;
    justify-content: flex-start;
    padding-top: 3rem;
  }

  .home-title-banner {
    padding: 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
  }

  .home-title-banner h1 {
    font-size: 1.3rem;
    letter-spacing: 0.08em;
  }

  .home-title-banner h1 .matin,
  .home-title-banner h1 .soir {
    font-size: 1.7rem;
  }

  .author { font-size: 0.7rem; }

  .mode-selection {
    flex-direction: column;
    width: 100%;
    align-items: center;
    gap: 1rem;
  }

  .mode-card {
    width: 100%;
    max-width: 360px;
    padding: 1.5rem 1rem;
  }

  .mode-card .icon { font-size: 2.2rem; }
  .mode-card .arabic-title { font-size: 1.5rem; }
  .mode-card h2 { font-size: 1.2rem; }

  .lang-toggle { display: flex; }

  .app-header {
    padding: 0.6rem 0.8rem;
    flex-wrap: wrap;
  }

  .back-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
  }

  .app-title {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    order: 3;
    width: 100%;
    text-align: center;
    margin-top: 0.4rem;
  }

  .progress-info { font-size: 0.85rem; }

  .cards-container {
    padding: 0.75rem;
    position: relative;
    touch-action: pan-y;
  }

  .invocation-card {
    grid-template-columns: 1fr;
    gap: 0;
    max-width: 100%;
  }

  /* On mobile: hide non-active panel */
  .invocation-card[data-active-lang="ar"] .french-panel { display: none; }
  .invocation-card[data-active-lang="fr"] .arabic-panel { display: none; }

  .card-panel {
    max-height: calc(100dvh - 280px);
    padding: 1.2rem 1rem;
    border-radius: 12px;
  }

  .panel-header {
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
  }

  .panel-header h2 {
    font-size: 0.95rem;
    letter-spacing: 0.12em;
  }

  .arabic-header { font-size: 1.4rem; }

  .panel-number {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .arabic-text {
    font-size: 1.55rem;
    line-height: 2.4;
  }

  .french-text {
    font-size: 1.1rem;
    line-height: 1.6;
  }

  .repeat-info { font-size: 0.95rem; padding: 0.5rem; }

  .counter-section {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .counter-box {
    padding: 0.5rem 1rem;
    gap: 0.6rem;
  }

  .counter-label { font-size: 0.7rem; }
  .counter-display { font-size: 1.1rem; min-width: 55px; }

  .counter-btn {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
  }

  .counter-btn.reset {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
  }

  .nav-section {
    padding: 0.75rem 0.75rem 1rem;
    gap: 0.5rem;
  }

  .nav-btn {
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
  }

  .read-badge {
    font-size: 0.65rem;
    padding: 0.3rem 0.6rem;
  }

  .completion-card {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }

  .completion-card h2 { font-size: 1.4rem; }
  .completion-card .arabic-praise { font-size: 1.5rem; }
  .completion-card p { font-size: 1rem; }

  .completion-actions {
    flex-direction: column;
  }

  .completion-actions button {
    width: 100%;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .arabic-text { font-size: 1.35rem; line-height: 2.2; }
  .french-text { font-size: 1rem; }
  .counter-btn { width: 50px; height: 50px; font-size: 1rem; }
  .nav-btn { padding: 0.6rem 0.7rem; font-size: 0.75rem; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .card-panel { max-height: calc(100dvh - 200px); }
  .counter-section { padding: 0.5rem; }
  .nav-section { padding: 0.5rem; }
  .counter-btn { width: 48px; height: 48px; }
}
