/* =============================================================================
   Demo site styling. Hand-written, no framework, no build step — served straight
   from ./demo by Caddy. Modern dark SaaS look: layered surfaces, soft borders,
   rounded corners, subtle motion. Shared across landing, /db and /inbox.
   ============================================================================= */

:root {
    /* surfaces, deepest -> raised */
    --bg: #0b0d12;
    --bg-soft: #0f1218;
    --surface: #161a22;
    --surface-2: #1c212b;
    --surface-3: #232936;

    /* lines + text */
    --border: #232a36;
    --border-soft: #1b212c;
    --text: #e8eaf0;
    --muted: #9aa4b4;
    --faint: #69707e;

    /* accent + status */
    --accent: #6ea8fe;
    --accent-ink: #0b0d12;
    --accent-glow: rgba(110, 168, 254, 0.16);
    --good: #3fb950;
    --good-soft: rgba(63, 185, 80, 0.14);
    --bad: #f85149;
    --bad-soft: rgba(248, 81, 73, 0.14);

    /* radii + shadow */
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 18px;
    --pill: 999px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 20px 48px rgba(0, 0, 0, 0.4);

    --maxw: 1080px;
    --ease: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    /* full-height flex column so the footer pins to the bottom on short pages */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* native system UI fonts — modern, fast, zero external/Google-Fonts dependency */
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    /* soft glow behind the top of the page — the modern SaaS halo */
    background-image: radial-gradient(
        900px 420px at 50% -160px,
        var(--accent-glow),
        transparent 70%
    );
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-weight: 650;
}

code {
    font-family:
        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
}

.container {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
}

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

/* ---------------------------------------------------------------- header/nav */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}
.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #8b7bff);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 4px 12px var(--accent-glow);
}
.brand-text {
    font-size: 15px;
    letter-spacing: -0.01em;
}
.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--good);
    background: var(--good-soft);
    border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
    padding: 2px 8px;
    border-radius: var(--pill);
}
.badge-live .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--good);
    box-shadow: 0 0 0 0 var(--good);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 70%, transparent);
    }
    70% {
        box-shadow: 0 0 0 6px transparent;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-link {
    position: relative;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    font-size: 14px;
    color: var(--muted);
    transition:
        color var(--ease),
        background var(--ease);
}
.nav-link:hover {
    color: var(--text);
    background: var(--surface);
}
.nav-link.active {
    color: var(--text);
}
.nav-link.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* ---------------------------------------------------------------------- main */
main {
    flex: 1 0 auto; /* grow to fill, pushing the footer to the bottom */
    padding: 56px 0 96px;
}

/* page header (db / inbox) */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 28px 0px;
}
.page-head h1 {
    font-size: 26px;
}
.page-head p {
    margin: 6px 0 0;
}
.page-head .sub {
    font-size: 14px;
}
.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.count-chip {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--pill);
    padding: 2px 10px;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------- hero */
/* stacked + centered: the form is much taller than the copy, so columns look
   lopsided — copy on top, form in a constrained card below. */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 36px 0 96px 0;
}
.hero-copy {
    max-width: 620px;
}
.hero-copy h1 {
    font-size: 42px;
    line-height: 1.08;
}
.hero-copy .lead {
    font-size: 17px;
    color: var(--muted);
    margin: 18px auto 0;
    max-width: 54ch;
}
.eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 16px;
}
.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 26px;
    flex-wrap: wrap;
    justify-content: center;
}
.hero-form {
    width: 100%;
    max-width: 600px;
    margin-top: 68px;
    text-align: left;
}

/* buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition:
        transform var(--ease),
        background var(--ease),
        border-color var(--ease);
}
.btn:active {
    transform: translateY(1px);
}
.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
}
.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 88%, white);
}
.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

/* ---------------------------------------------------------------------- card */
.card {
    background: linear-gradient(180deg, var(--surface), var(--bg-soft));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}
.card-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-soft);
}
.card-head h2 {
    font-size: 16px;
}
.card-head p {
    margin: 4px 0 0;
    font-size: 13px;
}

/* hero form card holds the (transparent, dark-themed) Tally embed */
.hero-form {
    overflow: hidden;
}
.embed-wrap {
    padding: 8px 12px 14px;
}
iframe[data-tally-src],
iframe.tally {
    width: 100%;
    border: 0;
    min-height: 520px;
    display: block;
}

/* ------------------------------------------------------------ how-it-works */
.how {
    margin-top: 8px;
}
.how-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.step {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    transition:
        transform var(--ease),
        border-color var(--ease);
}
.step:hover {
    transform: translateY(-2px);
    border-color: var(--border);
}
.step-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--accent-glow);
    color: var(--accent);
    margin-bottom: 14px;
}
.step-icon svg {
    width: 20px;
    height: 20px;
}
.step h3 {
    font-size: 15px;
}
.step p {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--muted);
}
.step .n {
    font-size: 12px;
    color: var(--faint);
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* -------------------------------------------------------------------- table */
.table-card {
    overflow: hidden;
}
.table-scroll {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
thead th {
    position: sticky;
    top: 0;
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-2);
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
}
tbody tr {
    transition: background var(--ease);
}
tbody tr:last-child td {
    border-bottom: 0;
}
tbody tr:hover {
    background: var(--surface);
}
td .name {
    font-weight: 600;
}
td .summary {
    color: var(--muted);
    max-width: 360px;
}
td.mono,
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--muted);
}

/* pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--pill);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.pill.good {
    color: var(--good);
    background: var(--good-soft);
}
.pill.bad {
    color: var(--bad);
    background: var(--bad-soft);
}
.pill.lead {
    color: var(--accent);
    background: var(--accent-glow);
}

/* score chip */
.score {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    height: 26px;
    padding: 0 8px;
    border-radius: var(--r-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: var(--surface-3);
    color: var(--text);
}
.score.hi {
    background: var(--good-soft);
    color: var(--good);
}
.score.lo {
    background: var(--bad-soft);
    color: var(--bad);
}

/* ---------------------------------------------------------------- inbox list */
.inbox {
    display: flex;
    flex-direction: column;
}
.msg {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 16px;
    align-items: start;
    padding: 22px;
    border-bottom: 1px solid var(--border-soft);
    transition: background var(--ease);
}
.msg:last-child {
    border-bottom: 0;
}
.msg:hover {
    background: var(--surface);
}
.msg-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}
.msg-icon svg {
    width: 19px;
    height: 19px;
}
.msg-icon.lead {
    background: var(--accent-glow);
    color: var(--accent);
}
.msg-icon.error {
    background: var(--bad-soft);
    color: var(--bad);
}
.msg-body {
    min-width: 0;
}
.msg-top {
    display: flex;
    align-items: center;
    gap: 8px 10px;
    flex-wrap: wrap;
}
.msg .subject {
    font-weight: 600;
}
.msg .meta {
    color: var(--faint);
    font-size: 12.5px;
    margin-left: auto;
    white-space: nowrap;
}
.msg .body {
    color: var(--muted);
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
}

/* ------------------------------------------------------------- states/skel */
.state {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}
.state.error {
    color: var(--bad);
}
.skeleton {
    padding: 8px 0;
}
.skeleton .row {
    height: 16px;
    margin: 14px 16px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 37%,
        var(--surface-2) 63%
    );
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* offline / service-down panel (shared, injected by status.js) */
.offline {
    text-align: center;
    padding: 56px 24px;
    max-width: 460px;
    margin: 0 auto;
}
.offline-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.offline-icon svg {
    width: 28px;
    height: 28px;
}
.offline h2 {
    font-size: 20px;
}
.offline p {
    color: var(--muted);
    margin: 10px 0 0;
}
.offline-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}
.offline-status {
    margin-top: 18px;
    font-size: 14px;
}
.offline-status.good {
    color: var(--good);
}
.offline-status.error {
    color: var(--bad);
}
.offline-status a {
    color: inherit;
    text-decoration: underline;
}

/* -------------------------------------------------------------------- footer */
.site-footer {
    border-top: 1px solid var(--border-soft);
    padding: 28px 0;
    margin-top: 36px;
    color: var(--faint);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.site-footer a {
    color: var(--muted);
}
.site-footer a:hover {
    color: var(--text);
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 860px) {
    .hero-copy h1 {
        font-size: 34px;
    }
    .how-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 560px) {
    .container {
        padding: 0 16px;
    }
    main {
        padding: 40px 0 64px;
    }
    .hero {
        margin-bottom: 64px;
    }
    .badge-live {
        display: none;
    }
    td .summary {
        max-width: 200px;
    }
}
