/* ════════════════════════════════════════════════════════════
   HijriDates — design system
   Desktop: immersive editorial night-sky
   Mobile:  pocket-app shell with bottom navigation
   ════════════════════════════════════════════════════════════ */

:root {
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Outfit', system-ui, sans-serif;
  --ar: 'Amiri', serif;

  --bg: #06080f;
  --bg2: #0a101f;
  --card: rgba(18, 24, 42, .62);
  --card-solid: #0e1426;
  --line: rgba(243, 232, 208, .09);
  --line-strong: rgba(243, 232, 208, .18);
  --ink: #f3e9d4;
  --mut: #97a0b6;
  --gold: #d9ab52;
  --gold-soft: #f0d18c;
  --gold-dim: rgba(217, 171, 82, .14);
  --teal: #7fb6a4;
  --white-day: #efe7d3;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .65);
  --ring: rgba(217, 171, 82, .55);
}

[data-theme="light"] {
  --bg: #f5efe1;
  --bg2: #ece2cc;
  --card: rgba(255, 252, 244, .72);
  --card-solid: #fffcf4;
  --line: rgba(36, 32, 22, .10);
  --line-strong: rgba(36, 32, 22, .22);
  --ink: #221e14;
  --mut: #6f6a5b;
  --gold: #a87b1e;
  --gold-soft: #8a6418;
  --gold-dim: rgba(168, 123, 30, .12);
  --teal: #3f7a68;
  --white-day: #5c5132;
  --shadow: 0 24px 50px -28px rgba(60, 48, 20, .35);
  --ring: rgba(168, 123, 30, .55);
}

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

html { scroll-behavior: smooth; }
html, body { background: var(--bg); }

body {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .6s ease, color .6s ease;
}

::selection { background: var(--gold); color: #14100a; }

/* ───────────────────── ambient sky ───────────────────── */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#stars { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; transition: opacity .6s; }
[data-theme="light"] #stars { opacity: .14; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.orb-a { width: 46vw; height: 46vw; top: -18vw; right: -12vw; background: radial-gradient(circle, rgba(217,171,82,.16), transparent 65%); }
.orb-b { width: 40vw; height: 40vw; bottom: -16vw; left: -10vw; background: radial-gradient(circle, rgba(82,114,217,.12), transparent 65%); }
[data-theme="light"] .orb-a { background: radial-gradient(circle, rgba(217,171,82,.25), transparent 65%); }
[data-theme="light"] .orb-b { background: radial-gradient(circle, rgba(150,130,80,.18), transparent 65%); }
.grain {
  position: absolute; inset: 0; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

main { position: relative; z-index: 1; }

/* ───────────────────── shared bits ───────────────────── */
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-weight: 500; letter-spacing: .02em; font-size: 1.05rem; }
.brand b { color: var(--gold); font-weight: 700; }
.brand-moon { color: var(--gold); transform: rotate(-18deg); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  cursor: pointer; transition: border-color .25s, transform .25s;
}
.icon-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
[data-theme="dark"] .ic-sun { display: none; }
[data-theme="light"] .ic-moon { display: none; }

.disclaimer { font-size: .8rem; color: var(--mut); font-style: italic; max-width: 52ch; }

.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); display: inline-block; animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--gold-dim); } 55% { box-shadow: 0 0 0 9px transparent; } }

/* dots */
.d { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.d-ev { background: var(--gold); }
.d-wh { background: var(--white-day); box-shadow: 0 0 6px rgba(239,231,211,.7); }
[data-theme="light"] .d-wh { box-shadow: none; }
.d-mt { background: var(--teal); }

/* ════════════════════════════════════════════════════════════
   DESKTOP
   ════════════════════════════════════════════════════════════ */
.dt { display: block; }

/* ── nav ── */
.dt-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  padding: .9rem clamp(1.5rem, 4vw, 3.5rem);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .4s, background .4s;
}
.dt-nav.scrolled { border-bottom-color: var(--line); }
.nav-links { display: flex; gap: 2.2rem; }
.nav-links a {
  color: var(--mut); text-decoration: none; font-size: .92rem; letter-spacing: .04em;
  transition: color .25s; position: relative;
}
.nav-links a::after {
  content: ''; position: absolute; left: 0; bottom: -5px; height: 1px; width: 0;
  background: var(--gold); transition: width .3s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { width: 100%; }
.nav-actions { display: flex; align-items: center; gap: .8rem; }

.year-ctl {
  display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); overflow: hidden;
}
.yc-btn, .yc-reset {
  background: none; border: none; color: var(--mut); font-size: 1.05rem; cursor: pointer;
  padding: .4rem .65rem; transition: color .2s;
}
.yc-btn:hover, .yc-reset:hover { color: var(--gold); }
.yc-reset { border-left: 1px solid var(--line); font-size: .9rem; }
#yearSel {
  appearance: none; -webkit-appearance: none; background: none; border: none; color: var(--ink);
  font-family: var(--sans); font-weight: 600; font-size: .95rem; cursor: pointer; text-align: center;
  padding: .4rem .15rem;
}
#yearSel:focus { outline: none; color: var(--gold); }
#yearSel option { background: var(--card-solid); color: var(--ink); }

.dl-wrap { position: relative; }
.dl-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--gold); color: #17120a; border: none; border-radius: 999px;
  font-family: var(--sans); font-weight: 700; font-size: .88rem; letter-spacing: .03em;
  padding: .55rem 1.1rem; cursor: pointer; transition: transform .25s, box-shadow .25s;
}
.dl-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -10px var(--gold); }
.dl-menu {
  position: absolute; right: 0; top: calc(100% + .6rem); min-width: 240px;
  background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: .45rem; display: none; z-index: 60;
}
.dl-menu.open { display: block; }
.dl-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  border-radius: 11px; padding: .65rem .8rem; color: var(--ink); font-family: var(--sans);
  transition: background .2s;
}
.dl-menu button:hover { background: var(--gold-dim); }
.dl-menu b { display: block; font-size: .92rem; }
.dl-menu span { font-size: .76rem; color: var(--mut); }

/* ── hero ── */
.hero {
  min-height: 100svh; display: flex; align-items: center;
  padding: 7rem clamp(1.5rem, 6vw, 6rem) 4rem;
  position: relative; overflow: hidden;
}
.hero-moon {
  position: absolute; right: clamp(2rem, 10vw, 11rem); top: 50%;
  width: clamp(260px, 30vw, 460px); height: clamp(260px, 30vw, 460px);
  transform: translateY(-50%);
}
.hero-moon svg { width: 100%; height: 100%; overflow: visible; }
.moon-disc { fill: rgba(243, 233, 212, .07); stroke: var(--line); stroke-width: .6; }
[data-theme="light"] .moon-disc { fill: rgba(36,32,22,.06); }
.moon-rim { fill: none; stroke: var(--gold-soft); stroke-width: 1.1; opacity: .32; filter: drop-shadow(0 0 12px rgba(217,171,82,.5)); }
[data-theme="light"] .moon-rim { stroke: var(--gold); opacity: .45; filter: drop-shadow(0 0 6px rgba(168,123,30,.3)); }
.moon-lit { fill: var(--gold-soft); filter: drop-shadow(0 0 26px rgba(217,171,82,.45)); }
[data-theme="light"] .moon-lit { fill: var(--gold); filter: drop-shadow(0 0 18px rgba(168,123,30,.35)); }
.moon-crater { fill: rgba(0,0,0,.10); }

.hero-inner { position: relative; z-index: 2; max-width: 1100px; }
.hero-eyebrow {
  display: flex; align-items: center; gap: .7rem;
  color: var(--mut); font-size: .95rem; letter-spacing: .14em; text-transform: uppercase;
  margin-bottom: 1.6rem;
}
.hero-date { display: flex; align-items: baseline; gap: 2.2rem; flex-wrap: wrap; }
.hero-day {
  font-family: var(--serif); font-weight: 300; line-height: .82;
  font-size: clamp(7rem, 20vw, 17rem); color: var(--ink);
  letter-spacing: -.04em;
}
.hero-day .ch { display: inline-block; }
.hero-monthwrap { display: flex; flex-direction: column; gap: .6rem; padding-bottom: .8rem; }
.hero-month {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(2.4rem, 5.4vw, 4.8rem); line-height: 1; color: var(--gold-soft);
}
[data-theme="light"] .hero-month { color: var(--gold); }
.hero-year { font-size: clamp(1rem, 1.6vw, 1.3rem); letter-spacing: .3em; text-transform: uppercase; color: var(--mut); }
.hero-year em { font-style: normal; color: var(--gold); }
.hero-ar {
  font-family: var(--ar); font-size: clamp(1.6rem, 3vw, 2.6rem); color: var(--mut);
  margin-top: 1.8rem;
}
.hero-next {
  display: inline-flex; align-items: center; gap: 1rem; margin-top: 2.4rem;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: .7rem 1.4rem .7rem .9rem;
  text-decoration: none; color: var(--ink); background: var(--card);
  transition: border-color .3s, transform .3s;
}
.hero-next:hover { border-color: var(--gold); transform: translateY(-2px); }
.hero-next .hn-moon { width: 34px; height: 34px; border-radius: 50%; background: var(--gold-dim); display: grid; place-items: center; color: var(--gold); font-size: 1rem; }
.hero-next .hn-label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); display: block; }
.hero-next .hn-name { font-weight: 600; font-size: 1rem; }
.hero-next .hn-count { margin-left: .6rem; font-family: var(--serif); font-style: italic; color: var(--gold-soft); font-size: 1rem; white-space: nowrap; }
[data-theme="light"] .hero-next .hn-count { color: var(--gold); }

.hero-scroll {
  position: absolute; bottom: 2.2rem; left: clamp(1.5rem, 6vw, 6rem);
  display: flex; align-items: center; gap: .8rem; color: var(--mut);
  font-size: .72rem; letter-spacing: .26em; text-transform: uppercase;
}
.hero-scroll i { width: 56px; height: 1px; background: var(--line-strong); position: relative; overflow: hidden; display: block; }
.hero-scroll i::after { content: ''; position: absolute; inset: 0; background: var(--gold); transform: translateX(-100%); animation: scrollline 2.6s infinite; }
@keyframes scrollline { 0% { transform: translateX(-100%);} 60% { transform: translateX(100%);} 100% { transform: translateX(100%);} }

/* ── section heads ── */
.sec-head { margin-bottom: 2.6rem; }
.sec-eyebrow { color: var(--gold); font-size: .8rem; letter-spacing: .3em; text-transform: uppercase; margin-bottom: .8rem; }
.sec-title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: 1.02; }
.sec-title em { font-style: italic; color: var(--gold-soft); }
[data-theme="light"] .sec-title em { color: var(--gold); }
.sec-sub { color: var(--mut); margin-top: .8rem; font-size: 1.02rem; }

/* ── months ── */
.dt-months { padding: 7rem clamp(1.5rem, 6vw, 6rem) 5rem; }
.months-ctl { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--card); }
.seg button {
  border: none; background: none; color: var(--mut); font-family: var(--sans); font-weight: 600;
  font-size: .85rem; padding: .42rem 1.2rem; border-radius: 999px; cursor: pointer; transition: all .25s;
}
.seg button.on { background: var(--gold); color: #17120a; }
.legend { display: flex; gap: .6rem; flex-wrap: wrap; }
.lg {
  display: inline-flex; align-items: center; gap: .5rem;
  border: 1px solid var(--line); background: var(--card); color: var(--mut);
  border-radius: 999px; padding: .4rem .95rem; font-family: var(--sans); font-size: .82rem;
  cursor: pointer; transition: all .25s; opacity: .55;
}
.lg.on { opacity: 1; color: var(--ink); border-color: var(--line-strong); }

.months-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem;
}
.month-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.4rem 1.4rem 1.2rem; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), border-color .35s, box-shadow .35s;
  opacity: 0; transform: translateY(34px);
}
.no-anim .month-card, .month-card.in { opacity: 1; transform: none; }
.month-card:hover { transform: translateY(-5px); border-color: var(--ring); box-shadow: var(--shadow); }
.month-card.is-current::before {
  content: ''; position: absolute; inset: 0; border-radius: 22px; pointer-events: none;
  border: 1px solid var(--gold); opacity: .55;
}
.mc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .25rem; }
.mc-num { font-family: var(--serif); font-style: italic; color: var(--mut); font-size: .9rem; }
.mc-name { font-family: var(--serif); font-size: 1.45rem; font-weight: 500; }
.mc-ar { font-family: var(--ar); color: var(--gold-soft); font-size: 1.15rem; }
[data-theme="light"] .mc-ar { color: var(--gold); }
.mc-ar.mc-ar-latin { font-family: var(--sans); font-size: .82rem; font-weight: 500; letter-spacing: .02em; }
.mc-span { color: var(--mut); font-size: .8rem; margin: .15rem 0 1rem; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mc-dow { text-align: center; font-size: .58rem; letter-spacing: .08em; color: var(--mut); padding-bottom: 3px; }
.mc-cell {
  aspect-ratio: 1; display: grid; place-items: center; font-size: .72rem; border-radius: 8px;
  color: var(--mut); position: relative; transition: background .2s;
}
.mc-cell span { position: relative; z-index: 1; }
.show-wh .mc-cell.is-wh { background: rgba(239,231,211,.10); color: var(--ink); }
[data-theme="light"] .show-wh .mc-cell.is-wh { background: rgba(92,81,50,.12); }
.show-mt .mc-cell.is-mt::after {
  content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--teal);
}
.show-ev .mc-cell.has-ev { background: var(--gold-dim); color: var(--gold-soft); font-weight: 700; }
[data-theme="light"] .show-ev .mc-cell.has-ev { color: var(--gold); }
.mc-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--gold); color: var(--ink); font-weight: 700; border-radius: 50%; }
.mc-foot { display: flex; gap: .9rem; margin-top: 1rem; font-size: .72rem; color: var(--mut); }
.mc-foot b { color: var(--gold-soft); font-weight: 600; }
[data-theme="light"] .mc-foot b { color: var(--gold); }

/* list view */
.months-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.ml-row {
  display: grid; grid-template-columns: 3rem 1.4fr 1fr 1.2fr .8fr; align-items: center; gap: 1rem;
  padding: 1.15rem .6rem; border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .25s, padding-left .25s;
}
.ml-row:hover { background: var(--gold-dim); padding-left: 1.1rem; }
.ml-num { font-family: var(--serif); font-style: italic; color: var(--mut); }
.ml-name { font-family: var(--serif); font-size: 1.3rem; }
.ml-ar { font-family: var(--ar); color: var(--gold-soft); text-align: right; }
[data-theme="light"] .ml-ar { color: var(--gold); }
.ml-span, .ml-days { color: var(--mut); font-size: .9rem; }
.ml-row.is-current .ml-name { color: var(--gold-soft); }
[data-theme="light"] .ml-row.is-current .ml-name { color: var(--gold); }

.dt-months .disclaimer { margin-top: 2rem; }

/* ── events: horizontal pinned scroll ── */
.dt-events { position: relative; overflow: hidden; }
.ev-track {
  display: flex; align-items: stretch; gap: 1.4rem;
  padding: 16vh clamp(1.5rem, 6vw, 6rem);
  width: max-content;
}
.ev-intro { width: 34vw; min-width: 380px; display: flex; flex-direction: column; justify-content: center; }
.ev-intro .sec-title { font-size: clamp(2.6rem, 4.6vw, 4.2rem); }
.ev-intro p.lead { color: var(--mut); margin-top: 1.2rem; max-width: 36ch; font-size: 1.05rem; line-height: 1.6; }
.ev-card {
  width: 340px; flex-shrink: 0; border-radius: 26px; padding: 1.8rem;
  background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  transition: border-color .3s, transform .3s;
}
.ev-card:hover { border-color: var(--ring); transform: translateY(-6px); }
.ev-card.past { opacity: .45; }
.ev-card.is-next { border-color: var(--gold); }
.ev-card.is-next::after {
  content: 'Up next'; position: absolute; top: 1.1rem; right: 1.1rem;
  font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
  background: var(--gold); color: #17120a; font-weight: 800; border-radius: 999px; padding: .3rem .7rem;
}
.ev-date { font-family: var(--serif); font-size: 2.6rem; line-height: 1; }
.ev-date small { font-family: var(--sans); display: block; font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mut); margin-top: .5rem; }
.ev-name { font-size: 1.35rem; font-weight: 700; margin-top: 1.4rem; }
.ev-ar { font-family: var(--ar); color: var(--gold-soft); font-size: 1.3rem; margin-top: .2rem; }
[data-theme="light"] .ev-ar { color: var(--gold); }
.ev-desc { color: var(--mut); font-size: .9rem; line-height: 1.6; margin-top: .9rem; flex: 1; }
.ev-foot { margin-top: 1.4rem; display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.ev-greg { color: var(--mut); }
.ev-count { font-family: var(--serif); font-style: italic; color: var(--gold-soft); }
[data-theme="light"] .ev-count { color: var(--gold); }
.ev-badge { position: absolute; top: 1.2rem; right: 1.2rem; font-size: 1.2rem; }

/* ── Moon Sighting button (desktop) ── */
.ev-moon {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1.2rem; align-self: flex-start;
  padding: .48rem 1.1rem; border-radius: 999px;
  border: 1px solid rgba(217, 171, 82, .4);
  color: var(--gold-soft);
  font-family: var(--sans); font-size: .75rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  text-decoration: none;
  background: var(--gold-dim);
  backdrop-filter: blur(4px);
  transition: background .25s, color .25s, border-color .25s, box-shadow .25s, transform .25s;
}
.ev-moon-ic { font-size: 1rem; line-height: 1; transition: transform .3s; }
.ev-moon:hover {
  background: var(--gold); color: #17120a; border-color: var(--gold);
  box-shadow: 0 8px 28px -10px rgba(217, 171, 82, .7);
  transform: translateY(-2px);
}
.ev-moon:hover .ev-moon-ic { transform: rotate(-20deg); }
[data-theme="light"] .ev-moon { color: var(--gold); }
[data-theme="light"] .ev-moon:hover { color: #17120a; }

/* ── sunnah ── */
.dt-sunnah { padding: 7rem clamp(1.5rem, 6vw, 6rem); }
.sunnah-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.2rem; }
.sn-card {
  grid-column: span 4; background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 1.9rem; transition: transform .35s, border-color .35s;
  opacity: 0; transform: translateY(34px);
}
.no-anim .sn-card, .sn-card.in { opacity: 1; transform: none; }
.sn-card:hover { transform: translateY(-5px); border-color: var(--ring); }
.sn-featured { grid-column: span 8; grid-row: span 2; display: flex; flex-direction: column; justify-content: flex-end; min-height: 380px; position: relative; overflow: hidden; }
.sn-card h3 { font-family: var(--serif); font-weight: 500; font-size: 1.5rem; margin-bottom: .6rem; }
.sn-featured h3 { font-size: 2.2rem; }
.sn-ar { font-family: var(--ar); color: var(--gold-soft); font-size: 1.5rem; margin-bottom: .8rem; }
[data-theme="light"] .sn-ar { color: var(--gold); }
.sn-card p { color: var(--mut); line-height: 1.65; font-size: .95rem; max-width: 52ch; }
.sn-tag { margin-top: 1.2rem; color: var(--gold-soft) !important; font-family: var(--serif); font-style: italic; }
[data-theme="light"] .sn-tag { color: var(--gold) !important; }
.sn-moons { position: absolute; top: 2rem; right: 2.4rem; display: flex; gap: 1.6rem; }
.sn-moons svg { width: 64px; height: 64px; overflow: visible; }

/* ── footer ── */
.dt-foot {
  border-top: 1px solid var(--line);
  padding: 2.4rem clamp(1.5rem, 6vw, 6rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  color: var(--mut); font-size: .9rem;
}
.dt-foot > div { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
.dt-foot strong { color: var(--gold-soft); }
[data-theme="light"] .dt-foot strong { color: var(--gold); }
.foot-note { font-size: .78rem; font-style: italic; }

/* ── month modal ── */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(3, 5, 10, .7); backdrop-filter: blur(6px);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .35s;
}
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.month-modal {
  position: fixed; z-index: 95; left: 50%; top: 50%;
  width: min(680px, calc(100vw - 2.5rem)); max-height: 88svh; overflow: auto;
  background: var(--card-solid); border: 1px solid var(--line-strong); border-radius: 28px;
  box-shadow: var(--shadow); padding: 1.8rem;
  transform: translate(-50%, -46%) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .4s cubic-bezier(.2,.8,.2,1), opacity .35s;
}
.month-modal.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.mm-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.mm-title { flex: 1; text-align: center; }
.mm-title h3 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; }
.mm-title p { color: var(--mut); font-size: .85rem; margin-top: .2rem; }
.mm-nav, .mm-close {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--ink); font-size: 1.2rem; cursor: pointer; transition: all .25s;
}
.mm-nav:hover, .mm-close:hover { border-color: var(--gold); color: var(--gold); }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.fg-dow { text-align: center; font-size: .68rem; letter-spacing: .1em; color: var(--mut); padding-bottom: 6px; }
.fg-cell {
  border-radius: 12px; border: 1px solid transparent; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  position: relative; transition: background .2s;
}
.fg-cell .h { font-weight: 600; font-size: .98rem; }
.fg-cell .g { font-size: .6rem; color: var(--mut); }
.fg-cell.is-wh { background: rgba(239,231,211,.08); }
[data-theme="light"] .fg-cell.is-wh { background: rgba(92,81,50,.10); }
.fg-cell.has-ev { background: var(--gold-dim); border-color: var(--ring); }
.fg-cell.is-today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.fg-cell .evdot { position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.mm-events { margin-top: 1.4rem; display: flex; flex-direction: column; gap: .6rem; }
.mm-ev {
  display: flex; align-items: center; gap: .9rem; border: 1px solid var(--line);
  border-radius: 14px; padding: .75rem 1rem; font-size: .9rem;
}
.mm-ev .num { font-family: var(--serif); font-size: 1.3rem; color: var(--gold-soft); min-width: 2rem; text-align: center; }
[data-theme="light"] .mm-ev .num { color: var(--gold); }
.mm-ev .nm { font-weight: 600; }
.mm-ev .gd { margin-left: auto; color: var(--mut); font-size: .8rem; }

/* reveal helper */
.reveal { opacity: 0; transform: translateY(30px); }
.no-anim .reveal, .reveal.in { opacity: 1; transform: none; }

/* mobile events: highlight next upcoming event */
.mb-ev.card { border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; display: flex; align-items: center; gap: .8rem; position: relative; }
.mb-ev.card .date { min-width: 3.2rem; }
.mb-ev.is-next { border-color: var(--gold); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.mb-ev.is-next::after {
  content: 'Up next'; position: absolute; top: 8px; right: 10px;
  font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
  background: var(--gold); color: #17120a; font-weight: 800; border-radius: 999px; padding: .26rem .6rem;
}

/* ════════════════════════════════════════════════════════════
   MOBILE — pocket app (totally different shell)
   ════════════════════════════════════════════════════════════ */
.mb { display: none; }

@media (max-width: 840px) {
  .dt { display: none; }
  .mb {
    display: flex; flex-direction: column; min-height: 100svh;
    padding: 0 1.1rem calc(86px + env(safe-area-inset-bottom));
    max-width: 560px; margin: 0 auto;
  }

  .mb-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem .2rem .9rem; position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .mb-top-actions { display: flex; align-items: center; gap: .6rem; }
  .mb-yearpill {
    display: flex; align-items: center; gap: .15rem; border: 1px solid var(--line);
    background: var(--card); border-radius: 999px; padding: .2rem .3rem;
  }
  .mb-yearpill button { background: none; border: none; color: var(--mut); font-size: 1.1rem; padding: .15rem .5rem; cursor: pointer; }
  .mb-yearpill span { font-weight: 700; font-size: .92rem; min-width: 3.4ch; text-align: center; }
  .mb-yearpill .mb-yr-reset { font-size: .82rem; padding: .15rem .45rem; margin-left: .1rem; border-left: 1px solid var(--line); color: var(--gold); }

  .mb-panel { display: none; flex-direction: column; gap: 1rem; padding-top: .4rem; }
  .mb-panel.on { display: flex; }

  .card {
    background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 1.2rem 1.3rem;
  }
  .card h3 { font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mut); font-weight: 600; margin-bottom: .8rem; }

  /* today hero */
  .mb-hero {
    border-radius: 30px; padding: 2.1rem 1.5rem 1.8rem; text-align: center; position: relative; overflow: hidden;
    background:
      radial-gradient(120% 90% at 50% 0%, var(--gold-dim), transparent 60%),
      var(--card);
    border: 1px solid var(--line);
  }
  .mb-hero-moonbox { display: flex; justify-content: center; margin-bottom: 1rem; }
  #mbMoon { width: 86px; height: 86px; }
  #mbMoon svg { width: 100%; height: 100%; overflow: visible; }
  .mb-hero-greg { color: var(--mut); font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; }
  .mb-hero-date { font-family: var(--serif); font-weight: 400; font-size: clamp(2.5rem, 11vw, 3.4rem); line-height: 1.05; margin-top: .5rem; }
  .mb-hero-date #mbDay { font-weight: 300; }
  .mb-hero-date #mbMonth { font-style: italic; color: var(--gold-soft); }
  [data-theme="light"] .mb-hero-date #mbMonth { color: var(--gold); }
  .mb-hero-ar { font-family: var(--ar); font-size: 1.5rem; color: var(--mut); margin-top: .5rem; }
  .mb-hero-year { letter-spacing: .3em; text-transform: uppercase; font-size: .8rem; color: var(--gold); margin-top: .6rem; }
  .mb-moonname { margin-top: 1rem; display: inline-block; font-size: .75rem; color: var(--mut); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .9rem; }

  /* next event card */
  .mb-next { display: flex; align-items: center; gap: 1rem; }
  .mb-next .mn-count {
    min-width: 64px; height: 64px; border-radius: 18px; background: var(--gold-dim);
    display: grid; place-items: center; text-align: center; color: var(--gold-soft);
  }
  [data-theme="light"] .mb-next .mn-count { color: var(--gold); }
  .mb-next .mn-count b { display: block; font-family: var(--serif); font-size: 1.5rem; line-height: 1; }
  .mb-next .mn-count i { font-style: normal; font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; }
  .mb-next .mn-label { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); }
  .mb-next .mn-name { font-weight: 700; font-size: 1.1rem; margin-top: .15rem; }
  .mb-next .mn-date { color: var(--mut); font-size: .82rem; margin-top: .15rem; }

  .mb-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
  .mb-chip {
    border: 1px solid var(--line); border-radius: 999px; padding: .45rem 1rem;
    font-size: .82rem; color: var(--mut); display: inline-flex; align-items: center; gap: .45rem;
  }
  .mb-chip.yes { border-color: var(--ring); color: var(--ink); background: var(--gold-dim); }

  .mb-dl-row { display: flex; gap: .7rem; }
  .mb-dl-row button {
    flex: 1; border: 1px solid var(--line-strong); background: none; color: var(--ink);
    font-family: var(--sans); font-weight: 600; font-size: .85rem;
    border-radius: 14px; padding: .8rem .4rem; cursor: pointer; transition: all .25s;
  }
  .mb-dl-row button:active { background: var(--gold-dim); }
  .mb .disclaimer { text-align: center; margin: 0 auto; padding-bottom: .6rem; }

  /* months panel */
  .mb-monthchips {
    display: flex; gap: .5rem; overflow-x: auto; padding: .2rem .1rem .6rem;
    scrollbar-width: none; position: sticky; top: 64px; z-index: 30;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px);
    width: 100%; min-width: 0; -webkit-overflow-scrolling: touch;
  }
  .mb-monthchips::-webkit-scrollbar { display: none; }
  .mb-mchip {
    flex-shrink: 0; border: 1px solid var(--line); background: var(--card); color: var(--mut);
    border-radius: 999px; padding: .5rem 1.05rem; font-family: var(--sans); font-weight: 600;
    font-size: .82rem; cursor: pointer; transition: all .25s;
  }
  .mb-mchip.on { background: var(--gold); border-color: var(--gold); color: #17120a; }
  .mb-monthview .card { padding: 1.3rem 1rem; }
  .mb-mv-head { text-align: center; margin-bottom: 1rem; }
  .mb-mv-head h2 { font-family: var(--serif); font-weight: 500; font-size: 1.6rem; }
  .mb-mv-head .ar { font-family: var(--ar); color: var(--gold-soft); font-size: 1.2rem; }
  [data-theme="light"] .mb-mv-head .ar { color: var(--gold); }
  .mb-mv-head .ar-latin { color: var(--gold-soft); font-size: .88rem; font-weight: 500; margin-top: .15rem; }
  [data-theme="light"] .mb-mv-head .ar-latin { color: var(--gold); }
  .mb-mv-head .span { color: var(--mut); font-size: .8rem; margin-top: .2rem; }

  /* mobile calendar-system toggle */
  .mb-monthtop { display: flex; justify-content: center; padding: .1rem 0 .2rem; }
  .mb-seg { display: flex; width: 100%; }
  .mb-seg button { flex: 1; text-align: center; }
  .mb-mv-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .mb-mv-grid .fg-cell { min-height: 48px; border-radius: 10px; }
  .mb-mv-grid .fg-cell .h { font-size: .9rem; }
  .mb-mv-grid .fg-cell .g { font-size: .55rem; }
  .mb-mv-events { margin-top: 1rem; display: flex; flex-direction: column; gap: .55rem; }

  /* events panel */
  .mb-h2 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; padding: .4rem .2rem .6rem; }
  .mb-h2 span { color: var(--gold-soft); font-style: italic; }
  [data-theme="light"] .mb-h2 span { color: var(--gold); }
  .mb-evlist { display: flex; flex-direction: column; gap: .8rem; }
  .mb-ev { display: flex; gap: 1rem; align-items: flex-start; }
  .mb-ev.past { opacity: .45; }
  .mb-ev .date {
    min-width: 60px; height: 60px; border-radius: 16px; background: var(--gold-dim);
    display: grid; place-items: center; text-align: center; color: var(--gold-soft);
  }
  [data-theme="light"] .mb-ev .date { color: var(--gold); }
  .mb-ev .date b { display: block; font-family: var(--serif); font-size: 1.4rem; line-height: 1; }
  .mb-ev .date i { font-style: normal; font-size: .55rem; letter-spacing: .06em; text-transform: uppercase; }
  .mb-ev .nm { font-weight: 700; font-size: 1rem; }
  .mb-ev .ar { font-family: var(--ar); color: var(--mut); font-size: .95rem; }
  .mb-ev .gd { color: var(--mut); font-size: .78rem; margin-top: .1rem; }
  .mb-ev-body { flex: 1; min-width: 0; }
  .mb-ev .cnt { margin-left: auto; font-family: var(--serif); font-style: italic; color: var(--gold-soft); font-size: .85rem; white-space: nowrap; }
  [data-theme="light"] .mb-ev .cnt { color: var(--gold); }
  .mb-ev-month-hdr {
    font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--mut); padding: .5rem 0 .2rem;
    display: flex; align-items: center; gap: .6rem;
  }
  .mb-ev-month-hdr::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }

  /* ── Moon Sighting button (mobile) ── */
  .mb-moon {
    display: inline-flex; align-items: center; gap: .3rem;
    margin-top: .55rem;
    padding: .3rem .75rem; border-radius: 999px;
    border: 1px solid rgba(217, 171, 82, .38);
    color: var(--gold-soft);
    font-family: var(--sans); font-size: .68rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    text-decoration: none;
    background: var(--gold-dim);
    transition: background .2s, color .2s, border-color .2s;
  }
  .mb-moon:active, .mb-moon:focus-visible {
    background: var(--gold); color: #17120a; border-color: var(--gold);
  }
  [data-theme="light"] .mb-moon { color: var(--gold); }
  [data-theme="light"] .mb-moon:active { color: #17120a; }

  /* tab bar */
  .mb-tabbar {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(.9rem + env(safe-area-inset-bottom)); z-index: 50;
    display: flex; gap: .3rem; padding: .4rem;
    background: color-mix(in srgb, var(--card-solid) 88%, transparent);
    border: 1px solid var(--line-strong); border-radius: 999px;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
  }
  .mb-tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    background: none; border: none; color: var(--mut); font-family: var(--sans);
    font-size: .62rem; font-weight: 600; letter-spacing: .06em;
    border-radius: 999px; padding: .5rem 1.3rem; cursor: pointer; transition: all .3s;
  }
  .mb-tabbar button.on { background: var(--gold-dim); color: var(--gold-soft); }
  [data-theme="light"] .mb-tabbar button.on { color: var(--gold); }
}

/* tablet tune-up for desktop layout */
@media (min-width: 841px) and (max-width: 1100px) {
  .nav-links { display: none; }
  .hero-moon { opacity: .5; }
  .sn-featured { grid-column: span 12; }
  .sn-card { grid-column: span 6; }
}
@media (min-width: 841px) {
  .mb-tabbar { display: none; }
}

/* ───────────────────── print — single-A4 Gregorian calendar ───────────────────── */
.print-sheet { display: none; }
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  .ambient, .dt, .mb, .mb-tabbar, .month-modal, .modal-scrim, .settings, .settings-btn { display: none !important; }
  html, body { background: #fff !important; }
  .print-sheet {
    display: block; color: #1c1810; font-family: Georgia, 'Times New Roman', serif;
    width: 194mm;
  }
  .ps-head { text-align: center; margin-bottom: 2mm; }
  .ps-head h1 { font-size: 15pt; font-weight: 700; letter-spacing: .01em; }
  .ps-head p { font-size: 7pt; color: #666; margin-top: .6mm; }
  .ps-head .ps-leg { margin-top: 1.2mm; color: #444; }
  .ps-k { display: inline-block; width: 7.5pt; height: 7.5pt; border-radius: 2pt; vertical-align: -1pt; }
  .ps-k-ev { border: .8pt solid #c79121; background: rgba(199, 145, 33, .08); }
  .ps-k-wh { border: .8pt solid #d8b666; border-radius: 999px; background: transparent; }

  .ps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.2mm; }
  .ps-month { break-inside: avoid; border: .4pt solid #c9c2ad; border-radius: 2.2mm; padding: 1mm 1.4mm 1.2mm; }
  .ps-month h2 {
    font-size: 8.6pt; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline;
    border-bottom: .4pt solid #ddd6c2; padding-bottom: .5mm; margin-bottom: .7mm;
  }
  .ps-month h2 span { font-weight: 400; color: #9a7016; font-size: 6.2pt; }
  .ps-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4mm; }
  .psd {
    aspect-ratio: 1 / .62; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: .8mm; line-height: 1;
  }
  .psd b { font-size: 6.6pt; font-weight: 600; }
  .psd i { font-size: 4.1pt; font-style: normal; color: #9a917b; margin-top: .1mm; }
  .psd-h { color: #b3a98c; font-size: 5pt; font-weight: 700; aspect-ratio: auto; }
  .psd-x { visibility: hidden; }
  .psd-wh {
    border: .8pt solid #d8b666;
    border-radius: 999px;
    background: transparent;
  }
  .psd-wh i { color: #8a7c52; }
  .psd-ev {
    border: .8pt solid #c79121;
    background: rgba(199, 145, 33, .08);
    color: #8f6717;
  }
  .psd-ev b { font-weight: 700; }
  .psd-ev i { color: #8f6717; }
  .psd-ev.psd-wh { border-radius: 999px; }
  .psd-today { border: 1.2pt solid #c79121; border-radius: 50%; }

  .ps-key { break-inside: avoid; margin-top: 2.2mm; border-top: .5pt solid #ddd6c2; padding-top: 1.4mm; }
  .ps-key h3 { font-size: 8.4pt; font-weight: 700; margin-bottom: 1mm; }
  .ps-key ul { columns: 4; column-gap: 4mm; font-size: 6.5pt; list-style: none; line-height: 1.35; }
  .ps-key li { break-inside: avoid; }
  .ps-key b { color: #9a7016; font-weight: 700; margin-right: .8mm; }
  .ps-foot { text-align: center; font-size: 6.4pt; color: #999; margin-top: 2mm; }
}

/* ───────────────────── reduced motion ───────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
