/* ============================================================
   MAIN STYLES
   ============================================================ */

:root {
    --color-bg: #ffffff;
    --color-text: #000000;
    --color-muted: #666666;
    --color-muted-hover: #000000;
    --color-separator: #cccccc;
    --color-accent: #000000;

    --font-primary: 'Switzer', sans-serif;
    --font-weight-regular: 400;
    --font-weight-bold: 700;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 3.5rem;

    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.15rem;
    --text-xl: 1.75rem;
    --text-xxl: 2.6rem;
}

[data-theme="dark"] {
    --color-bg: #141414;
    --color-text: #ffffff;
    --color-muted: #888888;
    --color-muted-hover: #ffffff;
    --color-separator: #2e2e2e;
    --color-accent: #ffffff;
}

/* ── Reset ───────────────────────────────────────────────── */

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

html {
    background-color: var(--color-bg);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ── Typography ──────────────────────────────────────────── */

h1 {
    font-size: var(--text-xxl);
    font-weight: var(--font-weight-bold);
    line-height: 1.08;
    margin-bottom: var(--space-md);
}

h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-muted);
    margin: var(--space-md) 0 var(--space-sm);
}

h3 {
    font-size: var(--text-base);
    font-weight: var(--font-weight-bold);
    margin: var(--space-md) 0 var(--space-xs);
}

p {
    font-size: var(--text-base);
}

ol,
ul {
    padding-left: var(--space-md);
    margin-bottom: var(--space-md);
}

ol {
    list-style-type: decimal-leading-zero;
}

li {
    font-size: var(--text-base);
    margin-bottom: var(--space-xs);
}

strong {
    font-weight: var(--font-weight-bold);
}

/* ── Links ───────────────────────────────────────────────── */

a {
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-muted-hover);
}

/* ── Layout ──────────────────────────────────────────────── */

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(var(--space-lg), env(safe-area-inset-top)) max(var(--space-lg), env(safe-area-inset-right)) max(var(--space-lg), env(safe-area-inset-bottom)) max(var(--space-lg), env(safe-area-inset-left));
}

.content-wrapper {
    flex: 1;
}

.controls-panel {
    position: fixed;
    top: max(var(--space-lg), env(safe-area-inset-top));
    right: max(var(--space-lg), env(safe-area-inset-right));
    z-index: 100;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.flex-between p {
    margin-bottom: 0;
}

footer p {
    margin-bottom: 0;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    align-items: start;
}

/* ── Homepage Scroll Snapping ────────────────────────────── */

html.snap-root {
    scroll-snap-type: y proximity;
}

html.snap-root body>.container,
html.snap-root body>.footer-section {
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* ── Utilities ───────────────────────────────────────────── */

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.col-span-2 {
    grid-column: 1 / 3;
}

.text-muted {
    color: var(--color-muted);
    font-size: var(--text-sm);
    display: block;
    margin-bottom: 0.4rem;
}

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

/* ── Hero ────────────────────────────────────────────────── */

.hero-heading {
    grid-column: 1 / 4;
    margin: 0;
}

.server-time,
.server-time-label {
    color: var(--color-muted);
}

/* ── Separators ──────────────────────────────────────────── */

.separator {
    border: none;
    border-top: 1px solid var(--color-separator);
    margin: var(--space-md) 0;
    transition: border-color 0.25s ease;
}

.separator--flush {
    margin: 0;
}

/* ── Navigation bar (resources) ─────────────────────────── */

.resources-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.resources-bar>p {
    color: var(--color-text);
    font-size: var(--text-lg);
}

.resources-nav {
    display: flex;
    gap: var(--space-md);
}

.resources-nav a {
    font-size: var(--text-base);
    color: var(--color-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-separator);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.resources-nav a:hover {
    color: var(--color-muted-hover);
    text-decoration-color: var(--color-muted-hover);
}

/* ── Back nav (detail pages) ─────────────────────────────── */

.back-nav {
    margin-bottom: var(--space-lg);
    font-size: var(--text-sm);
}

.back-nav a {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px 8px 0;
    margin: -8px -12px -8px 0;
    min-height: 44px;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.back-nav a:hover {
    color: var(--color-muted-hover);
}

.back-nav .back-label {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-separator);
    transition: text-decoration-color 0.2s ease;
}

.back-nav a:hover .back-label {
    text-decoration-color: var(--color-muted-hover);
}

/* ── Material Icons ──────────────────────────────────────── */

.icon {
    display: inline-block;
    font-size: 1em;
    vertical-align: -0.15em;
    font-variation-settings: 'FILL' 0, 'wght' 900, 'GRAD' 0, 'opsz' 24;
    -webkit-user-select: none;
    user-select: none;
}

.icon--sm {
    display: inline-block;
    font-size: 1.3em;
    vertical-align: -0.1em;
    -webkit-user-select: none;
    user-select: none;
}

.icon--inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15em;
    vertical-align: -0.25em;
    color: var(--color-text);
    background: var(--color-separator);
    padding: 2px;
    margin: 0 2px;
    -webkit-user-select: none;
    user-select: none;
}

/* ── Theme Toggle ────────────────────────────────────────── */

.theme-toggle {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs);
    margin: calc(var(--space-xs) * -1);
    min-width: 44px;
    min-height: 44px;
    font-size: 1.25rem;
    transition: color 0.2s ease;
}

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

/* ── Code Blocks ─────────────────────────────────────────── */

pre {
    background: var(--color-bg);
    border: 1px solid var(--color-separator);
    padding: var(--space-md);
    overflow-x: auto;
    margin: var(--space-md) 0;
}

pre code {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text);
    white-space: pre;
    font-weight: var(--font-weight-regular);
    background: transparent;
    padding: 0;
}

/* ── Code Window Component ───────────────────────────────── */

.code-window {
    border: 1px solid var(--color-separator);
    margin: var(--space-md) 0;
    background: var(--color-bg);
}

.code-window pre {
    margin: 0;
    border: none;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--color-separator);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .code-header {
    background: rgba(255, 255, 255, 0.02);
}

.code-lang {
    font-size: var(--text-sm);
    color: var(--color-muted);
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
}

.code-actions {
    display: flex;
    gap: var(--space-xs);
}

.code-actions button {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.code-actions button:hover {
    color: var(--color-muted-hover);
}

.code-content {
    position: relative;
}

.code-window.is-collapsed .code-content pre {
    max-height: 160px;
    overflow: hidden;
}

.code-window.is-collapsed .code-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--color-bg));
    pointer-events: none;
}

code {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.9em;
    background: var(--color-separator);
    padding: 2px 6px;
    font-weight: var(--font-weight-regular);
}

/* ── Detail Page Layout ──────────────────────────────────── */

.spec-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.spec-grid .col-span-2 {
    grid-column: 1 / 3;
}

.spec-value {
    font-size: var(--text-lg);
    font-weight: var(--font-weight-bold);
}

.log-container {
    max-width: 720px;
}

.log-container p {
    font-size: var(--text-lg);
    line-height: 1.6;
}

.log-container p+p {
    margin-top: var(--space-md);
}

/* ── Services Table ──────────────────────────────────────── */

.works-section {
    padding-top: var(--space-xl);
}

.works-table {
    width: 100%;
}

.works-table table {
    width: 100%;
    border-collapse: collapse;
}

.work-row {
    border-bottom: 1px solid var(--color-separator);
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

.work-row:hover {
    background-color: rgba(0, 0, 0, 0.03);
    background-color: color-mix(in srgb, var(--color-text) 3%, transparent);
}

.work-title-cell {
    width: 40%;
    padding: var(--space-md) 0;
}

.work-sphere-cell {
    width: 30%;
    padding: var(--space-md) 0;
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.work-status-cell {
    width: 20%;
    padding: var(--space-md) 0;
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.work-access-cell {
    width: 10%;
    padding: var(--space-md) 0;
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.work-link {
    display: block;
    width: 100%;
    color: inherit;
    text-decoration: none;
}

.work-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.work-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    /* Persistent muted underline — the primary affordance signal */
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-color: var(--color-separator);
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

.work-row:hover .work-title {
    text-decoration-color: var(--color-text);
}

/* ── Status Indicator ────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-sm);
    color: var(--color-muted);
}

.status-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-muted);
    flex-shrink: 0;
}

/* ── Docs Hub ────────────────────────────────────────────── */

.docs-category {
    margin-bottom: var(--space-lg);
}

.docs-category>.text-muted {
    margin-bottom: var(--space-xs);
}

.docs-index {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-index li {
    border-bottom: 1px solid var(--color-separator);
    margin-bottom: 0;
}

.docs-index a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    font-size: var(--text-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-color: var(--color-separator);
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.2s ease, background-color 0.15s ease;
}

.docs-index a:hover {
    text-decoration-color: var(--color-text);
    background-color: rgba(0, 0, 0, 0.03);
    background-color: color-mix(in srgb, var(--color-text) 3%, transparent);
}

.docs-index .doc-meta {
    font-size: var(--text-sm);
    color: var(--color-muted);
    font-weight: var(--font-weight-bold);
    text-decoration: none;
}

/* ── Footer ──────────────────────────────────────────────── */

footer {
    padding-top: var(--space-md);
    font-size: var(--text-base);
    color: var(--color-muted);
}

footer a {
    color: var(--color-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-separator);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

footer a:hover {
    color: var(--color-muted-hover);
    text-decoration-color: var(--color-muted-hover);
}

/* ── Guide Pages ─────────────────────────────────────────── */

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.guide-step {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-md);
    align-items: start;
}

.guide-step .text-muted {
    margin-top: 0.2rem;
    margin-bottom: 0;
}

.guide-step p {
    font-size: var(--text-lg);
    line-height: 1.6;
    max-width: 600px;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.info-table tr {
    border-bottom: 1px solid var(--color-separator);
}

.info-table td {
    padding: var(--space-sm) 0;
    vertical-align: middle;
    font-size: var(--text-base);
}

.info-table .cell-platform {
    width: 20%;
    font-size: var(--text-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    padding-right: var(--space-md);
}

.info-table .cell-client {
    width: 25%;
    color: var(--color-muted);
    font-size: var(--text-sm);
    padding-right: var(--space-md);
}

.info-table .cell-notes {
    color: var(--color-muted);
    font-size: var(--text-sm);
}

.info-table a {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-separator);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.info-table a:hover {
    color: var(--color-muted-hover);
    text-decoration-color: var(--color-muted-hover);
}

@media (max-width: 768px) {
    .guide-step {
        grid-template-columns: 1fr;
        gap: var(--space-xs);
    }

    .info-table tr {
        display: flex;
        flex-direction: column;
        padding: var(--space-md) 0;
        gap: var(--space-xs);
    }

    .info-table td {
        width: 100%;
        padding: 0;
    }

    .info-table .cell-platform {
        width: 100%;
        padding-bottom: var(--space-xs);
    }

    .info-table .cell-client {
        width: 100%;
        padding-right: 0;
    }

    .info-table .cell-notes {
        display: block;
        padding-top: var(--space-xs);
        border-top: 1px dashed var(--color-separator);
        margin-top: var(--space-xs);
    }
}

/* ── Site Footer (index page block 3) ────────────────────── */

.footer-section {
    padding: max(var(--space-lg), env(safe-area-inset-top)) max(var(--space-lg), env(safe-area-inset-right)) max(var(--space-lg), env(safe-area-inset-bottom)) max(var(--space-lg), env(safe-area-inset-left));
}

.site-footer-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: var(--space-lg);
}

.site-footer-name {
    font-size: var(--text-xxl);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-text);
    margin: 0;
}

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

.site-footer-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-xs);
}

.site-footer-nav a {
    font-size: var(--text-base);
    color: var(--color-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-separator);
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.site-footer-nav a:hover {
    color: var(--color-muted-hover);
    text-decoration-color: var(--color-muted-hover);
}

.site-footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-separator);
    color: var(--color-muted);
    font-size: var(--text-sm);
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
        filter: blur(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.anim {
    opacity: 0;
    animation: fadeUp 0.55s ease-out forwards;
}

.anim-d1 {
    animation-delay: 0.05s;
}

.anim-d2 {
    animation-delay: 0.15s;
}

.anim-d3 {
    animation-delay: 0.25s;
}

.anim-d4 {
    animation-delay: 0.35s;
}

.anim-d5 {
    animation-delay: 0.45s;
}

.anim-d6 {
    animation-delay: 0.55s;
}

.anim-d7 {
    animation-delay: 0.65s;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (min-width: 1600px) {
    :root {
        --text-xxl: 4rem;
        --text-xl: 2.25rem;
        --text-lg: 1.7rem;
        --space-lg: 3rem;
        --space-md: 2rem;
    }
}

@media (min-width: 2560px) {
    :root {
        --text-xxl: 4.5rem;
        --text-xl: 2.5rem;
        --space-lg: 4rem;
        --space-md: 2.5rem;
    }
}

@media (max-width: 1024px) {
    .container {
        padding: max(var(--space-md), env(safe-area-inset-top)) max(var(--space-md), env(safe-area-inset-right)) max(var(--space-md), env(safe-area-inset-bottom)) max(var(--space-md), env(safe-area-inset-left));
    }

    .controls-panel {
        top: max(var(--space-md), env(safe-area-inset-top));
        right: max(var(--space-md), env(safe-area-inset-right));
    }

    .footer-section {
        padding: max(var(--space-md), env(safe-area-inset-top)) max(var(--space-md), env(safe-area-inset-right)) max(var(--space-md), env(safe-area-inset-bottom)) max(var(--space-md), env(safe-area-inset-left));
    }

    .grid-container,
    .spec-grid {
        grid-template-columns: 1fr 1fr;
    }

    .col-span-2 {
        grid-column: 1 / -1;
    }

    .hero-heading {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: max(var(--space-sm), env(safe-area-inset-top)) max(var(--space-sm), env(safe-area-inset-right)) max(var(--space-sm), env(safe-area-inset-bottom)) max(var(--space-sm), env(safe-area-inset-left));
    }

    .controls-panel {
        top: max(var(--space-sm), env(safe-area-inset-top));
        right: max(var(--space-sm), env(safe-area-inset-right));
    }

    .footer-section {
        padding: max(var(--space-sm), env(safe-area-inset-top)) max(var(--space-sm), env(safe-area-inset-right)) max(var(--space-sm), env(safe-area-inset-bottom)) max(var(--space-sm), env(safe-area-inset-left));
    }

    :root {
        --text-xxl: 1.75rem;
        --text-xl: 1.25rem;
    }

    .grid-container,
    .spec-grid {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: 1;
    }

    .work-title {
        font-size: var(--text-lg);
    }

    .work-row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-md) 0;
        gap: var(--space-xs);
    }

    .work-title-cell,
    .work-sphere-cell,
    .work-status-cell,
    .work-access-cell {
        width: 100%;
        padding: 0;
        display: flex;
        align-items: center;
    }

    .work-sphere-cell::before {
        content: 'stack: ';
        margin-right: 6px;
        color: var(--color-muted);
    }

    .work-status-cell::before {
        content: 'status: ';
        margin-right: 6px;
        color: var(--color-muted);
    }

    .work-access-cell::before {
        content: 'access: ';
        margin-right: 6px;
        color: var(--color-muted);
    }

    .resources-nav {
        gap: var(--space-sm);
    }

    .site-footer-top {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .site-footer-nav {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
}

@media (max-width: 480px) {
    :root {
        --text-xxl: 1.5rem;
        --text-xl: 1.15rem;
    }
}

/* ── Landscape Mobile & Short Viewports ──────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --text-xxl: 1.5rem;
        --text-xl: 1.15rem;
    }

    .container,
    .footer-section {
        padding: max(var(--space-sm), env(safe-area-inset-top)) max(var(--space-md), env(safe-area-inset-right)) max(var(--space-sm), env(safe-area-inset-bottom)) max(var(--space-md), env(safe-area-inset-left));
    }

    .controls-panel {
        top: max(var(--space-sm), env(safe-area-inset-top));
        right: max(var(--space-md), env(safe-area-inset-right));
    }
}

@media print {
    .anim {
        opacity: 1 !important;
        animation: none !important;
    }

    .controls-panel {
        display: none;
    }
}