/* تقویم عمومی — نمای ماهانه‌ی جلالی (D-397، ظاهرِ تصویری D-699)
 *
 * شبکه راست‌به‌چپ است: ستون اول شنبه. `direction: rtl` روی بدنه
 * هست، پس ترتیب طبیعی grid همان چیزی است که می‌خواهیم.
 *
 * همه‌ی رنگ‌ها از توکن‌های `riqx.css` می‌آیند، پس حالتِ تیره‌ی سایت
 * خودبه‌خود درست است — پیش از D-699 رنگ‌ها ثابت و فقط روشن بودند.
 */

.cal-page { max-width: 1240px; margin: 0 auto; padding: 32px 16px 64px; }

/* ── سرصفحه‌ی تصویری ─────────────────────────────── */

.cal-hero { position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 28px;
  padding: 34px 38px; border-radius: 28px; margin-bottom: 26px;
  /* رنگِ ثابتِ برند، نه توکن: در حالتِ تیره `--accent` روشن می‌شود و متنِ سفید
     روی آن خوانا نمی‌ماند */
  background: linear-gradient(135deg, #5B4BE8 0%, #7A6DF0 100%); color: #fff;
  box-shadow: 0 30px 60px -36px #5B4BE8; }
.cal-hero::before { content: ""; position: absolute; z-index: -1; width: 420px; height: 420px; border-radius: 50%;
  top: -210px; right: -120px; background: rgba(255, 255, 255, .09); }
.cal-hero::after { content: ""; position: absolute; z-index: -1; width: 220px; height: 220px; border-radius: 50%;
  bottom: -120px; right: 40%; background: rgba(255, 255, 255, .07); }

.cal-kicker { display: inline-flex; align-items: center; gap: 7px; padding: 5px 14px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .3); }
.cal-kicker svg, .cal-step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.cal-hero h1 { margin: 14px 0 6px; font-size: 2.5rem; line-height: 1.3; color: #fff; font-weight: 900; }
.cal-hero h1 span { font-weight: 400; opacity: .75; font-variant-numeric: tabular-nums; }
.cal-sub { margin: 0; max-width: 520px; line-height: 2; color: rgba(255, 255, 255, .9); font-size: .95rem; }

.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
.cal-step { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px;
  font-size: .88rem; font-weight: 700; text-decoration: none; color: #3B2FBF; background: #fff;
  box-shadow: 0 8px 20px -12px rgba(0, 0, 0, .45); transition: transform .15s ease; }
.cal-step:hover { transform: translateY(-2px); }
.cal-today-link { padding: 8px 14px; border-radius: 999px; font-size: .85rem; font-weight: 700; color: #fff;
  text-decoration: none; border: 1px dashed rgba(255, 255, 255, .6); }
.cal-today-link:hover { background: rgba(255, 255, 255, .14); }

.cal-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; padding: 0; }
.cal-stats li { display: flex; align-items: baseline; gap: 7px; padding: 9px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .25); }
.cal-stats b { font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.cal-stats span { font-size: .82rem; color: rgba(255, 255, 255, .88); }

.cal-hero-art { border-radius: 22px; overflow: hidden; background: #F6F4FE;
  box-shadow: 0 24px 48px -26px rgba(0, 0, 0, .55); transform: rotate(-2deg); }
.cal-hero-art img { display: block; width: 100%; height: auto; }

/* ── شبکه ─────────────────────────────────────────── */

.cal-board { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 24px;
  padding: 14px; box-shadow: var(--shadow-m); }
.cal-grid { border-radius: 16px; overflow: hidden; border: 1px solid var(--line-soft); }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }

.cal-head { background: var(--surface-2); border-bottom: 1px solid var(--line-soft); }
.cal-wd { padding: 12px 6px; text-align: center; font-size: .84rem; font-weight: 800; color: var(--ink-soft); }
.cal-wd.fri { color: var(--live); }
.cal-wd .short { display: none; }

.cal-cell { position: relative; min-height: 112px; padding: 8px; display: flex; flex-direction: column; gap: 5px;
  border-inline-start: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft);
  background: var(--surface); transition: background .15s; }
.cal-row:nth-child(2) .cal-cell { border-top: 0; }
.cal-cell:first-child { border-inline-start: 0; }
.cal-cell.fri { background: color-mix(in srgb, var(--live-wash) 45%, var(--surface)); }
.cal-cell.empty { background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface) 8px 16px); }
.cal-cell.has { background: color-mix(in srgb, var(--accent-wash) 45%, var(--surface)); }
.cal-cell:not(.empty):hover { background: var(--accent-wash); }

.cal-day { align-self: flex-start; display: inline-grid; place-items: center; min-width: 30px; height: 30px;
  padding: 0 6px; border-radius: 999px; font-size: .88rem; font-weight: 800; color: var(--ink-soft);
  text-decoration: none; font-variant-numeric: tabular-nums; }
a.cal-day:hover { background: var(--surface); color: var(--accent-ink); }
.cal-cell.fri .cal-day { color: var(--live); }
.cal-cell.past .cal-day { color: var(--ink-faint); font-weight: 600; }
.cal-cell.today { background: var(--accent-wash); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.today .cal-day { color: var(--on-accent); background: var(--accent); box-shadow: 0 6px 14px -6px var(--accent); }
.cal-now { position: absolute; top: 12px; inset-inline-end: 10px; font-size: .68rem; font-weight: 800;
  color: var(--accent-ink); }

/* ── رویداد در سلول ───────────────────────────────── */

.cal-ev { display: block; padding: 5px 8px; border-radius: 9px; font-size: .78rem; line-height: 1.55;
  text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-soft); border-inline-start: 4px solid var(--accent);
  box-shadow: var(--shadow-s); transition: transform .15s, box-shadow .15s; }
.cal-ev:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); }
.cal-ev.paid { border-inline-start-color: var(--warm); }
.cal-cell.past .cal-ev { opacity: .62; }
.cal-ev .t { display: inline-block; margin-bottom: 2px; padding: 0 7px; border-radius: 999px; font-size: .68rem;
  font-weight: 800; color: var(--accent-ink); background: var(--accent-wash); font-variant-numeric: tabular-nums; }
.cal-ev.paid .t { color: var(--warm); background: var(--warm-wash); }
.cal-ev .n { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; }

.cal-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px;
  margin: 12px 0 2px; padding: 0; font-size: .8rem; color: var(--ink-soft); }
.cal-legend li { display: inline-flex; align-items: center; gap: 7px; }
.cal-legend i { width: 14px; height: 14px; border-radius: 5px; }
.lg-free { background: var(--accent); }
.lg-paid { background: var(--warm); }
.lg-today { background: var(--accent-wash); box-shadow: inset 0 0 0 2px var(--accent); }
.lg-fri { background: var(--live-wash); }

/* ── فهرست زیر تقویم ──────────────────────────────── */

.cal-list { margin-top: 34px; }
.cal-list h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; margin: 0 0 14px; color: var(--ink); }
.cal-count { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  font-size: .85rem; color: var(--on-accent); background: var(--accent); font-variant-numeric: tabular-nums; }
.cal-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.cal-item { display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 16px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line-soft); box-shadow: var(--shadow-s);
  transition: border-color .15s, box-shadow .15s; scroll-margin-top: 90px; }
.cal-item:hover { border-color: var(--accent-2); box-shadow: var(--shadow-m); }
.cal-item:target { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }

.cal-tile { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 74px; height: 80px; border-radius: 18px; text-decoration: none; color: var(--on-accent);
  background: linear-gradient(160deg, var(--accent-2), var(--accent)); box-shadow: 0 12px 22px -14px var(--accent); }
.cal-item.paid .cal-tile { background: linear-gradient(160deg, #E59A55, var(--warm)); box-shadow: 0 12px 22px -14px var(--warm); }
.cal-item.past .cal-tile { filter: grayscale(.55); opacity: .75; }
.cal-tile b { font-size: 1.6rem; line-height: 1.15; font-weight: 900; font-variant-numeric: tabular-nums; }
.cal-tile small { font-size: .68rem; opacity: .92; }

.cal-item-body { flex: 1; min-width: 0; }
.cal-item-title { display: block; font-size: 1.02rem; font-weight: 800; color: var(--ink); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item-title:hover { color: var(--accent-ink); }
.cal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 7px; font-size: .8rem; }
.cal-meta > span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.cal-meta svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.cal-meta .m-price { color: var(--ok); background: var(--ok-wash); font-weight: 700; }
.cal-item.paid .m-price { color: var(--warm); background: var(--warm-wash); }
.cal-meta .m-past { color: var(--ink-faint); }

.cal-ics { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 999px;
  font-size: .82rem; font-weight: 700; text-decoration: none; color: var(--accent-ink);
  background: var(--accent-wash); transition: background .15s, color .15s; }
.cal-ics:hover { background: var(--accent); color: var(--on-accent); }
.cal-ics svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }

.cal-empty { margin-top: 30px; padding: 34px 20px; text-align: center; border-radius: 24px;
  background: var(--surface); border: 1px dashed var(--line); color: var(--ink-soft); }
.cal-empty svg { width: 54px; height: 54px; padding: 12px; border-radius: 18px; fill: none; stroke: var(--accent);
  stroke-width: 1.8; stroke-linecap: round; background: var(--accent-wash); }
.cal-empty p { margin: 12px 0 16px; font-weight: 700; color: var(--ink); }

/* ── تبلت ─────────────────────────────────────────── */
@media (max-width: 980px) {
  .cal-hero { grid-template-columns: 1fr; padding: 28px 24px; }
  .cal-hero-art { display: none; }
}

/* ── موبایل ────────────────────────────────────────
 * جدول هفت‌ستونه با عنوانِ رویداد زیر ۷۲۰ پیکسل خوانا نیست؛ پس
 * «ماهِ کوچک» می‌شود: فقط شماره‌ی روز، و روزِ دارای رویداد با نقطه‌ای
 * که با لمس به همان رویداد در فهرستِ پایین می‌رود.
 */
@media (max-width: 720px) {
  .cal-hero h1 { font-size: 1.9rem; }
  .cal-stats li { flex: 1 1 0; flex-direction: column; align-items: center; gap: 0; padding: 8px 6px; text-align: center; }
  .cal-stats span { font-size: .72rem; }

  .cal-board { padding: 8px; border-radius: 20px; }
  .cal-wd { padding: 8px 0; }
  .cal-wd .full { display: none; }
  .cal-wd .short { display: inline; }
  .cal-cell { min-height: 50px; padding: 5px 0; align-items: center; justify-content: center; gap: 2px; }
  .cal-cell .cal-ev, .cal-now { display: none; }
  .cal-day { align-self: center; min-width: 32px; height: 32px; padding: 0; }
  .cal-cell.has .cal-day { color: var(--accent-ink); background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent-2); }
  .cal-cell.has::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  .cal-cell.today .cal-day { color: var(--on-accent); background: var(--accent); box-shadow: none; }
  .cal-legend li:first-child, .cal-legend li:nth-child(2) { display: none; }

  .cal-item { flex-wrap: wrap; gap: 12px; padding: 12px; }
  .cal-tile { width: 62px; height: 68px; border-radius: 16px; }
  .cal-tile b { font-size: 1.35rem; }
  .cal-item-title { white-space: normal; line-height: 1.7; }
  .cal-ics { width: 100%; justify-content: center; }
}

/* ═══ چند رویداد در یک روز (D-712) ═══════════════════════════════════════
   سلول حداکثر دو رویداد و «+N»؛ شمارِ روز کنارِ شماره‌ی روز؛ «هم‌زمان» با
   نقطه‌ی هشدار. برگه‌ی روز یک <dialog> است: در دسکتاپ وسطِ صفحه، در موبایل
   از پایین بالا می‌آید. فهرست به تفکیکِ روز. */

.cal-n { position: absolute; top: 12px; inset-inline-end: 8px; padding: 1px 7px; border-radius: 999px;
  font-size: .66rem; font-weight: 800; color: var(--accent-ink); background: var(--surface);
  border: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-n { top: 30px; }
.cal-ev.ov { position: relative; }
.cal-ev.ov::after { content: ""; position: absolute; top: 6px; inset-inline-end: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--live); box-shadow: 0 0 0 2px var(--surface); }
.cal-more { align-self: stretch; padding: 4px 8px; border-radius: 9px; font-size: .74rem; font-weight: 800;
  text-align: center; text-decoration: none; color: var(--accent-ink); background: var(--surface);
  border: 1px dashed var(--accent-2); transition: background .15s, color .15s; }
.cal-more:hover { background: var(--accent); color: var(--on-accent); border-style: solid; }
.lg-ov { background: var(--live); border-radius: 50% !important; width: 10px !important; height: 10px !important; }

/* ── فهرست به تفکیکِ روز ── */
.cal-dg { scroll-margin-top: 90px; margin-bottom: 22px; }
.cal-dg:target .cal-dg-head { box-shadow: 0 0 0 3px var(--accent-wash); border-color: var(--accent); }
.cal-dg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 10px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.cal-dg-date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 48px;
  height: 50px; border-radius: 13px; font-size: .64rem; color: var(--on-accent);
  background: linear-gradient(160deg, var(--accent-2), var(--accent)); line-height: 1.2; }
.cal-dg-date b { font-size: 1.2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.cal-dg-title { display: flex; flex-direction: column; line-height: 1.6; }
.cal-dg-title b { color: var(--ink); font-size: .98rem; }
.cal-dg-title small { color: var(--ink-faint); font-size: .78rem; }
.cal-tile b { font-size: 1.25rem; }
.cal-meta .m-ov { color: var(--live); background: var(--live-wash); font-weight: 700; }

/* ── برگه‌ی روز ── */
.cal-sheet { padding: 0; border: 0; background: transparent; width: min(640px, calc(100% - 32px));
  max-width: none; max-height: min(82vh, 760px); margin: auto; overflow: visible; }
.cal-sheet::backdrop { background: rgba(14, 15, 36, .5); backdrop-filter: blur(4px); }
.cal-sheet[open] .cal-sheet-box { animation: cal-sheet-in .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes cal-sheet-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.cal-sheet-box { display: flex; flex-direction: column; max-height: min(82vh, 760px); border-radius: 24px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
  overflow: hidden; }
.cal-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(135deg, var(--accent-wash), transparent 70%); }
.cal-sheet-head small { font-size: .74rem; color: var(--accent-ink); font-weight: 700; }
.cal-sheet-head h3 { margin: 2px 0 0; font-size: 1.2rem; color: var(--ink); }
.cal-sheet-x { width: 36px; height: 36px; flex: none; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); color: var(--ink-soft); font-size: 1.3rem; line-height: 1; }
.cal-sheet-x:hover { background: var(--accent-wash); color: var(--accent-ink); }
.cal-sheet-body { overflow-y: auto; padding: 14px 16px; overscroll-behavior: contain; }
.cal-sheet-count { margin: 0 4px 10px; font-size: .82rem; color: var(--ink-faint); }
.cal-sheet-body ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cal-sheet-body .cal-item { box-shadow: none; }
.cal-sheet-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--line-soft); }
.cal-sheet-foot button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer;
  background: var(--surface); color: var(--ink-soft); font: inherit; font-size: .84rem; font-weight: 700; }
.cal-sheet-foot button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.cal-sheet-foot button:disabled { opacity: .45; cursor: default; }

@media (max-width: 720px) {
  .cal-n, .cal-more { display: none; }
  /* ماهِ کوچک «هم‌زمان» را نشان نمی‌دهد؛ برگه و فهرست نشان می‌دهند */
  .cal-legend li:nth-child(3) { display: none; }
  /* ماهِ کوچک: یک تا سه نقطه برای شمارِ رویدادهای روز */
  .cal-cell[data-n="2"]::after { box-shadow: 9px 0 0 var(--accent); transform: translateX(4.5px); }
  .cal-cell[data-n="3"]::after, .cal-cell[data-n="4"]::after, .cal-cell[data-n="5"]::after,
  .cal-cell[data-n="6"]::after, .cal-cell[data-n="7"]::after, .cal-cell[data-n="8"]::after {
    box-shadow: 9px 0 0 var(--accent), -9px 0 0 var(--accent); }
  /* برگه از پایین: کشوی گوشی */
  .cal-sheet { width: 100%; margin: auto 0 0; max-height: 88vh; }
  .cal-sheet-box { max-height: 88vh; border-radius: 24px 24px 0 0; }
  .cal-sheet[open] .cal-sheet-box { animation: cal-sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
  @keyframes cal-sheet-up { from { transform: translateY(40%); opacity: .4; } }
}
@media (prefers-reduced-motion: reduce) {
  .cal-sheet[open] .cal-sheet-box { animation: none; }
}

/* صفحه‌بندیِ فهرست (D-713، D-715) حالا مشترک است و در `event.css` (D-717). */
