/* Dark palette borrowed from My Job Search (warm charcoal) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #262624;
    --bar-bg: #3d1e24;
    --bar-text: #faf9f5;
    --text: #faf9f5;
    --soft: #c9c7bd;
    --muted: #9f9d94;
    --marker: #6e6c66;
    --link: #faf9f5;
    --rule: #3e3d39;
    --accent: #faf9f5;
    --photo-bg: #30302e;
}

body { transition: background-color 0.2s ease, color 0.2s ease; }

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s;
}

.theme-toggle:hover,
.theme-toggle:focus-visible { opacity: 1; }

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

/* Type scale matched to Liza Wood's site */
body { font-size: 17px; line-height: 1.5; }
.navbar { font-size: 17px; }
.navbar .brand { font-size: 21.25px; }
h1.title, h1.name, .profile h1, .case h1 { font-size: 42.5px; font-weight: 600; line-height: 1.2; }
h2.group, h2.section, .case h2 { font-size: 24.84px; font-weight: 600; line-height: 1.2; }
.item h3 { font-size: 17px; font-weight: 500; }
.case h3 { font-size: 17px; font-weight: 600; }
.case .lede { font-size: 21.25px; }
.item .stack, .toc, .toc h2 { font-size: 14.875px; }
.project-links a { font-size: 15px; }

@media (max-width: 640px) {
    h1.title, h1.name, .profile h1, .case h1 { font-size: 34px; }
    .navbar .brand { font-size: 18px; }
}

/* Motion: short, subtle, off for reduced motion */
@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
    ::view-transition-old(root),
    ::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: cubic-bezier(.2, 0, 0, 1); }
    .navbar { view-transition-name: navbar; }

    .motion .reveal {
        opacity: 0;
        transform: translateY(12px);
        transition: opacity 0.55s cubic-bezier(.16, 1, .3, 1), transform 0.55s cubic-bezier(.16, 1, .3, 1);
        transition-delay: var(--d, 0ms);
    }
    .motion .reveal.in { opacity: 1; transform: none; }

    .lightbox:not([hidden]) { animation: lb-fade 0.2s ease-out; }
    .lightbox:not([hidden]) figure { animation: lb-zoom 0.3s cubic-bezier(.16, 1, .3, 1); }
    .lightbox img.swap { animation: lb-swap 0.25s ease-out; }
    .theme-toggle.turned .icon { animation: icon-turn 0.4s cubic-bezier(.16, 1, .3, 1); }
}

@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lb-zoom { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes lb-swap { from { opacity: 0.35; } to { opacity: 1; } }
@keyframes icon-turn { from { opacity: 0; transform: rotate(-90deg) scale(0.6); } to { opacity: 1; transform: none; } }

/* Keep the top bar on one line on small phones */
.navbar .brand { white-space: nowrap; }
@media (max-width: 430px) {
    .navbar { padding: 0 14px; }
    .navbar .brand { font-size: 16.5px; margin-right: 6px; }
    .navbar .links { gap: 0; }
    .navbar .links a { padding: 8px 7px; font-size: 15px; }
}

/* ---------- Top bar: underline on hover and current page, shadow once scrolled ---------- */
.navbar { transition: box-shadow 0.2s ease; }
.navbar.scrolled { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14); }
.navbar .links a { position: relative; }
.navbar .links a::after {
    content: "";
    position: absolute;
    left: 10px; right: 10px; bottom: 4px;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s cubic-bezier(.2, 0, 0, 1);
}
.navbar .links a:hover::after,
.navbar .links a[aria-current="page"]::after { transform: scaleX(1); }
.navbar .links a:focus-visible { outline: 1.5px solid currentColor; outline-offset: -2px; border-radius: 4px; }

.menu-btn { display: none; }

/* Phones: name on the left, theme and menu buttons on the right, links in a drop-down panel */
@media (max-width: 575px) {
    .navbar .tools { margin-left: auto; align-items: center; gap: 10px; }

    .menu-btn {
        display: block;
        position: relative;
        width: 36px; height: 36px;
        margin-right: -8px;
        padding: 0;
        border: none;
        background: none;
        color: inherit;
        cursor: pointer;
    }
    .menu-btn span {
        position: absolute;
        top: 50%; left: 9px;
        width: 18px; height: 1.5px;
        margin-top: -0.75px;
        border-radius: 1px;
        background: currentColor;
        transition: transform 0.3s cubic-bezier(.2, 0, 0, 1);
    }
    .menu-btn span:first-child { transform: translateY(-3.5px); }
    .menu-btn span:last-child { transform: translateY(3.5px); }
    .menu-open .menu-btn span:first-child { transform: rotate(45deg); }
    .menu-open .menu-btn span:last-child { transform: rotate(-45deg); }

    .navbar .links {
        position: absolute;
        top: 100%; left: 0; right: 0;
        flex-direction: column;
        gap: 0;
        padding: 6px 0 16px;
        background: var(--bar-bg);
        box-shadow: 0 14px 24px rgba(0, 0, 0, 0.16);
        visibility: hidden;
        opacity: 0;
        transform: translateY(-6px);
        transition: opacity 0.2s ease, transform 0.25s cubic-bezier(.2, 0, 0, 1), visibility 0s 0.25s;
    }
    .navbar.menu-open .links {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 0.2s ease, transform 0.25s cubic-bezier(.2, 0, 0, 1);
    }
    .navbar .links a {
        display: block;
        padding: 11px 16px;
        font-size: 19px;
        opacity: 0.75;
    }
    .navbar .links a[aria-current="page"] { opacity: 1; }
    .navbar .links a::after { left: 16px; right: auto; width: 22px; bottom: 6px; }
    .navbar .links a:hover::after { transform: scaleX(0); }
    .navbar .links a[aria-current="page"]::after { transform: scaleX(1); }
}
@media (max-width: 430px) {
    .navbar .links a { padding: 11px 14px; font-size: 19px; }
    .navbar .links a::after { left: 14px; }
}
