/* Moon Phase Calendar — art direction per PRD §6: PlanetScale, inverted.
   High contrast, minimal black/white palette, visible borders, zero
   border-radius anywhere. Self-contained: no Bootstrap/jQuery dependency —
   the main site's light/rounded look is a different, deliberate choice for
   a different section; this one needs the opposite. */

:root {
    --bg: #1c1d21;          /* page background — dark grey, distinct from the calendar */
    --surface: #000000;     /* calendar / card background — pure black */
    --fg: #ffffff;          /* primary text */
    --muted: #cfd2d8;       /* secondary text — kept bright per feedback #5 */
    --dim: #9aa0a8;         /* decorative-only text, never a border or a status line */
    --line: #6d7178;        /* default border — kept bright per feedback #5/#6 */
    --line-strong: #aeb3bb; /* emphasized border */
    --accent: #e8c877;      /* gold accent — links, today highlight */
    --accent-dim: #6b5a33;
    --moon-dark: #08080a;
    --moon-light: #f2ede0;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button, input, select, a, div, td, th, table, section, nav, header, footer, li {
    border-radius: 0;
}

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
    position: absolute; top: 0; left: -9999px; z-index: 100;
    background: var(--fg); color: var(--bg); padding: 8px 14px; font-weight: 700;
}
.skip:focus { left: 0; }

/* Cross-site tab switcher — PRD §5.1a */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs a {
    display: block; padding: 9px 16px; font-size: 13px; font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
    border-right: 1px solid var(--line);
}
.tabs a[aria-current="page"] { background: var(--fg); color: var(--bg); }
.tab-ico { margin-right: 7px; }
.tabs a:hover:not([aria-current]) { color: var(--fg); }

/* Top bar — non-sticky, per PRD §5.1 */
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.brand { font-size: clamp(15px, 2.4vw, 19px); font-weight: 800; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
    display: inline-block; min-height: 40px; padding: 8px 14px;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    background: transparent; color: var(--fg); border: 1px solid var(--line-strong);
}
.btn:hover { border-color: var(--fg); color: var(--accent); }
.btn-accent { border-color: var(--accent-dim); color: var(--accent); }
.btn[aria-pressed="true"], .btn.is-selected { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Language switcher — one row of buttons, no dropdown */
.lang-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-buttons a[aria-current="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Month/year nav — PRD §5.1. Year select, the 12-month row, and prev/next
   arrows all share one line on desktop. */
.month-nav { padding: 14px 0; }
.month-nav .nav-line { display: flex; align-items: center; gap: 10px; }
.nav-arrow {
    flex: 0 0 auto; min-width: 40px; padding: 8px 0; text-align: center;
    font-size: 16px; line-height: 1;
}
.nav-arrow[aria-disabled="true"] { color: #4a4d54; border-color: #333438; pointer-events: none; }
select.ctl {
    appearance: none; -webkit-appearance: none;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23cfd2d8'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--fg); border: 1px solid var(--line-strong); font: inherit; font-size: 14px;
    padding: 9px 32px 9px 12px; min-height: 40px;
}
.month-nav .nav-line select.ctl { flex: 0 0 auto; width: auto; }
.month-row { flex: 1; display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.month-row.year-row { grid-template-columns: repeat(10, 1fr); }   /* list view: a decade's 10 years */
.month-row a, .month-row span {
    text-align: center; padding: 8px 2px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--line); color: var(--muted);
}
.month-row a:hover { border-color: var(--fg); color: var(--fg); }
.month-row a[aria-current="page"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.month-row span[aria-disabled="true"] { color: #4a4d54; border-color: #333438; }

.mobile-nav { display: none; gap: 8px; align-items: center; }
.mobile-nav select { flex: 1; }
.mobile-nav .nav-arrow { min-width: 34px; }

@media (max-width: 720px) {
    .month-row { display: none; }
    .month-nav .nav-line > select.ctl { display: none; }
    .month-nav .nav-line > .nav-arrow { display: none; }
    .mobile-nav { display: flex; }
    /* PRD §5.2: the full month must fit above the fold on common mobile
       viewports, so chrome above the grid is compacted here rather than
       left at desktop spacing. */
    .topbar { padding: 8px 0; gap: 8px; }
    .topbar-right { gap: 6px; }
    .topbar { padding: 6px 0; }
    .topbar .btn { min-height: 32px; padding: 5px 9px; font-size: 12px; }
    h1 { margin: 4px 0; line-height: 1.15; }
    .month-nav { padding: 4px 0; }
    .mobile-nav select.ctl { min-height: 32px; padding: 5px 24px 5px 9px; font-size: 13px; }
    .mobile-nav .nav-arrow { min-height: 32px; padding: 5px 0; }
}

/* Calendar grid — PRD §5.2. Narrower than the page width and each cell
   taller than wide, so the moon reads as a big inset photo rather than a
   small square icon. */
.calendar { background: var(--surface); border: 1px solid var(--line-strong); max-width: 1100px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.grid > .dow {
    text-align: center; padding: 8px 2px; font-size: 12px; font-weight: 700;
    color: var(--muted); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
}
.grid > .dow:last-child { border-right: none; }

.cell {
    /* Fixed height (not aspect-ratio) so widening the column for one-line
       labels doesn't also grow the cell taller -- the moon is sized off
       this height (see .cell .moon below), so it stays a constant size
       independent of the column's width. */
    position: relative; height: 129px;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.grid > .cell:nth-child(7n) { border-right: none; }
.cell.is-outside { opacity: .3; display: flex; align-items: flex-start; justify-content: flex-start; padding: 6px; }
.cell.is-today { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }

/* The moon itself stays a true circle (not stretched) and fills ~70% of
   the cell's height, inset near the top with dark space visible around
   it -- the label lives below it, not overlaid on top. */
.cell .moon {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    height: 68%; width: auto; aspect-ratio: 1 / 1; display: block;
}

.cell .daynum {
    position: absolute; top: 4px; left: 6px; z-index: 2;
    font-size: 13px; font-weight: 700; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.85), 0 0 6px rgba(0,0,0,.6);
}
.cell.is-outside .daynum { position: static; color: var(--dim); text-shadow: none; }

.cell .label {
    position: absolute; left: 2px; right: 2px; bottom: 4px;
    text-align: center; font-size: 12px; font-weight: 600; line-height: 1.15;
    color: var(--muted);
}

@media (max-width: 480px) {
    /* Keep both tabs (icon + label) on one line on a phone. */
    .tabs a { padding: 9px 10px; font-size: 11px; letter-spacing: .02em; }
    .tab-ico { margin-right: 5px; }
    .cell { height: 66px; }
    .cell .moon { top: 2px; }
    .cell .daynum { top: 3px; left: 5px; font-size: 11px; }
    .cell .label { font-size: 9px; bottom: 3px; }
    .grid > .dow { padding: 4px 2px; font-size: 10px; }
}

/* Two months at every width. Every page is "the left month" (its URL); the
   second card is always the month after it. Side by side from 1200px up,
   stacked in a single column below that. */
.months { display: grid; gap: 22px; margin-top: 6px; }
.cal-card { width: 100%; max-width: 1100px; margin: 0 auto; }
.cal-title { margin: 0 0 8px; font-size: 18px; }
.cal-title::first-letter { text-transform: uppercase; }

@media (max-width: 720px) {
    .months { gap: 16px; }
    .cal-title { margin-bottom: 6px; font-size: 16px; }
}

@media (min-width: 1200px) {
    .wrap { max-width: 1600px; }
    .months { grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
    .cal-card { max-width: none; margin: 0; }
    .cal-card .calendar { max-width: none; margin: 0; container-type: inline-size; }
    /* Columns are narrower with two grids side by side, so the moon and the
       label scale with the calendar's own width (cqw), capped at the sizes
       used when a single grid has the full width. */
    .cell .moon { height: min(68%, 12cqw); }
    .cell .label { font-size: clamp(10px, 1.55cqw, 12px); }
}

/* Heading row: "Today" and the thumbnail/list view switch sit right-aligned on it. */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title-row h1 { flex: 1 1 auto; min-width: 0; }
.title-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 8px; }
.title-actions .btn { min-height: 38px; padding: 0 14px; display: flex; align-items: center; white-space: nowrap; }
@media (max-width: 720px) {
    /* The heading gets its own line; "Today" and the view switch sit under it, right-aligned. */
    .title-row { flex-wrap: wrap; row-gap: 6px; }
    .title-row h1 { flex-basis: 100%; }
    .title-actions { margin-left: auto; }
}
.view-toggle { display: flex; flex: 0 0 auto; border: 1px solid var(--line-strong); }
.vt-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 36px; color: var(--muted); }
.vt-btn + .vt-btn { border-left: 1px solid var(--line-strong); }
.vt-btn svg { width: 18px; height: 18px; fill: currentColor; }
.vt-btn:hover { color: var(--accent); }
.vt-btn[aria-current="true"], .vt-btn[aria-current="true"]:hover { background: var(--fg); color: var(--bg); }

/* List view: one row per month, one tiny moon per day, no phase text. */
/* No outer border or panel background (it uses the page's own background):
   just a divider line between the months. */
.yv-row { display: grid; grid-template-columns: 112px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.yv-row:last-child { border-bottom: none; }
.yv-row[data-month] { padding: 11px 0; }
.yv-month { padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--fg); }
.yv-month::first-letter { text-transform: uppercase; }
.yv-days { display: grid; grid-template-columns: repeat(31, 1fr); }
.yv-d { display: block; padding: 4px 3px; }
.yv-d:hover { background: rgba(255, 255, 255, .08); }
.yv-d svg { display: block; width: 84%; height: auto; aspect-ratio: 1 / 1; margin: 0 auto; }
.yv-d circle { fill: #14151a; stroke: #3a3c44; stroke-width: .6; }
.yv-d path { fill: #e2dccb; }
.yv-d.is-today, .yv-d.is-today:hover { outline: 2px solid var(--accent); outline-offset: -2px; background: rgba(232, 200, 119, .14); }
.yv-head { border-bottom: 1px solid var(--line-strong); }
.yv-head .yv-days span { text-align: center; font-size: 11px; font-weight: 700; color: #fff; padding: 8px 0; }

/* Hover card for a day in the list view (built by app.js). */
.moon-tip {
    position: fixed; left: 0; top: 0; z-index: 50;
    width: max-content; min-width: 140px; max-width: 210px; text-align: center;
    background: #e6e7ea; border: 1px solid #b4b8c1; border-radius: 5px; box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
    pointer-events: none;
    /* Fades and drifts in; fades out too -- `visibility` flips only after the
       fade has finished (its 0.2s delay), otherwise it would cut the fade-out. */
    opacity: 0; visibility: hidden; transform: translateY(5px);
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.moon-tip.is-below { transform: translateY(-5px); }
.moon-tip.is-on { opacity: 1; visibility: visible; transform: translateY(0); transition-delay: 0s, 0s, 0s; }
.moon-tip::after {
    content: ""; position: absolute; left: var(--arrow-x, 50%); bottom: -6px; width: 10px; height: 10px;
    background: #e6e7ea; border-right: 1px solid #b4b8c1; border-bottom: 1px solid #b4b8c1;
    transform: translateX(-50%) rotate(45deg);
}
/* Placed below the day, the arrow sits on the moon's dark box instead. */
.moon-tip.is-below::after { bottom: auto; top: -6px; background: #0c0d10; transform: translateX(-50%) rotate(225deg); }
/* The moon needs a dark surround to read well: a black box across the top. */
.tip-moon { background: #0c0d10; padding: 14px 0 12px; border-radius: 4px 4px 0 0; }
.tip-moon svg { display: block; width: 76px; height: 76px; margin: 0 auto; }
.tip-text { padding: 10px 14px 12px; }
.tip-date { font-size: 14px; font-weight: 700; color: #111214; line-height: 1.25; }
.tip-day { margin-top: 3px; font-size: 12px; color: #555a64; }
.tip-phase { margin-top: 9px; padding-top: 8px; border-top: 1px solid #c6c9d0; font-size: 12px; font-weight: 600; color: #22252b; }

@media (max-width: 720px) {
    .vt-btn { width: 36px; height: 32px; }
    /* 31 moons don't fit one row on a phone: month name above, 16 per line. */
    .yv-head { display: none; }
    .yv-row { grid-template-columns: 1fr; }
    .yv-row[data-month] { padding: 0; }
    .yv-month { padding: 8px 10px 2px; }
    .yv-days { grid-template-columns: repeat(16, 1fr); padding: 0 4px 8px; }
    .yv-d { padding: 2px; }
    .yv-d svg { width: 100%; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 0; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 0; margin-bottom: 12px; }
.site-footer nav a {
    padding: 4px 14px; font-size: 13px; color: var(--muted);
    border-right: 1px solid var(--line);
}
.site-footer nav a:last-child { border-right: none; }
.site-footer .lang-row { margin-bottom: 12px; }
.site-footer .lang-row a, .site-footer .lang-row span {
    padding: 3px 10px; font-size: 11px; letter-spacing: .03em; color: var(--dim);
    border-right: 1px solid var(--line);
}
.site-footer .lang-row a:last-child, .site-footer .lang-row span:last-child { border-right: none; }
.site-footer p { text-align: center; font-size: 12px; color: var(--dim); margin: 0; }
.site-footer .footer-blurb {
    max-width: 640px; margin: 0 auto 18px; font-size: 13px; line-height: 1.6; color: var(--muted);
}

.about-copy { max-width: 720px; margin: 24px auto; color: var(--muted); }
.about-copy h1 { color: var(--fg); }
.about-copy dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.about-copy dt { color: var(--fg); font-weight: 600; }
.about-copy dd { margin: 0; }

h1, h2 { color: var(--fg); font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(20px, 3vw, 28px); }
