@font-face {
  font-family: 'KFGQPC Uthman';
  src: url('/meal/fonts/KFGQPC_Uthmanic_Script_HAFS_Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1a2332;
  --muted: #5a6577;
  --paper: #f7f4ee;
  --paper-edge: #e8e2d6;
  --accent: #1a5490;
  --accent-deep: #123a63;
  --nav-bg: rgba(12, 18, 28, 0.92);
  --stage-bg: #0c121c;
  --slide-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --font-ui: 'IBM Plex Sans', system-ui, sans-serif;
  --font-meal: 'Source Serif 4', Georgia, serif;
  --font-ar: 'KFGQPC Uthman', 'Traditional Arabic', serif;
  --fs-ar: 1;
  --fs-latin: 1;
  --fs-meal: 1;
  --fs-kavram: 1;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--stage-bg);
  color: var(--ink);
  font-family: var(--font-ui);
}

.deck {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* —— Start —— */
.start-screen {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(26, 84, 144, 0.35), transparent 70%),
    var(--stage-bg);
}

.start-card {
  width: min(440px, 100%);
  padding: 36px 32px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--slide-shadow);
  text-align: center;
}

.start-brand {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.start-card h1 {
  margin: 0 0 12px;
  font-family: var(--font-meal);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.start-lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 28px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font: 600 1rem var(--font-ui);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(26, 84, 144, 0.35);
}

.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }

.start-home {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}
.start-home:hover { color: var(--accent); }

/* —— Stage / 4:3 —— */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 12px 0;
}
.stage[hidden],
.start-screen[hidden] {
  display: none !important;
}

.slide-frame {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.slide {
  aspect-ratio: 4 / 3;
  width: min(100%, calc((100dvh - 72px) * 4 / 3));
  height: auto;
  max-height: calc(100dvh - 72px);
  background: var(--paper);
  border-radius: 6px;
  box-shadow: var(--slide-shadow);
  border: 1px solid var(--paper-edge);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(16px, 3.5%, 40px) clamp(18px, 4%, 48px);
  animation: slideIn 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.slide.is-leaving {
  animation: slideOut 180ms ease-in forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes slideOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(-14px); }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .slide.is-leaving { animation: none; }
}

.slide-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(8px, 2%, 20px);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--paper-edge);
  flex-shrink: 0;
}

.slide-ref {
  font-size: clamp(0.85rem, 2.2cqi, 1.15rem);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.slide-sure {
  font-size: clamp(0.75rem, 1.8cqi, 0.95rem);
  color: var(--muted);
  text-align: right;
}

.slide-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(10px, 2.5%, 22px);
  overflow: auto;
  container-type: size;
}

.slide-arabic {
  font-family: var(--font-ar);
  font-size: calc(max(1.35rem, 5.2cqh) * var(--fs-ar));
  line-height: 1.85;
  text-align: center;
  color: var(--ink);
  direction: rtl;
}

.slide-latin {
  font-family: var(--font-meal);
  font-style: italic;
  font-size: calc(max(0.9rem, 2.8cqh) * var(--fs-latin));
  line-height: 1.55;
  text-align: center;
  color: var(--muted);
}

.slide-meal {
  font-family: var(--font-meal);
  font-size: calc(max(0.95rem, 3.2cqh) * var(--fs-meal));
  line-height: 1.65;
  text-align: center;
  color: var(--ink);
}

.slide-meal sup,
.slide-meal .kuran-kavram-link {
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.slide-meal p { margin: 0; }

/* —— Nav —— */
.deck-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  color: #e8eef6;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: 500 0.85rem var(--font-ui);
  cursor: pointer;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.12); }
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.nav-btn-mid { background: rgba(26, 84, 144, 0.45); border-color: rgba(26, 84, 144, 0.6); }
.nav-btn-mid:hover { background: rgba(26, 84, 144, 0.65); }

.nav-counter {
  min-width: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: rgba(232, 238, 246, 0.75);
  padding: 0 8px;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.nav-icon:hover { background: rgba(255, 255, 255, 0.1); }
.nav-icon.is-active {
  background: rgba(26, 84, 144, 0.55);
  border-color: rgba(26, 84, 144, 0.75);
}

.nav-size-wrap {
  position: relative;
  margin-left: 4px;
}

.size-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(280px, calc(100vw - 24px));
  padding: 12px;
  background: #161e2b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: #e8eef6;
  z-index: 30;
}
.size-panel[hidden] { display: none !important; }

.size-panel-title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 238, 246, 0.65);
  font-weight: 600;
}

.size-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.size-row + .size-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.size-row-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e8eef6;
}

.size-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.size-stepper button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  font: 600 1rem var(--font-ui);
  line-height: 1;
  cursor: pointer;
}
.size-stepper button:hover { background: rgba(255, 255, 255, 0.14); }
.size-stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}

.size-stepper-value {
  min-width: 3.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: rgba(232, 238, 246, 0.85);
}

.size-panel-reset {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: transparent;
  color: rgba(232, 238, 246, 0.8);
  font: 500 0.8rem var(--font-ui);
  cursor: pointer;
}
.size-panel-reset:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

@media (max-width: 640px) {
  .nav-btn span { display: none; }
  .nav-btn { padding: 0 10px; }
  .stage { padding: 8px 8px 0; }
  .size-panel { right: -8px; }
}

/* —— Loading —— */
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 18, 28, 0.72);
  color: #fff;
  font-size: 1rem;
  z-index: 40;
}
.loading[hidden] {
  display: none !important;
}

/* —— Sure panel (Sure Ayet Seç) —— */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.backdrop[hidden],
.list-backdrop[hidden],
.sure-panel:not(.open),
.ayet-list-drawer[hidden] { display: none !important; }

.sure-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: #fff;
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
  transform: translateX(-105%);
  transition: transform 220ms ease;
}
.sure-panel.open { transform: none; }

.sure-panel-header {
  padding: 16px 16px 12px;
  background: linear-gradient(135deg, #1a5490, #2c3e50);
  color: #fff;
  flex-shrink: 0;
}

.sure-panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sure-panel-title-row h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.sure-panel-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}
.sure-panel-close:hover { background: rgba(255, 255, 255, 0.28); }

.sure-search-label {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
  margin-bottom: 4px;
}

.sure-search-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  font: 400 0.95rem var(--font-ui);
}

.sure-panel-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.sure-list {
  overflow-y: auto;
  border-right: 1px solid #e8ecf1;
  padding: 8px;
}

.sure-item-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 0.88rem var(--font-ui);
  cursor: pointer;
}
.sure-item-btn:hover { background: #eef3f9; }
.sure-item-btn.is-selected {
  background: #1a5490;
  color: #fff;
}
.sure-item-btn .sure-no {
  display: inline-block;
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  margin-right: 6px;
}
.sure-item-btn.is-selected .sure-no { opacity: 1; }

.ayet-picker-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}
.ayet-picker-pane[hidden] { display: none !important; }

.ayet-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.ayet-picker-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
}
.ayet-picker-open-all {
  border: 1px solid #c5d3e4;
  background: #f4f7fb;
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font: 500 0.8rem var(--font-ui);
  cursor: pointer;
}
.ayet-picker-open-all:hover { background: #e8f0f8; }

.ayet-picker-manual {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.ayet-picker-input {
  flex: 1;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #c5d3e4;
  border-radius: 6px;
  font: 400 0.9rem var(--font-ui);
}
.ayet-picker-go {
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: 600 0.85rem var(--font-ui);
  cursor: pointer;
}

.ayet-picker-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  align-content: start;
}

.ayet-picker-num {
  min-height: 40px;
  border: 1px solid #d5dde8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 500 0.85rem var(--font-ui);
  cursor: pointer;
}
.ayet-picker-num:hover,
.ayet-picker-num:focus {
  border-color: var(--accent);
  background: #eef4fb;
  outline: none;
}
.ayet-picker-num.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 520px) {
  .sure-panel-body { grid-template-columns: 1fr; grid-template-rows: 40% 60%; }
  .sure-list { border-right: none; border-bottom: 1px solid #e8ecf1; }
}

/* —— Ayet list drawer —— */
.list-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 70;
}

.ayet-list-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: #fff;
  z-index: 80;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1a5490, #2c3e50);
  color: #fff;
  flex-shrink: 0;
}
.drawer-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.ayet-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.ayet-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 400 0.9rem var(--font-ui);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.ayet-list-item:hover { background: #eef3f9; }
.ayet-list-item.is-current {
  background: #e8f0f8;
  border-left-color: var(--accent);
  font-weight: 600;
  color: var(--accent);
}
.ayet-list-item .ayet-list-preview {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* —— Kavram overlay (büyük ekran) —— */
.kavram-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.5vh, 28px);
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(6px);
}
.kavram-overlay[hidden] {
  display: none !important;
}

.kavram-card {
  width: min(1100px, 96vw);
  height: min(92vh, 920px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 14px;
  border: 1px solid var(--paper-edge);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: kavramIn 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes kavramIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .kavram-card { animation: none; }
}

.kavram-card-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.kavram-card-titles {
  min-width: 0;
  flex: 1;
}

.kavram-card-no {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.kavram-card-title {
  margin: 0;
  font-family: var(--font-meal);
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.kavram-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kavram-size-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.kavram-size-stepper button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: 600 1.05rem var(--font-ui);
  cursor: pointer;
}
.kavram-size-stepper button:hover { background: rgba(255, 255, 255, 0.22); }
.kavram-size-stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}

.kavram-size-val {
  min-width: 3.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.9);
}

.kavram-card-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}
.kavram-card-close:hover { background: rgba(255, 255, 255, 0.28); }

.kavram-card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(20px, 3.5vh, 36px) clamp(22px, 4vw, 44px);
  font-family: var(--font-meal);
  font-size: calc(1.15rem * var(--fs-kavram));
  line-height: 1.7;
  color: var(--ink);
}

.kavram-card-body p {
  margin: 0 0 0.9em;
}
.kavram-card-body p:last-child {
  margin-bottom: 0;
}

.kavram-card-text {
  margin-bottom: 1.2em;
}

.kavram-card-detay {
  padding-top: 1em;
  border-top: 1px solid var(--paper-edge);
  color: #2a3444;
}

.kavram-card-body .loading-inline,
.kavram-card-body .kavram-error {
  color: var(--muted);
  font-style: italic;
}

.kavram-card-body sup {
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 600;
}

.kavram-card-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--paper-edge);
  background: #f0ebe3;
  color: var(--muted);
  font-size: 0.85rem;
}

.kavram-card-foot a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.kavram-card-foot a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .kavram-card {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .kavram-card-head {
    flex-wrap: wrap;
  }
  .kavram-card-actions {
    width: 100%;
    justify-content: space-between;
  }
}
