/* PhotoForecast - dark by default, because you read it at 4am before a shoot. */

:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-raised: #1d212a;
    --border: #262b36;
    --text: #e6e8ec;
    --muted: #939cad;
    --accent: #f5a623;

    /* Band colours, reused by the score chips and the charts. */
    --band-exceptional: #ffb454;
    --band-good: #7fd18b;
    --band-fair: #8fb8de;
    --band-marginal: #8a93a3;
    --band-poor: #5a6273;

    --positive: #7fd18b;
    --negative: #e0736d;

    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }

/* ---- Shell ---- */

.site-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-mark { color: var(--accent); font-size: 1.2rem; }

.site-header nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* On a wide screen the wrapper is transparent to layout, so nav and the user
   block stay direct flex children of the header exactly as before. */
.site-menu { display: contents; }

/* Shown only once nav.js has run; see the note in that file. */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.nav-toggle:hover { background: var(--panel-raised); }

.nav-toggle .bars { position: relative; }

.nav-toggle .bars,
.nav-toggle .bars::before,
.nav-toggle .bars::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
}

.nav-toggle .bars::before,
.nav-toggle .bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle .bars::before { top: -6px; }
.nav-toggle .bars::after  { top: 6px; }

/* Open state folds the bars into a cross, so the button says what it will do
   next rather than what it did last. */
.site-header[data-menu="open"] .bars { background: transparent; }
.site-header[data-menu="open"] .bars::before { top: 0; transform: rotate(45deg); }
.site-header[data-menu="open"] .bars::after  { top: 0; transform: rotate(-45deg); }

@media (prefers-reduced-motion: no-preference) {
    .nav-toggle .bars,
    .nav-toggle .bars::before,
    .nav-toggle .bars::after {
        transition: transform 160ms ease, top 160ms ease, background-color 160ms ease;
    }
}

@media (max-width: 800px) {
    .site-header { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem 1rem; }

    /* Pushes the button to the right edge whether or not the menu is open. */
    .brand { margin-right: auto; }

    .site-header.has-toggle .nav-toggle { display: inline-flex; }

    .site-header.has-toggle .site-menu {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        gap: 0.25rem;
        padding-top: 0.6rem;
        border-top: 1px solid var(--border);
    }

    .site-header.has-toggle[data-menu="open"] .site-menu { display: flex; }

    .site-header nav { flex-direction: column; gap: 0.15rem; }

    /* Roomier targets: these are being tapped with a thumb, often in the dark. */
    .nav-link { padding: 0.65rem 0.7rem; font-size: 0.95rem; }

    .site-user {
        margin-left: 0;
        margin-top: 0.35rem;
        padding-top: 0.7rem;
        border-top: 1px solid var(--border);
        justify-content: space-between;
    }
}

.nav-link {
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9rem;
}

.nav-link:hover { background: var(--panel-raised); color: var(--text); }
.nav-link.active { background: var(--panel-raised); color: var(--text); }

main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ---- Generic surfaces ---- */

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0; }

.toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

button, .button {
    font: inherit;
    font-size: 0.88rem;
    padding: 0.45rem 0.85rem;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--panel-raised);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover, .button:hover { border-color: #3a4150; }
button:disabled { opacity: 0.5; cursor: default; }

button.primary { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--negative); }

select, input[type="text"], input[type="number"], input[type="date"], input[type="url"], textarea {
    font: inherit;
    font-size: 0.88rem;
    padding: 0.45rem 0.6rem;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

textarea { resize: vertical; min-height: 4.5rem; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }

.field { margin-bottom: 0.85rem; }
.field-row { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 10rem; }

.checkbox { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--text); }
.checkbox input { width: auto; }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 2.5rem 1rem; text-align: center; }
.error { color: var(--negative); font-size: 0.85rem; }

/* ---- Score chips ---- */

.chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 3.1rem;
    padding: 0.4rem 0.3rem;
    border-radius: 8px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--band-poor);
    font-variant-numeric: tabular-nums;
}

.chip .score { font-size: 1.05rem; font-weight: 600; line-height: 1.1; }
.chip .time { font-size: 0.68rem; color: var(--muted); }

.band-Exceptional { border-left-color: var(--band-exceptional); }
.band-Good { border-left-color: var(--band-good); }
.band-Fair { border-left-color: var(--band-fair); }
.band-Marginal { border-left-color: var(--band-marginal); }
.band-Poor { border-left-color: var(--band-poor); }

.band-Exceptional .score { color: var(--band-exceptional); }
.band-Good .score { color: var(--band-good); }
.band-Fair .score { color: var(--band-fair); }

/* ---- Forecast grid ---- */

.forecast-grid { overflow-x: auto; }

table.forecast {
    border-collapse: separate;
    border-spacing: 0.4rem;
    width: 100%;
    min-width: 46rem;
}

table.forecast th {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    text-align: center;
    padding-bottom: 0.2rem;
}

table.forecast th.row-head, table.forecast td.row-head {
    text-align: left;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--muted);
    width: 7rem;
}

table.forecast td { text-align: center; }

table.forecast a.cell { text-decoration: none; display: block; }
table.forecast a.cell:hover .chip { border-color: #4a5265; }

.day-head { display: flex; flex-direction: column; gap: 0.1rem; }

/* The summary row reads as a heading for the columns beneath it. */
tr.summary-row td.row-head { color: var(--text); font-weight: 600; }
tr.summary-row td { padding-bottom: 0.15rem; }
tr.summary-row + tr td { border-top: 1px solid var(--border); padding-top: 0.55rem; }

/* ---- Overview ---- */

.grid-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.grid-head h2 { margin: 0; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }

.segmented .seg {
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.83rem;
    padding: 0.4rem 0.75rem;
}

.segmented .seg + .seg { border-left: 1px solid var(--border); }
.segmented .seg:hover { color: var(--text); background: var(--panel-raised); }
.segmented .seg.active { background: var(--panel-raised); color: var(--text); font-weight: 600; }

/* Ranked list: does the scanning the grid would otherwise leave to the reader. */
.best-list { display: flex; flex-direction: column; }

/* Every column is a fixed width because each row is its own grid, and an auto
   column therefore sizes to that row's own content. "Tomorrow, 5:26 AM" and
   "Wed 19 Aug, 5:30 AM" are 13px apart, which was enough to leave the scores and
   dates visibly out of line down the list. */
.best-row {
    display: grid;
    /* 8.75rem is 140px. The longest string the date column can hold is
       "Wed 19 Aug, 12:30 PM", measured at 131.6px, so this leaves a little
       headroom for platforms whose text metrics differ without wasting space. */
    grid-template-columns: 3.1rem 7rem 1fr 8.75rem;
    gap: 0.85rem;
    align-items: center;
    padding: 0.4rem 0.35rem;
    border-radius: 7px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.best-row:last-child { border-bottom: none; }
.best-row:hover { background: var(--panel-raised); }

.best-kind { font-size: 0.88rem; }

/* min-width lets the track actually shrink, so a long location name truncates
   instead of pushing the date column out of alignment again. */
.best-where {
    font-size: 0.88rem;
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.best-when { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

@media (max-width: 640px) {
    .best-row { grid-template-columns: 3.1rem 1fr; row-gap: 0.15rem; }
    .best-when { grid-column: 2; }
}

.location-link { text-decoration: none; }
.location-link:hover { color: var(--text); text-decoration: underline; }

/* Best score in each column, so the answer is findable without reading every
   number. Deliberately quiet: the band colour already carries the quality. */
.best-cell .chip {
    border-color: #4a5265;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

/* Day-to-day stepping on the detail page. */
.day-nav { display: flex; align-items: center; gap: 0.6rem; }

.day-step {
    padding: 0.05rem 0.5rem;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--muted);
}

.day-step:hover:not(:disabled) { color: var(--text); }
.day-step:disabled { opacity: 0.3; }

/* ---- Day detail ---- */

.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }

@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
}

.event-card { margin-bottom: 1rem; }

.event-card header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.6rem;
}

.event-card header .title { flex: 1; }
.event-card header .title h2 { margin: 0; }
.event-card header .title .when { font-size: 0.8rem; color: var(--muted); }

.narrative { margin: 0 0 0.9rem; line-height: 1.6; }

.confidence-note { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.75rem; }

/* Signed factor bars: the "why is this score high" view. */
.factors { display: flex; flex-direction: column; gap: 0.4rem; }

.factor {
    display: grid;
    grid-template-columns: 9.5rem 1fr 3rem;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.83rem;
}

.factor .factor-name { color: var(--muted); }
.factor .factor-value { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.factor .factor-value.pos { color: var(--positive); }
.factor .factor-value.neg { color: var(--negative); }
.factor .factor-value.zero { color: var(--muted); }

.factor-detail {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.78rem;
    padding-left: 0.15rem;
    margin: -0.15rem 0 0.35rem;
}

.factor-detail .evidence { font-family: var(--mono); color: #7e8798; }

.astro-list { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; font-size: 0.85rem; }
.astro-list dt { color: var(--muted); white-space: nowrap; }
.astro-list dd { margin: 0; font-variant-numeric: tabular-nums; }

.section-gap { margin-top: 1rem; }

/* ---- Tables ---- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
table.data td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }

.stars { color: var(--accent); letter-spacing: 0.08em; white-space: nowrap; }

.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; align-items: start; }

@media (max-width: 820px) {
    .layout-split { grid-template-columns: 1fr; }
}

/* ---- Charts ---- */

.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; }
.chart-legend > span { display: flex; align-items: center; gap: 0.4rem; }

/* The key draws each series' real line, so stroke colour and any dash pattern
   both show. A solid block cannot represent a dashed series honestly. */
.legend-mark { flex: 0 0 auto; width: 20px; height: 10px; }

.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { }
.stat .value { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 0.78rem; color: var(--muted); }

/* ---- Accounts ---- */

/* Signed-in identity sits at the far right of the header, pushed there rather
   than floated so it survives the nav wrapping on a narrow window. */
.site-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}

.site-user .user-name { color: var(--muted); }

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

.link-button:hover { color: var(--text); border-color: transparent; }

/* Sign-in, setup, and invite pages: one narrow column, vertically generous,
   because there is nothing else on the page to balance against. */
.auth-body { display: flex; min-height: 100vh; }

.auth-shell {
    margin: auto;
    padding: 2rem 1.25rem;
    width: 100%;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-card { padding: 1.5rem; }

.auth-card h1 { margin-bottom: 0.5rem; }

.auth-card .subtitle { margin-bottom: 1.25rem; }

.auth-card button.primary { width: 100%; margin-top: 0.35rem; }

.auth-footnote { color: var(--muted); font-size: 0.78rem; margin: 0; text-align: center; }

.form-error {
    background: rgba(224, 115, 109, 0.12);
    border: 1px solid var(--negative);
    color: var(--negative);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.field-hint { color: var(--muted); font-size: 0.78rem; margin: 0.3rem 0 0; }

/* ---- Invitations ---- */

.invite-fresh { border-color: var(--accent); margin-bottom: 1rem; }

.copy-row { display: flex; gap: 0.5rem; }

/* The link is long and the point is to copy it whole, so it gets a monospace
   face and all the width going. */
.copy-row input {
    flex: 1;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.state {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.state-pending  { color: var(--band-good); }
.state-redeemed { color: var(--muted); }
.state-revoked  { color: var(--negative); }
.state-expired  { color: var(--muted); }
