/* =============================================
   BASE — 365Ganj Design System v2
   Clean, modern, inspired by premium apps
   ============================================= */

/* ── فونت اصلی اپ: IRANSans (فارسی + اعداد فارسی) ──
   فایل‌های فونت باید در مسیر assets/fonts/ قرار داشته باشند */
@font-face{font-family:IRANSans;src:url('../fonts/IRANSansWeb(FaNum).woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap}

@font-face{font-family:IRANSans;src:url('../fonts/IRANSansWeb(FaNum)_Bold.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap}

:root {
  --nav-height: 72px;
  --page-pad: 16px;
  --page-gap: 14px;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow-soft: 0 8px 24px rgba(0,0,0,.08);
  --shadow: 0 16px 48px rgba(0,0,0,.12);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.16);
  --blur: blur(20px);
  --ease: cubic-bezier(.25,.46,.45,.94);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --font: "IRANSans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  --transition: .2s var(--ease);
}

body[data-theme="light"] {
  --bg-0: #efefef;
  --bg-1: #f0f5f2;
  --bg-2: #ffffff;
  --surface: rgba(255,255,255,.85);
  --surface-strong: rgba(255,255,255,.96);
  --surface-soft: rgba(248,250,249,.90);
  --surface-deep: rgba(10,16,13,.96);
  --text: #0f1f18;
  --text-2: #2d4a3c;
  --muted: #6b8a7a;
  --line: rgba(15,130,80,.08);
  --line-strong: rgba(30, 141, 93, 0.144);
  --primary: #0f8a55;
  --primary-light: #12a866;
  --primary-2: #5dd4a0;
  --primary-3: rgba(15,138,85,.10);
  --primary-deep: #0a6a40;
  --gold: #e8a93a;
  --sky: #3b82f6;
  --rose: #e8607e;
  --emerald: #10b96a;
  --jade: #45c994;
  --purple: #8b5cf6;
  color-scheme: light;
}

body[data-theme="dark"] {
  --bg-0: #060e09;
  --bg-1: #0a150f;
  --bg-2: #0e1b14;
  --surface: rgba(14,27,20,.72);
  --surface-strong: rgba(18,32,24,.94);
  --surface-soft: rgba(20,32,26,.80);
  --surface-deep: rgba(3,8,5,.97);
  --text: #ecf5ef;
  --text-2: #b8d4c4;
  --muted: rgba(220,240,228,.55);
  --line: rgba(255,255,255,.06);
  --line-strong: rgb(255 255 255 / 14%);
  --primary: #22d48e;
  --primary-light: #2ae898;
  --primary-2: #80e9be;
  --primary-3: rgba(34,212,142,.14);
  --primary-deep: #17a068;
  --gold: #f0c040;
  --sky: #60a5fa;
  --rose: #fb7097;
  --emerald: #50d99a;
  --jade: #72e8c0;
  --purple: #a78bfa;
  color-scheme: dark;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }

body {
  direction: rtl;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background var(--transition), color var(--transition);
  display: flex;
  justify-content: center;
}

button, input, textarea { font: inherit; color: inherit; }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ── App Shell ── */
#app-shell {
  /* پیش‌فرض: تمام‌عرض (موبایل و تبلت همیشه تمام‌عرض هستند)
     قاب موبایلی فقط برای دسکتاپ در مدیا کوئری پایین اعمال می‌شود */
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  container-type: size;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 40% at 20% -10%, color-mix(in srgb, var(--primary) 10%, transparent), transparent),
    radial-gradient(ellipse 60% 30% at 80% 5%, color-mix(in srgb, var(--sky) 7%, transparent), transparent),
    var(--bg-0);
  background-attachment: local;
}

.is-hidden { display: none; }

.view {
  flex: 1;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.view::-webkit-scrollbar { display: none; }

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--page-gap);
  padding: calc(14px + env(safe-area-inset-top)) var(--page-pad) calc(20px + env(safe-area-inset-bottom));
}

.page.game-page {
    padding: 0 !important;
    height: -webkit-fill-available;
    position: relative;
}

.game-frame {
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: 100cqh;
    border: 0;
}

/* ── Game (کودک) back button ──
   دکمه سفید بازگشت بالای iframe بخش کودک */
.game-back {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: 12px;
    z-index: 70;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    color: #000000;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .15s var(--ease), opacity .2s var(--ease);
}
.game-back:active { transform: scale(.9); }
.game-back svg { width: 22px; height: 22px; display: block; }

/* ── Typography ── */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--text);
}

.page-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 2px;
}

.micro-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

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

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -.02em;
}

/* ── Chips & Pills ── */
.section-chip {
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-3);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
}

.section-link {
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-3);
  border: 1px solid color-mix(in srgb, var(--primary) 12%, transparent);
  transition: var(--transition);
}
.section-link:active { transform: scale(.95); opacity: .8; }

/* ── Glass / Cards ── */


.glass { border-radius: var(--radius-xl); }
.soft-panel { border-radius: var(--radius-lg); }

/* ── Buttons ── */
.icon-btn,
.primary-btn,
.ghost-btn,
.home-avatar,
.search-pill,
.input-box,
.task-check,
.task-delete,
.task-action,
.player-action,
.mode-card,
.nav-item,
.story-card,
.report-mini,
.book-card,
.booklist-item,
.profile-link,
.profile-stat,
.edit-form button {
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  font-size: 15px;
}

.icon-btn:active,
.primary-btn:active,
.ghost-btn:active,
.home-avatar:active,
.search-pill:active,
.story-card:active,
.report-mini:active,
.book-card:active,
.booklist-item:active,
.player-action:active,
.mode-card:active,
.nav-item:active,
.task-item:active {
  transform: scale(.97);
  opacity: .85;
}

.primary-btn,
.ghost-btn {
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 30%, transparent);
  border: none;
}

.ghost-btn {
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
}

/* ── Inputs ── */
.search-pill,
.input-box {
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-strong);
  border: 1.5px solid var(--line-strong);
  font-size: 14px;
}

.search-pill input,
.input-box input,
.input-box textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.search-pill input::placeholder,
.input-box input::placeholder,
.input-box textarea::placeholder { color: var(--muted); }

.input-box.textarea { min-height: 96px; padding-top: 14px; align-items: flex-start; }
.input-box textarea { resize: none; line-height: 1.7; }
.search-pill--full { width: 100%; }

/* ── Empty State ── */
.empty-row {
  min-height: 80px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1.5px dashed var(--line-strong);
  font-size: 13px;
}

/* ── Skeleton ── */
.skeleton,
.skeleton-pill {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-radius: 8px;
}

.skeleton::after,
.skeleton-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.45) 45%, transparent 90%);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

/* ── Boot Screen ── */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--bg-0);
}

.boot-card {
  min-width: 200px;
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.boot-logo {
  width: 80px;
  height: 80px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.boot-title { font-size: 20px; font-weight: 900; letter-spacing: -.02em; }
.boot-subtitle { font-size: 12px; color: var(--muted); }

.boot-loader {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--primary-3);
  overflow: hidden;
}
.boot-loader span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  animation: boot-slide 1.1s infinite ease-in-out alternate;
}
@keyframes boot-slide { from { transform: translateX(-10%); } to { transform: translateX(240%); } }

/* ── Bottom Nav ── */
.bottom-nav {
  flex-shrink: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface-strong) 90%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  position: sticky;
  bottom: 0;
  z-index: 25;
}

.bottom-nav.is-hidden { display: none; }


.nav-item {
  height: 56px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: transparent;
  border: none;
  position: relative;
  overflow: hidden;
}

.nav-item.is-active {
  color: var(--primary);
  background: var(--primary-3);
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: transform .2s var(--ease-spring);
}
.nav-icon svg {
    width: -webkit-fill-available;
}

.nav-item.is-active .nav-icon {
  transform: translateY(-1px) scale(1.05);
}
.nav-item.is-active[data-tab="game"] {
    color: #e91e63;
}
.nav-label { font-size: 10px; font-weight: 700; letter-spacing: .01em; }

/* ── Toast ── */
.toast-host {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 12px 16px;
  border-radius: 16px;
  color: #fff;
  background: rgba(10,18,14,.92);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08);
  text-align: center;
  place-self: center;
  width: fit-content;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 16px;
  display: grid;
  align-items: end;
  background: rgba(0,0,0,.50);
  backdrop-filter: blur(10px);
}

.modal.is-hidden { display: none; }

.modal-sheet {
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  border-radius: 28px 28px 24px 24px;
  max-height: 88dvh;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px);
}
.modal-sheet::-webkit-scrollbar { display: none; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.edit-form { display: grid; gap: 12px; }
.task-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* ── Dark mode glass adjustments ── */
body[data-theme="dark"] .glass,
body[data-theme="dark"] .soft-panel,
body[data-theme="dark"] .task-item,
body[data-theme="dark"] .task-overview-card,
body[data-theme="dark"] .profile-stat,
body[data-theme="dark"] .profile-link,
body[data-theme="dark"] .report-mini,
body[data-theme="dark"] .story-card,
body[data-theme="dark"] .hero-panel,
body[data-theme="dark"] .search-drawer,
body[data-theme="dark"] .modal-sheet,
body[data-theme="dark"] .player-shell,
body[data-theme="dark"] .pomo-panel{
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 8px 32px rgba(0,0,0,.28);
}

/* ── Desktop frame ──
   قاب موبایلی فقط برای دسکتاپ (دستگاه‌های موس‌دار) اعمال می‌شود.
   ابعاد قاب بر اساس رزولوشن صفحه به‌صورت خودکار تنظیم می‌شود تا
   همیشه مانند یک گوشی واقعی (نسبت 430×932) و کاملاً داخل صفحه
   قرار بگیرد؛ در هیچ رزولوشنی از پایین بریده نمی‌شود. */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  body {
    height: 100vh;
    height: 100dvh;
    padding: 0;
    overflow: hidden;
    background: var(--bg-1);
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  #app-shell {
    min-height: 0;
    width: min(430px, 100vw - 32px);
    width: min(430px, 100vw - 32px, calc((100dvh - 48px) * 0.4614));
    height: min(932px, 100vh - 48px);
    height: min(932px, 100dvh - 48px);
    border-radius: 40px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--line), 0 40px 80px rgba(0,0,0,.24);
  }
}

/* ── Image Shell ── */
.image-shell {
  position: relative;
  overflow: hidden;
}

.image-shell.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.30), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
  z-index: 1;
}

.image-shell.is-loading img { opacity: 0; }

.image-shell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity .25s ease;
}

.image-shell.is-loaded::before { display: none; }

/* ── Animations ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 374px) {
  :root {
    --page-pad: 12px;
    --nav-height: 68px;
  }
  .page-title { font-size: 20px; }
}

/* meta / status chips */
.meta-chip,
.status-chip {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
}

.meta-date {
  display: grid;
  gap: 2px;
}
.meta-date span { font-size: 10px; color: var(--muted); }
.meta-date strong { font-size: 14px; font-weight: 900; }

/* premium card */
.premium-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ── Global Polish ── */

/* Better button press feel */
button:active:not(:disabled) {
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scroll for all scrollable areas */
.view {
  scroll-behavior: smooth;
}

/* iOS-style glass cards */
.glass {
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
}

/* Better primary-btn */
.primary-btn {
  transition: transform .18s var(--ease-spring), box-shadow .18s ease;
}
.primary-btn:active { transform: scale(.97); }

/* icon-btn press feel */
.icon-btn {
  transition: transform .15s var(--ease-spring), background .15s ease;
}
.icon-btn:active { transform: scale(.90); }

/* smoother page transitions */
.page {
  animation: page-in .28s var(--ease);
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
