/* Where is my INDX? — community delivery tracker
   Mobile-first, no frameworks. */

:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1c2330;
    --muted: #5d6572;
    --border: #d9dde3;
    --accent: #d24726; /* Prusa-ish orange */
    --accent-dark: #ab351a;
    --accent-ink: #ffffff;
    --ok-bg: #e7f6ec;
    --ok-border: #1f8a46;
    --ok-text: #155e30;
    --err-bg: #fdecea;
    --err-border: #c0392b;
    --err-text: #8c2c21;
    --info-bg: #e8f1fb;
    --info-border: #2f6fb2;
    --info-text: #1f4e7d;
    --banner-bg: #fff0c2; /* high-contrast amber */
    --banner-border: #b98600;
    --banner-text: #433300;
    --hm-0: #ebedf0;
    --hm-1: #ace7ae;
    --hm-2: #69c16e;
    --hm-3: #549f57;
    --hm-4: #386a3a;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14171c;
    --surface: #1d2129;
    --text: #e7eaef;
    --muted: #98a1ad;
    --border: #333a45;
    --accent: #f06a3f;
    --accent-dark: #d24726;
    --accent-ink: #17130f;
    --ok-bg: #16331f;
    --ok-border: #2f9e55;
    --ok-text: #9fe0b4;
    --err-bg: #3a1d19;
    --err-border: #d0533f;
    --err-text: #f0a297;
    --info-bg: #17293d;
    --info-border: #4d8dd1;
    --info-text: #a9c9ea;
    --banner-bg: #3d2f00;
    --banner-border: #d9a400;
    --banner-text: #ffe9a3;
    --hm-0: #262b33;
    --hm-1: #1f4f2a;
    --hm-2: #2f7a3d;
    --hm-3: #43a85a;
    --hm-4: #62d67e;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --bg: #14171c;
        --surface: #1d2129;
        --text: #e7eaef;
        --muted: #98a1ad;
        --border: #333a45;
        --accent: #f06a3f;
        --accent-dark: #d24726;
        --accent-ink: #17130f;
        --ok-bg: #16331f;
        --ok-border: #2f9e55;
        --ok-text: #9fe0b4;
        --err-bg: #3a1d19;
        --err-border: #d0533f;
        --err-text: #f0a297;
        --info-bg: #17293d;
        --info-border: #4d8dd1;
        --info-text: #a9c9ea;
        --banner-bg: #3d2f00;
        --banner-border: #d9a400;
        --banner-text: #ffe9a3;
        --hm-0: #262b33;
        --hm-1: #1f4f2a;
        --hm-2: #2f7a3d;
        --hm-3: #43a85a;
        --hm-4: #62d67e;
    }
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.container {
    width: 100%;
    max-width: 60rem;
    margin: 0 auto;
    padding: 0 1rem;
}

.muted {
    color: var(--muted);
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0.25rem 0 0;
}

/* ---------- header / nav ---------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    color: var(--accent);
    background: var(--surface);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    font-weight: 600;
}

.nav a:hover {
    color: var(--text);
    background: var(--info-bg);
}

.nav a[aria-current="page"] {
    color: var(--accent-ink);
    background: var(--accent);
    font-weight: 700;
}

.nav a[aria-current="page"]:hover {
    color: var(--accent-ink);
    background: var(--accent);
    text-decoration-thickness: 2px;
}

.nav a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.header-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
}

.theme-control {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.theme-label {
    color: var(--muted);
}

.theme-options {
    display: inline-flex;
    gap: 0.15rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--bg);
}

.theme-option {
    min-height: 2.5rem;
    padding: 0.35rem 0.6rem;
    border: 0;
    border-radius: 0.35rem;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.theme-option:hover {
    color: var(--text);
    background: var(--surface);
}

.theme-option[aria-pressed="true"] {
    color: var(--accent-ink);
    background: var(--accent);
}

.theme-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- FR-014 disclaimer banner ---------- */

.disclaimer-banner {
    background: var(--banner-bg);
    border-bottom: 2px solid var(--banner-border);
    color: var(--banner-text);
    font-size: 0.95rem;
}

.disclaimer-banner .container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.disclaimer-banner strong {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* ---------- main content ---------- */

.main {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
    min-height: 55vh;
}

h1 {
    font-size: 1.7rem;
    margin: 0.25rem 0 0.75rem;
}

h2 {
    font-size: 1.25rem;
    margin: 1.75rem 0 0.5rem;
}

p {
    margin: 0.5rem 0;
}

/* ---------- panels & cards ---------- */

.welcome {
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 14px;
    padding: clamp(1.25rem, 4vw, 2.25rem);
    margin: 0 0 1.75rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, var(--surface)), var(--surface) 65%);
}

.welcome-eyebrow {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.035em;
    margin: 0 0 0.65rem;
}

.welcome h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
    margin: 0 0 0.85rem;
    text-wrap: balance;
}

.welcome-lead {
    font-size: 1.1rem;
    max-width: 44rem;
    margin-bottom: 1rem;
}

.welcome-copy {
    max-width: 47rem;
}

.welcome-copy p + p {
    margin-top: 0.9rem;
}

.welcome-stats-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent);
    font-weight: 650;
    text-underline-offset: 0.2em;
}

.form-intro {
    margin-bottom: 1.5rem;
}

.form-intro h2 {
    margin-top: 0;
}

.card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
}

.panel-error {
    background: var(--err-bg);
    border-color: var(--err-border);
    color: var(--err-text);
}

.panel-ok {
    background: var(--ok-bg);
    border-color: var(--ok-border);
    color: var(--ok-text);
}

.panel-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
}

.panel-terminal {
    text-align: center;
    padding: 2rem 1rem;
    border-width: 2px;
}

.panel-terminal h2 {
    margin: 0 0 0.5rem;
}

/* ---------- form ---------- */

.report-form {
    max-width: 34rem;
}

.field {
    margin-bottom: 1rem;
}

.field label,
.field legend {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

fieldset.field {
    border: 0;
    padding: 0;
    margin: 0 0 1rem;
}

input[type="text"],
input[type="date"],
select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.radio-group legend {
    width: 100%;
}

label.radio {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    cursor: pointer;
}

label.radio input {
    accent-color: var(--accent);
    width: 1.05rem;
    height: 1.05rem;
}

.field-error {
    color: var(--err-text);
    font-size: 0.85rem;
    margin: 0.3rem 0 0;
}

/* ---------- buttons ---------- */

.btn {
    font: inherit;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0.6rem 1.1rem;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent-dark);
    color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
}

.btn-danger {
    background: var(--err-border);
    border-color: var(--err-border);
    color: #fff;
}

/* "I have received it!" — green positive action (feature 005, FR-001). */
.btn-received {
    background: var(--ok-border);
    border-color: var(--ok-border);
    color: #fff;
}

.btn-received:hover:not(:disabled) {
    filter: brightness(0.88);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- date row + "Today" button ---------- */

.date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-row input[type="date"] {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
}

.btn-today {
    flex: 0 0 auto;
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* ---------- dashboard: tiles ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.75rem;
    margin: 1rem 0 0.25rem;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 0.9rem;
}

.tile-value {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
}

.tile-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 0.15rem;
}

/* ---------- dashboard: table ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    min-width: 38rem;
}

.stats-table th,
.stats-table td {
    text-align: left;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.stats-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.stats-table tbody tr:last-child td {
    border-bottom: 0;
}

.stats-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- heatmap ---------- */

.heatmap svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.heatmap rect {
    stroke: none;
}

.heatmap .hm-0 {
    fill: var(--hm-0);
}

.heatmap .hm-1 {
    fill: var(--hm-1);
}

.heatmap .hm-2 {
    fill: var(--hm-2);
}

.heatmap .hm-3 {
    fill: var(--hm-3);
}

.heatmap .hm-4 {
    fill: var(--hm-4);
}

.hm-month {
    font-size: 8px;
    fill: var(--muted);
}

.generated {
    margin-top: 1.25rem;
    font-size: 0.85rem;
}

/* ---------- turnstile ---------- */

.turnstile-widget {
    min-height: 65px;
}

/* ---------- action buttons (success panel + pending panel) ---------- */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.75rem 0 0.25rem;
}

/* Anchors styled as buttons: kill link underlines, sit on one line. */
a.btn-action {
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

a.btn-action:hover,
a.btn-action:focus-visible {
    text-decoration: none;
}

/* ---------- per-order stats lines (feature 005) ---------- */

.order-stats {
    font-size: 0.85rem;
    margin: 0.15rem 0 0.4rem;
}

.order-stats p {
    margin: 0.15rem 0;
}

.order-stats-note {
    font-size: 0.78rem;
    font-style: italic;
}

/* ---------- pending reports panel ---------- */

.pending-panel {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
    border-radius: 10px;
}

.pending-panel h2 {
    margin: 0 0 0.75rem;
}

.pending-entry + .pending-entry {
    border-top: 1px solid var(--info-border);
    margin-top: 0.9rem;
    padding-top: 0.9rem;
}

.pending-entry-head {
    margin: 0 0 0.5rem;
}

.pending-entry .action-buttons {
    margin: 0.25rem 0;
}

.pending-entry .hint {
    margin: 0.25rem 0 0;
}

/* ---------- footer ---------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: 2rem;
}

.footer-inner {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    font-size: 0.85rem;
}

.footer-stack {
    margin: 0.6rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.6;
}

.author-contact {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.reddit-contact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent-ink);
    background: var(--accent);
    box-shadow: 0 4px 18px rgb(0 0 0 / 12%);
    font-weight: 650;
    text-decoration: none;
}

.reddit-contact:hover {
    background: var(--accent-dark);
}

.reddit-contact:focus-visible,
.welcome-stats-link:focus-visible {
    outline: 3px solid var(--text);
    outline-offset: 4px;
}

/* ---------- small screens ---------- */

@media (min-width: 40rem) {
    .author-contact {
        position: fixed;
        right: max(1.25rem, env(safe-area-inset-right));
        bottom: max(1.25rem, env(safe-area-inset-bottom));
        z-index: 20;
        margin: 0;
    }

    .footer-inner {
        padding-bottom: 5rem;
    }

    .card,
    .panel {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2rem;
    }
}

/* Public guide remains readable before WASM starts and after navigation. */
.public-guide { margin-top: 2rem; }
.public-guide h3 { margin-top: 1.4rem; font-size: 1rem; }
.public-guide p { color: var(--muted); line-height: 1.65; }
.public-guide summary { cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.public-guide li { margin-top: .45rem; }
