/* Savage Soul — Lunar Calendar
   The calendar is one locked composition: every size inside the frame is a % of the frame width (cqw),
   so the balance of the printed calendar is kept exactly at any screen size. Phi scale for ratios. */
@font-face { font-family: "Cinzel"; src: url("fonts/Cinzel.ttf") format("truetype"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "CinzelDeco"; src: url("fonts/CinzelDecorative-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bebas"; src: url("fonts/BebasNeue-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mont"; src: url("fonts/Montserrat-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  --navy: #060c1e; --navy-2: #0b1430;
  --ink: #e8ecf5; --muted: #9aa5c4;
  --gold: #d8b45a; --gold-deep: #8d6b22; --gold-light: #f6e3a1;
  --gold-grad: linear-gradient(135deg, #f6e3a1 0%, #d8b45a 22%, #8d6b22 48%, #e9cf7a 70%, #a98433 100%);
  --s1: 5px; --s2: 8px; --s3: 13px; --s4: 21px; --s5: 34px; --s6: 55px; --s7: 89px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--navy); color: var(--ink); font-family: "Mont", system-ui, sans-serif; }
body { background: radial-gradient(ellipse at 50% 0%, #152048 0%, var(--navy-2) 38%, var(--navy) 100%) fixed; overflow-x: hidden; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + var(--s3)) var(--s2) calc(env(safe-area-inset-bottom) + var(--s3)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* the shell is the measuring container; the frame scales inside it */
.shell { position: relative; z-index: 1; width: 100%; max-width: min(640px, calc(100dvh * 0.7)); container-type: inline-size; }

/* ---------- art-deco gold frame ---------- */
.frame {
  position: relative; width: 100%;
  padding: 4.6cqw 4.6cqw 3.6cqw;
  display: flex; flex-direction: column;
  border: 1.5px solid transparent; border-image: var(--gold-grad) 1;
  box-shadow: 0 0 0 1px rgba(216,180,90,.12), 0 0 40px rgba(0,0,0,.6) inset, 0 0 34px rgba(216,180,90,.08);
  overflow: hidden;
}
.frame::before { content: ""; position: absolute; inset: 5px; pointer-events: none; border: 1px solid transparent; border-image: var(--gold-grad) 1; opacity: .55; }
.frame::after {
  content: ""; position: absolute; inset: 11px; pointer-events: none;
  background:
    linear-gradient(var(--gold), var(--gold)) 0 0 / 2.4cqw 1px no-repeat, linear-gradient(var(--gold), var(--gold)) 0 0 / 1px 2.4cqw no-repeat,
    linear-gradient(var(--gold), var(--gold)) 100% 0 / 2.4cqw 1px no-repeat, linear-gradient(var(--gold), var(--gold)) 100% 0 / 1px 2.4cqw no-repeat,
    linear-gradient(var(--gold), var(--gold)) 0 100% / 2.4cqw 1px no-repeat, linear-gradient(var(--gold), var(--gold)) 0 100% / 1px 2.4cqw no-repeat,
    linear-gradient(var(--gold), var(--gold)) 100% 100% / 2.4cqw 1px no-repeat, linear-gradient(var(--gold), var(--gold)) 100% 100% / 1px 2.4cqw no-repeat;
}

/* ---------- header: emblem | wordmark, as in the printed calendar ---------- */
.hdr { display: flex; align-items: center; gap: 4.2cqw; height: 15.4cqw; margin-top: .4cqw; }
.emblem-wrap { position: relative; flex: 0 0 auto; width: 15.4cqw; height: 15.4cqw; }
.owner { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: .9cqw; white-space: nowrap; font-family: "Cinzel"; font-weight: 700; font-size: 1.9cqw; letter-spacing: .34em; padding-left: .34em; color: var(--gold); text-shadow: 0 0 1.2cqw rgba(216,180,90,.35); }
.emblem { width: 15.4cqw; height: 15.4cqw; flex: 0 0 auto; filter: drop-shadow(0 0 1.6cqw rgba(150,170,230,.35)); }
.hdr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.6cqw; padding-right: 2cqw; }
.wordmark { width: 100%; max-width: 62cqw; display: block; }
.subline { display: flex; gap: 2cqw; font-family: "Cinzel"; font-weight: 600; color: var(--muted); letter-spacing: .28em; font-size: 2.05cqw; padding-left: .4cqw; }
.subline .dot { color: var(--gold); }
.rule.after-hdr { margin-top: 4.2cqw; }
.rule { height: 1px; background: linear-gradient(90deg, rgba(90,100,140,.1), rgba(130,140,180,.9) 20%, rgba(130,140,180,.9) 80%, rgba(90,100,140,.1)); margin: 2.8cqw 0 2.4cqw; flex: 0 0 auto; }
.rule.thin { margin: 1.6cqw 0 1.4cqw; opacity: .7; }

/* ---------- month row ---------- */
.month-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 2cqw; height: 8.4cqw; }
.month-left { display: flex; align-items: baseline; gap: 1.6cqw; min-width: 0; }
.month-img { height: 7cqw; width: auto; max-width: 42cqw; object-fit: contain; object-position: left bottom; align-self: flex-end; }
.year { font-family: "Cinzel"; font-weight: 500; font-size: 3.2cqw; color: var(--muted); align-self: flex-end; padding-bottom: .6cqw; }
.nav { font-family: "Cinzel"; font-size: 3.6cqw; line-height: 1; color: var(--gold); width: 4.4cqw; height: 4.4cqw; display: grid; place-items: center; border: 1px solid rgba(216,180,90,.4); align-self: center; }
.nav:active { background: rgba(216,180,90,.15); }
.month-right { text-align: right; flex: 0 0 auto; padding-bottom: .2cqw; }
.fm-link { font-family: "Cinzel"; font-weight: 700; font-size: 1.5cqw; letter-spacing: .18em; color: var(--gold); opacity: .85; margin-top: .7cqw; }
.fm-name { font-family: "Cinzel"; font-weight: 700; color: var(--gold); letter-spacing: .14em; font-size: 2.3cqw; }
.fm-when { font-size: 1.75cqw; color: var(--muted); margin-top: .5cqw; letter-spacing: .02em; }

/* ---------- grid ---------- */
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1cqw; text-align: center; font-family: "Bebas"; font-size: 2.2cqw; letter-spacing: .14em; color: var(--muted); margin: 2.6cqw 0 1.6cqw; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: 14.6cqw; gap: 1cqw; width: 100%; }
.day {
  position: relative; min-width: 0; text-align: left;
  border: 1px solid rgba(110,122,170,.3); border-radius: .9cqw; background: rgba(12,20,48,.62);
  transition: transform .15s, border-color .2s;
}
.day:active { transform: scale(.95); }
.day.empty { border-color: transparent; background: transparent; pointer-events: none; }
.day .n { position: absolute; top: .9cqw; left: 1.2cqw; font-family: "Cinzel"; font-weight: 600; font-size: 2.6cqw; color: var(--ink); line-height: 1; }
.day img { position: absolute; left: 50%; top: 46%; width: 66%; transform: translate(-42%, -50%); }
.day.event img { top: 40%; width: 60%; }
.day .ev { position: absolute; left: 0; right: 0; bottom: 2.3cqw; font-family: "Bebas", "Arial Narrow", sans-serif; font-size: 1.5cqw; letter-spacing: .06em; color: var(--gold); text-align: center; line-height: 1; white-space: nowrap; overflow: hidden; }
.day .tm { position: absolute; left: 0; right: 0; bottom: .8cqw; font-size: 1.25cqw; color: var(--muted); text-align: center; line-height: 1; white-space: nowrap; overflow: hidden; }
.day.event { border-color: rgba(216,180,90,.45); background: linear-gradient(180deg, rgba(40,52,110,.75), rgba(28,38,86,.8)); }
.day.event .n { color: var(--gold-light); }
.day.today { box-shadow: 0 0 0 1.5px var(--gold), 0 0 1.6cqw rgba(216,180,90,.45); }
.day.today::after { content: "TODAY"; position: absolute; top: -1cqw; right: .8cqw; font-family: "Bebas"; font-size: 1.3cqw; letter-spacing: .1em; color: var(--navy); background: var(--gold); padding: .2cqw .6cqw; line-height: 1.2; }

/* ---------- legend + footer ---------- */
.legend { display: flex; justify-content: space-between; gap: .8cqw; align-items: center; min-height: 5cqw; padding: 0 .6cqw; }
.legend .li { display: flex; align-items: center; gap: .8cqw; min-width: 0; flex: 0 1 auto; }
.legend img { width: 3.2cqw; height: 3.2cqw; flex: 0 0 auto; }
.legend .lt { font-family: "Bebas"; font-size: 1.55cqw; letter-spacing: .08em; color: var(--gold); line-height: 1.1; }
.legend .ld { font-size: 1.15cqw; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 2cqw; margin-top: 1.4cqw; }
.today-btn { font-family: "Cinzel"; font-weight: 700; font-size: 1.6cqw; letter-spacing: .2em; color: var(--gold); padding: .9cqw 1.6cqw; border: 1px solid rgba(216,180,90,.5); flex: 0 0 auto; }
.foot-note { font-size: 1.35cqw; color: var(--muted); text-align: center; letter-spacing: .03em; flex: 1; }
.sig { font-family: "Cinzel"; font-weight: 500; color: #a0864a; letter-spacing: .3em; font-size: 1.9cqw; flex: 0 0 auto; }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; background: radial-gradient(ellipse at 50% 40%, #0f1a42 0%, #04081a 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.overlay[hidden] { display: none; }
.close { position: absolute; top: calc(env(safe-area-inset-top) + var(--s3)); right: var(--s3); width: var(--s5); height: var(--s5); font-size: 16px; color: var(--gold); border: 1px solid rgba(216,180,90,.4); z-index: 6; }
.ov-date { position: absolute; top: calc(env(safe-area-inset-top) + var(--s4)); left: 0; right: 0; text-align: center; font-family: "Cinzel"; font-weight: 600; font-size: 13px; letter-spacing: .22em; color: var(--muted); pointer-events: none; }
.wheel-stage { position: relative; width: min(92vw, 70vh, 560px); aspect-ratio: 1; }
.wheel { position: absolute; inset: 0; }
.wheel img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ring { transform: rotate(0deg); will-change: transform; filter: drop-shadow(0 0 24px rgba(0,0,0,.7)); }
.ring.spinning { transition: transform 2.4s cubic-bezier(.33, 1, .68, 1); }
.wheel-stage.pop .wheel { transition: filter .8s, opacity .8s; filter: blur(1.5px); opacity: .45; }
/* medallion is laid out at its final size (70% of the wheel) and scaled DOWN onto the top slot,
   so the browser rasterizes it sharp; the pop animates back to scale(1) */
.medal { position: absolute; left: 50%; top: 50%; width: 70%; opacity: 0; pointer-events: none; will-change: transform;
  transform: translate(-50%, -50%) translateY(-33.4cqw) scale(.2271); filter: drop-shadow(0 0 20px rgba(216,180,90,.45)); }
.wheel-stage { container-type: inline-size; }
.wheel-stage.pop .medal { opacity: 1; pointer-events: auto; cursor: pointer;
  transition: transform .8s cubic-bezier(.2, 1.2, .4, 1), opacity .2s; transform: translate(-50%, -50%) translateY(0) scale(1); }
.wheel-stage.pop .medal.breathe { animation: breathe 2.6s ease-in-out .9s infinite; }
@keyframes breathe { 0%,100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-50%,-50%) scale(1.03); } }
.hint { margin-top: var(--s4); padding: 0 var(--s4); font-family: "Cinzel"; font-weight: 600; font-size: 11px; letter-spacing: .22em; line-height: 1.618; color: var(--gold); opacity: .8; min-height: 1.2em; text-align: center; }

/* ---------- reading card ---------- */
.card { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + var(--s4)) var(--s3) var(--s4); background: radial-gradient(ellipse at 50% 30%, #0f1a42 0%, #04081a 70%); overflow-y: auto; animation: fadein .5s ease; }
.card[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; transform: translateY(13px); } to { opacity: 1; transform: none; } }
.card-rim { position: relative; width: min(100%, 440px); padding: var(--s6) var(--s4) var(--s4); text-align: center;
  border: 1.5px solid transparent; border-image: var(--gold-grad) 1; background: linear-gradient(180deg, rgba(14,22,54,.95), rgba(6,12,30,.98)); box-shadow: 0 0 40px rgba(0,0,0,.7); margin-top: var(--s6); }
.card-rim::before { content: ""; position: absolute; inset: 5px; border: 1px solid transparent; border-image: var(--gold-grad) 1; opacity: .5; pointer-events: none; }
.card-medal { position: absolute; top: -55px; left: 50%; transform: translateX(-50%); width: 110px; filter: drop-shadow(0 0 16px rgba(216,180,90,.4)); }
.card h2 { font-family: "CinzelDeco"; font-weight: 700; font-size: 26px; margin: var(--s3) 0 0; letter-spacing: .06em;
  background: linear-gradient(180deg, #f4f6fb 0%, #c9d0e0 45%, #8e97b0 55%, #e6eaf3 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.epithet { font-family: "Cinzel"; font-weight: 600; font-size: 11px; letter-spacing: .3em; color: var(--gold); margin-top: var(--s1); }
.card-moon { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin: var(--s4) 0; text-align: left; }
.card-moon img { width: 44px; height: 44px; }
.phase { font-family: "Cinzel"; font-weight: 700; font-size: 13px; letter-spacing: .12em; color: var(--ink); }
.phase-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.reading { font-size: 15.5px; line-height: 1.618; color: var(--ink); margin: 0 0 var(--s3); }
.closing { font-family: "Cinzel"; font-weight: 600; font-size: 13px; line-height: 1.618; letter-spacing: .04em; color: var(--gold-light); margin: 0; }
.card-sig { font-family: "Cinzel"; font-weight: 500; color: #a0864a; letter-spacing: .3em; font-size: 11px; margin-top: var(--s4); }
.back { margin-top: var(--s4); font-family: "Cinzel"; font-weight: 700; font-size: 11px; letter-spacing: .22em; color: var(--gold); padding: var(--s3) var(--s4); border: 1px solid rgba(216,180,90,.5); }

}
@media (prefers-reduced-motion: reduce) {
  .ring.spinning { transition-duration: .4s; }
  .wheel-stage.pop .medal { transition-duration: .3s; }
  .wheel-stage.pop .medal.breathe { animation: none; }
}

/* ---------- personal section + month page ---------- */
.deco-rule { display: flex; align-items: center; gap: var(--s2); margin: var(--s4) 0 var(--s3); }
.deco-rule span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(216,180,90,.7)); }
.deco-rule span:last-child { background: linear-gradient(90deg, rgba(216,180,90,.7), transparent); }
.deco-rule i { font-style: normal; color: var(--gold); font-size: 12px; }
.p-head { font-family: "Cinzel"; font-weight: 700; font-size: 12px; letter-spacing: .32em; color: var(--ink); display: flex; justify-content: center; align-items: baseline; gap: var(--s3); }
.p-sig { font-weight: 500; color: #a0864a; font-size: 11px; letter-spacing: .3em; }
.p-title { font-family: "Cinzel"; font-weight: 600; font-size: 10.5px; letter-spacing: .26em; color: var(--gold); margin: var(--s2) 0 var(--s3); }
.reading.small { font-size: 14px; line-height: 1.618; text-align: left; }
.checklist { list-style: none; margin: var(--s3) 0 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: var(--s2); }
.checklist li { display: grid; grid-template-columns: 22px 1fr; gap: var(--s3); align-items: start; padding: var(--s3) var(--s3); border: 1px solid rgba(216,180,90,.28); background: rgba(10,18,44,.55); cursor: pointer; transition: background .2s, border-color .2s; }
.checklist li:active { background: rgba(216,180,90,.1); }
.checklist .box { width: 20px; height: 20px; margin-top: 1px; border: 1.5px solid var(--gold); display: grid; place-items: center; font-size: 13px; color: var(--navy); background: transparent; transition: background .2s; }
.checklist .lab { display: block; font-family: "Bebas"; font-size: 13px; letter-spacing: .14em; color: var(--gold); line-height: 1; margin-bottom: 4px; }
.checklist .txt { display: block; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.checklist li.done { border-color: rgba(216,180,90,.6); background: rgba(216,180,90,.08); }
.checklist li.done .box { background: var(--gold); }
.checklist li.done .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(216,180,90,.6); }
.card-actions { display: flex; gap: var(--s2); margin-top: var(--s4); flex-wrap: wrap; justify-content: center; }
.card-actions .back { margin-top: 0; }
.back.ghost { color: var(--gold-light); border-color: rgba(216,180,90,.3); }
.month-card .card-medal { width: 96px; top: -48px; }
.month-card h2 { margin-top: var(--s2); }
.month-card .reading.small { margin-top: var(--s3); }
.m-blocks { display: flex; flex-direction: column; gap: var(--s2); text-align: left; }
.m-block { padding: var(--s3); border: 1px solid rgba(216,180,90,.28); background: rgba(10,18,44,.55); }
.m-label { font-family: "Bebas"; font-size: 13px; letter-spacing: .16em; color: var(--gold); margin-bottom: 4px; }
.m-block p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.card { justify-content: flex-start; }

/* ---------- ambient sound toggle ---------- */
.snd { position: absolute; top: 2.6cqw; right: 2.6cqw; z-index: 3; width: 5.2cqw; height: 5.2cqw; font-size: 3.2cqw; line-height: 1; color: rgba(216,180,90,.45); border: 1px solid rgba(216,180,90,.3); display: grid; place-items: center; transition: color .3s, border-color .3s, box-shadow .3s; }
.snd.on { color: var(--gold); border-color: rgba(216,180,90,.7); box-shadow: 0 0 1.4cqw rgba(216,180,90,.35); }
.snd.on::after { content: ""; position: absolute; inset: -1px; border: 1px solid rgba(216,180,90,.5); animation: pulse 3.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0; transform: scale(1); } 50% { opacity: 1; transform: scale(1.18); } }

/* ---------- year ahead ---------- */
.p-note { font-size: 12px; color: var(--muted); margin: var(--s2) 0 0; }
.year-card .m-block p { white-space: pre-line; }
.checklist .num { font-family: "Cinzel"; font-weight: 700; font-size: 11px; letter-spacing: .14em; color: var(--gold); display: block; margin-bottom: 3px; }
.nye { font-family: "Cinzel"; font-weight: 700; font-size: 11px; letter-spacing: .3em; color: var(--gold); margin-top: var(--s2); }

/* ---------- tablet tier: iPad, iPad Air, iPad Pro 11/13 (portrait + landscape) ----------
   The calendar frame already scales with its width; here we let it use more of a tablet screen
   and scale the reading / month / year cards up in step (phi-based: 440 → 560 → 680). */
@media (min-width: 768px) {
  .shell { max-width: min(720px, calc(100dvh * 0.72)); }
  .card { padding-left: var(--s5); padding-right: var(--s5); }
  .card-rim { width: min(100%, 560px); padding: var(--s7) var(--s5) var(--s5); }
  .card-medal { width: 132px; top: -66px; }
  .month-card .card-medal { width: 116px; top: -58px; }
  .card h2 { font-size: 31px; }
  .epithet { font-size: 12.5px; }
  .card-moon img { width: 52px; height: 52px; }
  .phase { font-size: 15px; } .phase-sub { font-size: 12.5px; }
  .reading { font-size: 17.5px; }
  .reading.small { font-size: 16px; }
  .closing { font-size: 15px; }
  .p-head { font-size: 13.5px; } .p-title { font-size: 12px; } .p-note { font-size: 13.5px; }
  .checklist li { grid-template-columns: 24px 1fr; padding: var(--s3) var(--s4); }
  .checklist .box { width: 22px; height: 22px; }
  .checklist .lab, .m-label { font-size: 14.5px; }
  .checklist .txt, .m-block p { font-size: 15.5px; }
  .m-block { padding: var(--s3) var(--s4); }
  .back { font-size: 12.5px; padding: var(--s3) var(--s5); }
  .hint { font-size: 13px; }
  .ov-date { font-size: 15px; }
  .close { width: 44px; height: 44px; font-size: 18px; }
  .wheel-stage { width: min(86vw, 68vh, 640px); }
}
/* iPad Pro 13 portrait and large landscape */
@media (min-width: 1000px) {
  .shell { max-width: min(800px, calc(100dvh * 0.72)); }
  .card-rim { width: min(100%, 680px); }
  .card-medal { width: 150px; top: -75px; }
  .month-card .card-medal { width: 128px; top: -64px; }
  .card h2 { font-size: 36px; }
  .reading { font-size: 19px; }
  .reading.small { font-size: 17px; }
  .checklist .txt, .m-block p { font-size: 16.5px; }
  .wheel-stage { width: min(80vw, 70vh, 720px); }
}
/* landscape tablets: keep the whole frame on screen without scrolling */
@media (min-width: 768px) and (orientation: landscape) {
  .shell { max-width: min(800px, calc(100dvh * 0.68)); }
}
