/* Stellara: Atlante (chiaro) e Notturno (scuro), come l'app. */

@font-face { font-family: "Newsreader"; font-weight: 300; src: url("/assets/fonts/Newsreader-Light.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Newsreader"; font-weight: 400; src: url("/assets/fonts/Newsreader-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Newsreader"; font-weight: 500; src: url("/assets/fonts/Newsreader-Medium.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; src: url("/assets/fonts/Newsreader-Italic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; font-weight: 400; src: url("/assets/fonts/InstrumentSans-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; font-weight: 500; src: url("/assets/fonts/InstrumentSans-Medium.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; font-weight: 600; src: url("/assets/fonts/InstrumentSans-SemiBold.woff2") format("woff2"); font-display: swap; }

:root {
  --ground: #EEF1F4;      /* carta */
  --raised: #F7F8FA;
  --sunk: #E2E7ED;
  --ink: #1E2B47;         /* inchiostro */
  --muted: #5B6475;       /* grafite */
  --rule: #CBD2DC;
  --star: #A8823A;        /* oro antico */
  --action: #1E2B47;
  --on-action: #F7F8FA;
  --moon-lit: #F7F8FA;
  --moon-dark: #1E2B47;
  --moon-edge: #1E2B47;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #1A2142;    /* notte */
    --raised: #222A50;
    --sunk: #141A35;
    --ink: #EDE6D6;       /* luna */
    --muted: #AEB5CC;     /* argento */
    --rule: #2C3560;
    --star: #E6D29A;      /* lampada */
    --action: #E6D29A;
    --on-action: #141A35;
    --moon-lit: #EDE6D6;
    --moon-dark: #2A3157;
    --moon-edge: rgba(174, 181, 204, .45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--star); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.column { max-width: 680px; }

/* Testata */
.masthead { display: flex; align-items: center; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.wordmark { font: 400 26px/1 var(--serif); text-decoration: none; letter-spacing: -.01em; }
.nav { display: flex; gap: 22px; margin-left: auto; font-size: 15px; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--ink); }
.nav .get { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
  .masthead { flex-wrap: wrap; gap: 10px 18px; }
  .nav { margin-left: 0; width: 100%; gap: 18px; overflow-x: auto; }
}

/* Tipografia */
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: clamp(40px, 7vw, 60px); font-weight: 300; line-height: 1.04; letter-spacing: -.02em; }
h2 { font-size: 28px; line-height: 1.15; }
h3 { font-size: 21px; font-weight: 500; line-height: 1.25; }
.reading { font: 400 19px/1.65 var(--serif); }
.reading p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.figure { font-family: var(--sans); font-variant-numeric: tabular-nums; }

/* Disegni */
.constellation { display: block; width: 100%; height: auto; }
.constellation .lines polyline { fill: none; stroke: var(--ink); stroke-opacity: .6; stroke-width: .9; stroke-linecap: round; stroke-linejoin: round; }
.constellation .stars circle { fill: var(--ink); }
.constellation .stars .halo { fill: var(--star); fill-opacity: .35; }
.constellation .faint circle { fill: var(--ink); fill-opacity: .35; }
.constellation text { font: italic 11px var(--serif); fill: var(--muted); }
.moon { flex: none; vertical-align: middle; }
.moon .dark { fill: var(--moon-dark); }
.moon .lit { fill: var(--moon-lit); }
.moon .edge { fill: none; stroke: var(--moon-edge); stroke-width: 1; }
.mark path { fill: var(--star); }

/* Apertura */
.opening { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: end; padding: 40px 0 28px; }
.opening .plate { max-width: 460px; justify-self: end; width: 100%; }
.dateline { font: 400 16px var(--serif); color: var(--muted); margin-bottom: 18px; }
.skyline { display: flex; gap: 10px; align-items: center; margin-top: 14px; color: var(--muted); }
@media (max-width: 760px) {
  .opening { grid-template-columns: 1fr; padding-top: 16px; }
  .opening .plate { order: -1; justify-self: end; max-width: 300px; }
}

/* Selettore oggi / settimana / mese */
.segments { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; margin: 8px 0 28px; }
.segments a { padding: 9px 20px; text-decoration: none; font-weight: 600; font-size: 14px; }
.segments a + a { border-left: 1px solid var(--rule); }
.segments a[aria-current="page"] { background: var(--action); color: var(--on-action); }

/* Punteggi */
.scores { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); margin: 6px 0 0; }
.scores b { color: var(--ink); font-weight: 600; }

/* Blocchi */
.section { padding: 36px 0 8px; }
.section > h2 { margin-bottom: 14px; }
.personal { border-left: 2px solid var(--star); padding: 2px 0 2px 20px; margin: 40px 0 8px; }
.personal h2 { margin-bottom: 8px; }
.button { display: inline-flex; align-items: center; gap: 10px; background: var(--action); color: var(--on-action); text-decoration: none; font-weight: 600; padding: 13px 24px; border-radius: 999px; }
.button.quiet { background: none; color: var(--ink); border: 1px solid var(--rule); }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* Righe di indice */
.rows { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.rows li { border-bottom: 1px solid var(--rule); }
.rows a { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 0; text-decoration: none; }
.rows .name { font: 400 21px/1.2 var(--serif); }
.rows .sub { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.rows .chev { color: var(--muted); }
.rows .lead { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.signs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
.signs-grid .rows { border-top: none; }
.signs-grid li:first-child, .signs-grid li:nth-child(2) { border-top: 1px solid var(--rule); }
@media (max-width: 760px) { .signs-grid { grid-template-columns: 1fr; } .signs-grid li:nth-child(2) { border-top: none; } }

/* Elenco con date */
.dated { list-style: none; padding: 0; margin: 0; }
.dated li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.dated .when { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Piede */
.footer { margin-top: 64px; padding: 28px 0 48px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 12px 24px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer p { margin: 0; flex-basis: 100%; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dated .when .mark { vertical-align: middle; }
.nav a { white-space: nowrap; }
.marked { list-style: none; padding: 0; margin: 0; }
.marked li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--rule); }

/* Calendario */
.calhead { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; justify-content: space-between; }
.monthnav { display: flex; gap: 18px; font-size: 15px; }
.monthnav a { text-decoration: none; color: var(--muted); }
.monthnav a:hover { color: var(--ink); }
.calendar-wrap { overflow-x: auto; }
.calendar { width: 100%; max-width: 760px; border-collapse: collapse; table-layout: fixed; }
.calendar th { font: 500 12px var(--sans); color: var(--muted); padding: 8px 0; text-align: center; }
.calendar td { text-align: center; padding: 10px 0 12px; border-top: 1px solid var(--rule); position: relative; height: 64px; vertical-align: top; }
.calendar td .d { display: block; font-size: 14px; margin-bottom: 6px; }
.calendar td.today .d { font-weight: 600; text-decoration: underline; text-decoration-color: var(--star); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.calendar .dot { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--star); margin: 6px auto 0; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.events .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .what b { font-weight: 600; }
.events .what .moon { margin-right: 4px; vertical-align: -2px; }
.reading-s { display: block; font: 400 17px/1.55 var(--serif); margin-top: 4px; }

/* Tarocchi */
.cardlist { list-style: none; padding: 0; margin: 0; columns: 3 200px; column-gap: 32px; }
.cardlist li { break-inside: avoid; border-bottom: 1px solid var(--rule); }
.cardlist a { display: block; padding: 9px 0; text-decoration: none; font: 400 18px var(--serif); }
.cardlist a:hover { color: var(--star); }
.card-opening { grid-template-columns: minmax(0, 1fr) 220px; }
.cardplate img, .cardback { display: block; width: 200px; height: 320px; object-fit: cover; border: 1px solid var(--rule); padding: 4px; background: var(--raised); }
.cardback { background: var(--ink); display: grid; place-items: center; border: 6px solid var(--ink); outline: 1px solid var(--star); outline-offset: -12px; }
@media (prefers-color-scheme: dark) { .cardback { background: var(--sunk); border-color: var(--sunk); } }
@media (max-width: 760px) { .card-opening { grid-template-columns: 1fr; } .card-opening .cardplate { order: -1; } .cardplate img, .cardback { width: 150px; height: 240px; } }
.pager { display: flex; justify-content: space-between; gap: 16px; padding: 24px 0 0; font: 400 18px var(--serif); }
.pager a { text-decoration: none; }

/* App */
.features { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.features li { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.features b { display: block; font: 500 20px var(--serif); margin-bottom: 2px; }
.features span { color: var(--muted); }
.button.quiet[aria-disabled] { color: var(--muted); cursor: default; }

/* Documenti */
.doc .reading { font-size: 17px; }
.doc h2 { font-size: 24px; margin: 1.6em 0 .5em; }
.doc .note { color: var(--muted); border-left: 2px solid var(--star); padding-left: 14px; }
.doc ul { padding-left: 1.2em; }
.table { overflow-x: auto; margin: 0 0 1em; }
.table table { border-collapse: collapse; font: 400 15px/1.45 var(--sans); min-width: 560px; }
.table th, .table td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
.table th { font-weight: 600; }
.lede { font-size: 21px; }
.doc h1 { margin-bottom: 24px; }

/* --- Impaginazione centrata --- */
main > section, main > div { max-width: 960px; margin-left: auto; margin-right: auto; }
.column { max-width: 700px; margin-left: auto !important; margin-right: auto !important; }

/* Apertura: la tavola in alto, poi titolo e riga del cielo, tutto in asse */
.opening, .card-opening { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0; padding: 36px 0 24px; max-width: 700px; }
.opening .plate { order: -1; justify-self: auto; width: 100%; max-width: 520px; margin-bottom: 4px; }
.opening .dateline { margin-bottom: 10px; }
.opening .skyline { justify-content: center; }
.opening .reading { margin-left: auto; margin-right: auto; max-width: 560px; }
.opening .buttons { justify-content: center; }
.card-opening .cardplate { order: -1; margin-bottom: 24px; }
.card-opening .cardplate img, .card-opening .cardback { width: 180px; height: 288px; }

/* Selettore e titoli di sezione in asse con il testo */
.column > .segments { display: flex; width: fit-content; margin: 4px auto 32px; }
.section > h2 { margin-bottom: 16px; }
main > section.section > h2, main > section.section > p.muted { text-align: center; }
main > section.section > p.muted { max-width: 560px; margin-left: auto !important; margin-right: auto !important; }

/* Pagina del calendario */
.calhead { justify-content: center; text-align: center; flex-direction: column; align-items: center; }
main > section.section:first-child > .dateline { text-align: center; }
.calendar { margin: 0 auto; }
.calendar-wrap { max-width: 760px; }

/* Tarocchi: liste in asse */
.cardlist { max-width: 860px; margin: 0 auto; }

/* Piede */
.footer { justify-content: center; text-align: center; }
.footer nav { justify-content: center; width: 100%; }
.footer p { max-width: 640px; margin: 0 auto; }

/* Tavole delle costellazioni */
.center-head { text-align: center; }
.center-head .reading { text-align: left; }
.plates { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 24px; }
.plates a { display: block; text-align: center; text-decoration: none; padding: 8px 0 14px; border-top: 1px solid var(--rule); }
.plates a:hover .name { color: var(--star); }
.plates .name { display: block; font: 400 21px/1.2 var(--serif); margin-top: 2px; }
.plates .sub { display: block; font: italic 15px var(--serif); color: var(--muted); }
.small-plates { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.small-plates .name { font-size: 18px; }
.plates { display: flex; flex-wrap: wrap; justify-content: center; }
.plates li { width: 200px; }
.small-plates li { width: 150px; }
@media (max-width: 640px) {
  .nav { flex-wrap: wrap; gap: 6px 16px; font-size: 14px; overflow: visible; }
  .plates li { width: calc(50% - 12px); }
}
@media (max-width: 640px) { .nav { gap: 6px 11px; font-size: 13.5px; } }
@media (max-width: 360px) { .nav { flex-wrap: wrap; } }
