/* ==========================================================================
   Base: reset, typography, page layout, header/nav, footer, motion.
   ========================================================================== */

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

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--nav-h) + var(--s-4));
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}

a {
    color: var(--accent-text);
    text-decoration: none;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
    transition: color var(--dur) var(--ease);
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--r-1);
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

code,
kbd,
pre,
.mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* Amounts, counts and anything a person might compare down a column. */
.num,
.stat-value,
.fee-amount,
.budget,
.comm-budget,
.comm-fees,
.application-rate,
.task-row-budget,
.inbox-app-budget,
.payment-currency,
.fee-total,
.reputation-score,
.unread-badge,
.section-count {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "ss01";
}

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

.skip-link {
    position: absolute;
    left: var(--s-4);
    top: -4rem;
    z-index: 1000;
    padding: var(--s-2) var(--s-4);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    border-radius: var(--r-2);
}

.skip-link:focus {
    top: var(--s-3);
}

/* ---- Icons ------------------------------------------------------------- */

.icon {
    width: 1.125em;
    height: 1.125em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Header / navigation ---------------------------------------------- */

nav.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--s-4);
    height: var(--nav-h);
    /* Align the header content with the page container (max 1200px, centred). */
    padding: 0 max(var(--gutter), calc((100% - var(--content-max)) / 2 + var(--gutter)));
    background: light-dark(rgba(250, 250, 247, 0.82), rgba(10, 10, 11, 0.8));
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
}

.brand a {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--text);
    font-weight: 650;
    font-size: var(--text-md);
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.brand a:hover {
    text-decoration: none;
}

.brand-mark {
    width: 1.5rem;
    height: 1.5rem;
}

.brand-tld {
    color: var(--text-3);
    font-weight: 500;
}

.nav-menu {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--s-5);
    min-width: 0;
}

.nav-links,
.nav-personal {
    display: flex;
    align-items: center;
    gap: var(--s-1);
}

.nav-links a,
.nav-personal a {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 0.4rem 0.75rem;
    border-radius: var(--r-2);
    color: var(--text-2);
    font-size: var(--text-base);
    font-weight: 500;
    white-space: nowrap;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.nav-links a:hover,
.nav-personal a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.nav-links a[aria-current="page"],
.nav-personal a[aria-current="page"] {
    color: var(--text);
    background: var(--surface-2);
}

.nav-inbox-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-left: auto;
}

.nav-post-task a,
.nav-cta a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 2.25rem;
    padding: 0 0.9rem;
    border-radius: var(--r-2);
    font-size: var(--text-base);
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.nav-post-task a {
    background: var(--accent);
    color: var(--accent-ink);
    border: 1px solid var(--accent-edge);
}

.nav-post-task a:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

.nav-post-task a:active,
.nav-cta a:active {
    transform: translateY(1px);
}

.nav-cta a {
    color: var(--text);
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.nav-cta a:hover {
    border-color: var(--text-3);
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.nav-user-link a {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    max-width: 14rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--r-2);
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-link a:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    margin-left: auto;
}

.nav-menu + .nav-tools {
    margin-left: 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid transparent;
    border-radius: var(--r-2);
    background: transparent;
    color: var(--text-2);
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.icon-btn:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

.icon-btn .icon {
    width: 1.2rem;
    height: 1.2rem;
}

/* Sun in dark mode (click for light), moon in light mode (click for dark). */
.theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

.nav-toggle {
    display: none;
}

.network-badge {
    flex: none;
    padding: 0.15rem 0.5rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--success-edge);
    background: var(--success-bg);
    color: var(--success);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.network-badge.devnet {
    border-color: var(--warning-edge);
    background: var(--warning-bg);
    color: var(--warning);
}

.unread-badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1;
}

@media (max-width: 860px) {
    .nav-toggle {
        display: inline-grid;
    }

    .nav-tools {
        margin-left: auto;
    }

    .nav-menu {
        position: fixed;
        inset: var(--nav-h) 0 auto 0;
        z-index: 99;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: var(--s-4);
        max-height: calc(100dvh - var(--nav-h));
        overflow-y: auto;
        padding: var(--s-4) var(--gutter) var(--s-5);
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-pop);
    }

    .nav-menu.open {
        display: flex;
        animation: menu-in 160ms var(--ease);
    }

    .nav-links,
    .nav-personal {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .nav-links a,
    .nav-personal a {
        padding: 0.8rem 0.5rem;
        font-size: var(--text-md);
        border-radius: var(--r-1);
        border-bottom: 1px solid var(--border);
    }

    .nav-actions {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        gap: var(--s-3);
    }

    .nav-post-task a,
    .nav-cta a {
        justify-content: center;
        height: 2.75rem;
    }

    .nav-user {
        justify-content: space-between;
    }

    .nav-user-link a {
        max-width: none;
    }

    .network-badge {
        margin-left: auto;
    }

    .network-badge + .nav-tools {
        margin-left: 0;
    }
}

@keyframes menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* ---- Page frame -------------------------------------------------------- */

main.container {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-6) var(--gutter) var(--s-8);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3) var(--s-5);
    margin-bottom: var(--s-5);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 650;
    letter-spacing: -0.035em;
    margin-bottom: var(--s-5);
}

.page-header .page-title {
    margin-bottom: 0;
}

.page-subtitle {
    color: var(--text-2);
    max-width: var(--measure);
    margin: calc(-1 * var(--s-3)) 0 var(--s-5);
}

/* ---- Footer ------------------------------------------------------------ */

.footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
}

.footer-content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-7) var(--gutter) var(--s-5);
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
    gap: var(--s-6);
}

.footer-section h4 {
    margin-bottom: var(--s-3);
    color: var(--text-3);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.footer-section p {
    max-width: 34ch;
    color: var(--text-2);
    font-size: var(--text-sm);
}

.footer-section ul {
    list-style: none;
    display: grid;
    gap: var(--s-2);
}

.footer-section a {
    color: var(--text-2);
    font-size: var(--text-base);
}

.footer-section a:hover {
    color: var(--text);
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
    color: var(--text);
    font-weight: 650;
    font-size: var(--text-md);
    letter-spacing: -0.03em;
}

.footer-bottom {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-4) var(--gutter) var(--s-6);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--s-2) var(--s-5);
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: var(--text-sm);
}

@media (max-width: 640px) {
    .footer-content {
        grid-template-columns: 1fr 1fr;
    }

    .footer-content .footer-section:first-child {
        grid-column: 1 / -1;
    }
}

/* ---- Motion ------------------------------------------------------------ */

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@keyframes shimmer {
    to {
        background-position-x: -200%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
