/* Theme, directory, and controls for Will’s Links. */

:root {
    --font-display: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Light Theme (Default): Soft Matte Slate Plastic */
    --bg: #e7edf5;
    --surface: #f6f8fc;
    --line: #cbd5e1;
    --blue: #244d8a;
    --shadow-light: rgba(255, 255, 255, 0.88);
    --shadow-dark: rgba(160, 175, 195, 0.65);
    --shadow-light-hover: rgba(255, 255, 255, 0.98);
    --shadow-dark-hover: rgba(144, 161, 184, 0.82);

    /* Text & Focus Contrast (WCAG AA Compliant) */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --focus-ring: #2563eb;

    /* Section Accent Fallbacks (matching Airtable spec) */
    --accent-blue: #2b5c8f;
    --accent-green: #2e7d32;
    --accent-rust: #b33927;
    --accent-velvet: #5a2181;
    --accent-amber: #d97706;
}

/* Dark Theme: Soft Matte Obsidian / Charcoal Plastic */
html[data-theme="dark"] {
    --bg: #141920;
    --surface: #1e2632;
    --line: #354255;
    --blue: #a9cdfd;
    --shadow-light: rgba(42, 48, 58, 0.90);
    --shadow-dark: rgba(8, 10, 13, 0.96);
    --shadow-light-hover: rgba(54, 62, 75, 1.0);
    --shadow-dark-hover: rgba(4, 5, 7, 1.0);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --focus-ring: #60a5fa;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.25s ease, color 0.25s ease;
}

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

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
    border-radius: 8px;
}

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--text-primary);
    color: var(--bg);
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    border-radius: 999px;
    z-index: 200;
}

.skip-link:focus {
    left: 20px;
    top: 20px;
}

.wrap {
    max-width: 840px;
    margin: 0 auto;
    padding: 48px 24px 120px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 28px;
    padding: 12px 0 26px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.brand {
    font-size: clamp(3rem, 9vw, 5rem);
    font-weight: 900;
    line-height: .84;
    letter-spacing: -.065em;
    text-transform: uppercase;
}

.brand > span { display: block; }

.brand-label {
    margin-top: 14px;
    font-size: .95rem;
    color: var(--text-secondary);
}

.collection-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 22px;
    align-items: flex-end;
}

.collection-stats > div {
    display: flex;
    flex-direction: column-reverse;
    gap: 5px;
}

.collection-stats dt {
    font-size: .75rem;
    font-weight: 650;
    color: var(--text-secondary);
}

.collection-stats dd {
    color: var(--blue);
    font-size: 1.75rem;
    font-weight: 850;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.collection-stats .updated-stat dd { font-size: .99rem; }

/* ==========================================================================
   Neumorphic Button Mechanics (.neumo-btn)
   ========================================================================== */

.neumo-btn {
    background: var(--bg);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    box-shadow: -4px -4px 10px var(--shadow-light), 4px 4px 10px var(--shadow-dark);
    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.neumo-btn:hover {
    box-shadow: -6px -6px 14px var(--shadow-light-hover), 6px 6px 14px var(--shadow-dark-hover);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.neumo-btn:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    transform: translateY(1px);
}

/* ==========================================================================
   Favorites Strip
   ========================================================================== */

.favorites-section {
    margin-bottom: 36px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
    display: block;
}

.favorites-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.favorite-btn {
    border-radius: 999px;
    padding: 8px 18px;
    min-height: 44px;
    max-width: 100%;
    font-size: 13px;
    font-weight: 700;
}

.fav-icon { object-fit: contain; flex: none; }

.fav-label { overflow-wrap: anywhere; }

.fav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--focus-ring);
    box-shadow: 0 0 6px var(--focus-ring);
}

.btn-arrow {
    font-size: 10px;
    opacity: 0.65;
    transition: transform 0.15s ease;
}

.favorite-btn:hover .btn-arrow {
    transform: translate(2px, -2px);
    opacity: 1;
}

/* ==========================================================================
   Section Panel (Molded Sheet Container)
   ========================================================================== */

.section-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: 0 3px 9px color-mix(in srgb, var(--shadow-dark) 35%, transparent);
}

.section-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 17px;
    min-height: 56px;
    list-style: none;
    cursor: pointer;
    border-radius: 15px;
}

.section-panel[open] > .section-summary { border-radius: 15px 15px 0 0; }
.section-summary::-webkit-details-marker { display: none; }
.section-summary:hover { background: color-mix(in srgb, var(--section-accent, var(--blue)) 7%, transparent); }

.summary-copy { min-width: 0; }
.sec-title { display: block; font-weight: 800; overflow-wrap: anywhere; }
.sec-subtitle { display: block; font-size: .84rem; color: var(--text-secondary); margin-top: 4px; }

.sec-accent-pill {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--section-accent, var(--blue));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--section-accent, var(--blue)) 16%, var(--surface));
}

.sec-glyph-well {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
    font-weight: 750;
}
.sec-glyph::before { content: "+"; }
.section-panel[open] > summary .sec-glyph::before { content: "−"; }

.items-list {
    display: grid;
    padding: 2px 16px 14px;
}

.item-card { padding: 9px 0; min-width: 0; }
.item-card + .item-card { border-top: 1px solid var(--line); }

.item-row-content {
    display: grid;
    gap: 8px;
    align-content: center;
    min-width: 0;
}

.item-title {
    font-size: 1rem;
    font-weight: 780;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.item-description {
    font-size: .91rem;
    line-height: 1.47;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.bookmark-link,
.pill-btn {
    color: var(--text-primary);
    border: 1px solid var(--line);
    background: var(--bg);
    transition: background .16s, transform .16s, box-shadow .16s;
}

.bookmark-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 12px;
    padding: 9px 12px;
    min-height: 44px;
}

.bookmark-label { font-size: .8rem; color: var(--text-secondary); margin-inline-start: .55rem; }
.bookmark-link .pill-arrow { color: var(--text-secondary); flex: none; }

.item-links-inline,
.search-result-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
}

.pill-label { overflow-wrap: anywhere; }
.pill-arrow { flex: none; }
.bookmark-link:hover,
.pill-btn:hover {
    background: color-mix(in srgb, var(--section-accent, var(--blue)) 12%, var(--bg));
    transform: translateY(-1px);
    box-shadow: 0 2px 5px color-mix(in srgb, var(--shadow-dark) 50%, transparent);
}
.bookmark-link:active,
.pill-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px var(--shadow-dark); }

.featured-card {
    display: grid;
    gap: 16px;
    margin-block: 8px;
    padding: 16px;
    border: 1px solid var(--line);
    border-inline-start: 3px solid var(--section-accent, var(--blue));
    border-radius: 14px;
    background: color-mix(in srgb, var(--section-accent, var(--blue)) 8%, var(--surface));
}
.featured-card.has-image { grid-template-columns: minmax(130px, 30%) minmax(0, 1fr); }
.featured-card .item-title { font-size: 1.22rem; }
.featured-card .primary-pill {
    background: var(--text-primary);
    color: var(--surface);
    border-color: transparent;
}
.featured-card .primary-pill:hover { opacity: .86; }
.project-image {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    background: var(--bg);
    border-radius: 9px;
}

/* ==========================================================================
   Floating Bottom Bar (Search & Light/Dark Switch)
   ========================================================================== */

.floating-dock {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    background: var(--bg);
    border-radius: 999px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: -6px -6px 18px var(--shadow-light), 6px 6px 18px var(--shadow-dark);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(8px);
}

.dock-btn {
    border-radius: 999px;
    min-height: 38px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.dock-icon {
    font-size: 13px;
    line-height: 1;
}

.dock-kbd {
    background: var(--bg);
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
    font-weight: 800;
    border-radius: 6px;
    box-shadow: inset 1px 1px 2px var(--shadow-dark), inset -1px -1px 2px var(--shadow-light);
    color: var(--text-secondary);
}

.theme-icon {
    font-size: 13px;
}

/* ==========================================================================
   Search Modal / Popup Dialog
   ========================================================================== */

body.search-open { overflow: hidden; }

.search-modal {
    position: fixed;
    inset: min(12vh, 80px) 0 auto;
    width: min(620px, calc(100% - 24px));
    max-width: none;
    max-height: 82vh;
    max-height: 82dvh;
    margin: 0 auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: 0 16px 60px #0f172a52;
}

.search-modal::backdrop {
    background: #0f172a80;
    backdrop-filter: blur(4px);
}

.search-dialog {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-input-icon {
    font-size: 16px;
    color: var(--text-secondary);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    min-width: 0;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-secondary);
}

.search-close-btn kbd {
    background: var(--bg);
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    font-family: inherit;
    border-radius: 6px;
    box-shadow: -2px -2px 5px var(--shadow-light), 2px 2px 5px var(--shadow-dark);
    display: inline-block;
}

.search-results-container {
    overflow-y: auto;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.search-empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.search-result-item {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: -3px -3px 8px var(--shadow-light), 3px 3px 8px var(--shadow-dark);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.search-result-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.search-result-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

.search-result-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: inset 1px 1px 2px var(--shadow-dark), inset -1px -1px 2px var(--shadow-light);
}


/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

@media (max-width: 640px) {
    .wrap {
        padding: 32px 16px 100px;
    }

    .page-header { gap: 20px; }
    .featured-card.has-image { grid-template-columns: minmax(0, 1fr); }

    .floating-dock {
        bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
