/*
    Shared defaults, visual components, and navigation.

    Layouts live in layout.css. Each component owns its padding and internal
    rhythm; page containers own the space between components.
*/
@layer reset {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }
    body,
    h1,
    h2,
    h3,
    h4,
    p,
    figure,
    dl,
    dd {
        margin: 0;
    }
    img,
    svg {
        display: block;
        max-width: 100%;
    }
    button,
    input,
    textarea {
        font: inherit;
    }
    button,
    a,
    input {
        -webkit-tap-highlight-color: transparent;
    }
}

@layer base {
    html {
        background: var(--page-background);
        scroll-padding-top: calc(var(--navbar-height) + 1.5rem);
    }

    body {
        min-height: 100svh;
        display: flex;
        flex-direction: column;
        color: var(--text-color);
        font-family: var(--font-family);
        font-size: var(--base-font-size);
        line-height: var(--base-line-height);
        letter-spacing: 0;
    }

    main {
        flex: 1;
    }
    h1,
    h2,
    h3,
    h4 {
        line-height: 1.2;
        font-weight: 600;
        text-wrap: balance;
    }
    h2 {
        font-size: var(--type-section);
    }
    h3 {
        font-size: var(--type-card);
    }
    p {
        text-wrap: pretty;
    }
    a {
        color: inherit;
        text-underline-offset: 0.22em;
        text-decoration-thickness: 1px;
    }
    a:hover {
        text-decoration-color: var(--gold-color-dark);
    }
    a,
    p,
    h1,
    h2,
    h3,
    dd {
        overflow-wrap: anywhere;
    }
    img {
        height: auto;
    }
    button {
        cursor: pointer;
    }
    :target {
        scroll-margin-top: 1.5rem;
    }
    ::selection {
        background: var(--accent-background);
        color: var(--text-color);
    }
}

@layer components {
    /* Text roles. Small labels never compete with the actual page heading. */
    .section-label,
    .page-kicker {
        color: var(--brand-color);
        font-size: var(--type-meta);
        font-weight: 600;
    }

    .page-header {
        position: relative;
        display: grid;
        gap: var(--space-medium);
        padding-bottom: 2.5rem;
        border-bottom: 1px solid var(--border-medium);
    }

    /* A short warm accent sits on the existing divider without changing its
       spacing. Keep the full-width rule neutral so gold stays a small detail. */
    .page-header::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: -1px;
        width: 3rem;
        height: 2px;
        background: var(--gold-color);
    }

    .page-title {
        color: var(--brand-color-dark);
        font-size: var(--type-title);
        line-height: 1.08;
        max-width: 25ch;
    }

    .page-deck {
        max-width: 58ch;
        color: var(--text-muted);
    }
    .page-actions {
        margin-top: var(--space-small);
    }
    .outline-link-row {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-medium);
    }

    .outline-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 2.75rem;
        padding: 0.5rem 1rem;
        border: 1px solid var(--border-medium);
        border-radius: var(--border-radius);
        font-size: var(--type-small);
        font-weight: 500;
        text-decoration: none;
        background: var(--surface-background);
        transition:
            border-color 150ms ease,
            background-color 150ms ease;
    }

    .outline-link:hover {
        border-color: var(--brand-color);
        background: var(--gold-background);
    }

    /* One surface and one padding rule for boxed records. Layout-specific
       variants below change only their internal organization or surface tone. */
    .content-card,
    .directory-link,
    .directory-row,
    .project-menu-card,
    .contact-card {
        background: var(--surface-background);
        border: 1px solid var(--border-soft);
        border-radius: var(--border-radius);
        padding: var(--content-card-padding);
    }

    .content-card-accent {
        background: var(--accent-background);
        border-color: var(--border-medium);
    }

    /* Explicit margins avoid collapsed heading margins looking like extra
       top padding. Spacing belongs to this region, not to all article tags. */
    .content-card > * + *,
    .content-block > * + *,
    .research-card-text > * + * {
        margin-top: var(--content-item-gap);
    }

    .content-card > p:not(.section-label),
    .content-block > p:not(.section-label) {
        color: var(--text-muted);
    }

    .directory-list {
        display: grid;
        gap: 0.75rem;
        margin-top: 1.25rem;
    }
    .directory-link {
        display: grid;
        gap: var(--space-small);
        text-decoration: none;
    }
    .directory-link strong {
        font-size: var(--type-card);
        font-weight: 500;
        line-height: 1.35;
    }
    .directory-link span {
        color: var(--text-muted);
        font-size: var(--type-body-small);
    }
    .directory-link:hover {
        border-color: var(--brand-color);
    }

    /* A person record keeps all four HTML slots. Empty content contributes no
       visual spacing; Projects stays on the same surface as the biography.
       Role and Projects labels need weight to separate them from regular links;
       making every secondary line equally quiet flattened this hierarchy. */
    .person-details {
        min-width: 0;
    }
    .person-name {
        font-size: 1.625rem;
        line-height: 1.2;
    }
    .person-name strong {
        font-weight: 600;
    }
    .person-title {
        margin-top: 0.35rem;
        color: var(--text-strong-muted);
        font-size: var(--type-small);
        font-weight: 600;
    }
    .person-description {
        margin-top: 1.1rem;
        color: var(--text-muted);
        font-size: var(--type-body-small);
        max-width: 72ch;
    }
    .person-description:empty {
        display: none;
    }
    .person-projects {
        margin-top: 1.3rem;
    }
    .person-projects strong {
        color: var(--text-strong-muted);
        font-size: var(--type-body-small);
        font-weight: 600;
    }
    .person-projects ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem 1.25rem;
        padding: 0;
        margin: 0.35rem 0 0;
        list-style: none;
    }

    /* Ordinary content links stay neutral, lighter, and smaller than titles.
       Underlines retain an affordance without turning links into buttons. */
    .person-projects a,
    .news-post-link,
    .contact-list a {
        color: var(--text-strong-muted);
        font-weight: 400;
        text-decoration: underline;
        text-decoration-color: var(--link-underline-muted);
        transition: text-decoration-color 150ms ease;
    }

    .person-projects a {
        font-size: var(--type-small);
        text-decoration: none;
    }
    .person-projects a:hover {
        text-decoration: underline;
    }
    .person-projects a:hover,
    .news-post-link:hover,
    .contact-list a:hover {
        text-decoration-color: var(--gold-color-dark);
    }

    /* Markers align with the first text line, including wrapped items. */
    .service-list {
        display: grid;
        gap: var(--space-medium);
        padding: 0;
        list-style: none;
    }
    .service-list li {
        display: flex;
        align-items: flex-start;
        gap: 0.8rem;
        color: var(--text-muted);
        font-size: var(--type-body-small);
    }
    .service-list li::before {
        content: "";
        flex: 0 0 0.45rem;
        height: 0.45rem;
        margin-top: 0.65em;
        border: 1px solid var(--brand-color);
        /* A tiny gold center adds warmth; the maroon edge defines the marker. */
        background: var(--gold-color);
    }

    /* Whole-card links are used only when the card has one destination. */
    .research-areas {
        display: grid;
        gap: 1.25rem;
        margin-top: 1.5rem;
    }
    .research-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 38%;
        overflow: hidden;
        border: 1px solid var(--border-medium);
        border-radius: var(--border-radius);
        background: var(--surface-light);
        text-decoration: none;
        transition:
            border-color 150ms ease,
            box-shadow 150ms ease;
    }

    .research-card:hover {
        border-color: var(--brand-color);
        box-shadow: 0 0 0 1px var(--brand-color);
    }
    .research-card-text {
        padding: var(--content-card-padding);
    }
    .research-card-text h3 {
        font-weight: 500;
    }
    .research-card-text p {
        font-size: var(--type-body-small);
        color: var(--text-muted);
        line-height: 1.55;
    }
    .research-card-media img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Each project card has one destination and one keyboard focus stop.
       Contributor names are plain text; never nest links inside the card. */
    .project-menu {
        display: grid;
        gap: var(--space-medium);
    }
    .project-menu-card {
        display: block;
        background: var(--surface-light);
        border-left: 3px solid var(--gold-color);
        text-decoration: none;
    }

    .project-menu-card:hover {
        border-color: var(--brand-color);
        /* Keep the gold tab distinct while the other edges signal hover. */
        border-left-color: var(--gold-color);
    }
    .project-menu-title {
        font-size: 1.5rem;
        font-weight: 500;
        line-height: 1.3;
    }
    /* These spans previously relied on grid-item layout. Keep separate text
       groups now that the numbered grid has been removed. */
    .project-menu-contributors,
    .project-menu-summary {
        display: block;
    }
    .project-menu-contributors {
        margin-top: var(--space-small);
        font-size: var(--type-meta);
        color: var(--text-subtle);
    }
    .project-menu-summary {
        margin-top: 1.1rem;
        color: var(--text-muted);
        font-size: var(--type-body-small);
        max-width: 68ch;
    }

    /* Project search queries the same read-only store used for rendering. */
    .directory-tools {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-medium);
        margin-block: 1.75rem;
    }
    .directory-search {
        display: grid;
        gap: 0.35rem;
        width: min(100%, 25rem);
        font-size: var(--type-meta);
        color: var(--text-muted);
    }
    .directory-search input,
    .contact-form input,
    .contact-form textarea {
        width: 100%;
        min-height: 3rem;
        padding: 0.65rem 0.9rem;
        border: 1px solid var(--border-medium);
        border-radius: var(--border-radius);
        background: var(--surface-light);
        color: var(--text-color);
        font-size: var(--type-small);
    }
    /* Browser-default placeholder grays vary; use the same readable metadata
       color as the count and contributor text, without extra transparency. */
    .directory-search input::placeholder {
        color: var(--text-subtle);
        opacity: 1;
    }
    .directory-count {
        font-size: var(--type-meta);
        color: var(--text-subtle);
        white-space: nowrap;
    }
    .directory-empty {
        padding-block: 2rem;
        color: var(--text-muted);
    }

    /* Feed entries use whitespace and one separator, not nested card shells. */
    .news-post {
        display: grid;
        gap: 2rem;
        padding-block: 2.5rem;
        border-bottom: 1px solid var(--border-soft);
    }
    .news-post:first-child {
        padding-top: 0;
    }
    .news-post-with-media {
        grid-template-columns: 15rem minmax(0, 1fr);
    }
    .news-post-header {
        display: grid;
        gap: 0.65rem;
    }
    .news-post h2 {
        font-size: 1.625rem;
        font-weight: 500;
        max-width: 36ch;
    }
    .news-post-meta {
        color: var(--text-subtle);
        font-size: var(--type-meta);
    }
    .news-post-body > * + * {
        margin-top: var(--space-medium);
    }
    .news-post-body > p {
        color: var(--text-muted);
        font-size: var(--type-body-small);
        max-width: 66ch;
    }
    .news-post-link {
        display: inline-block;
        font-size: var(--type-small);
    }
    .news-post-thumbnail {
        align-self: start;
    }
    .news-post-thumbnail img {
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
    }
    .news-video-preview {
        display: block;
        max-width: 44rem;
        text-decoration: none;
    }
    .news-video-preview img {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: cover;
    }
    .news-video-preview span {
        display: grid;
        gap: 0.2rem;
        padding-top: 0.9rem;
    }
    .news-video-preview strong {
        font-size: var(--type-body-small);
        font-weight: 500;
    }
    .news-video-preview small {
        color: var(--text-muted);
        font-size: var(--type-meta);
    }
    .news-video-preview:hover strong {
        text-decoration: underline;
        /* This is an image-and-caption link; gold is for text-only links. */
        text-decoration-color: var(--brand-color);
    }

    .contact-list {
        display: grid;
        gap: 1.75rem;
    }
    .contact-list > div {
        display: grid;
        grid-template-columns: 11rem minmax(0, 1fr);
        gap: 2rem;
    }
    .contact-list dt {
        color: var(--text-muted);
        font-size: var(--type-small);
    }
    .contact-list dd {
        min-width: 0;
    }

    /* Inquiry fields share the search control styling and stack at every width. */
    .contact-message > * + * {
        margin-top: var(--space-medium);
    }
    .contact-form {
        display: grid;
        max-width: 42rem;
        gap: var(--space-small);
    }
    .contact-form label:not(:first-child) {
        margin-top: var(--space-medium);
    }
    .contact-form label,
    .contact-help {
        font-size: var(--type-meta);
        color: var(--text-muted);
    }
    .contact-form textarea {
        resize: vertical;
        min-height: 10rem;
    }
    .contact-form button {
        justify-self: start;
        margin-top: var(--space-medium);
        color: var(--text-color);
    }
    .contact-form button:disabled {
        cursor: not-allowed;
        color: var(--text-muted);
        background: var(--surface-background);
        border-color: var(--border-soft);
    }

    /* Navigation stays in document flow. Explicit active state also tells
       readers which page they are on after following a deep link. */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--navbar-background);
        border-bottom: 1px solid var(--border-medium);
    }
    .navbar {
        display: flex;
        align-items: center;
        gap: var(--space-medium);
        min-height: var(--navbar-height);
        padding-inline: var(--page-inset);
    }
    .site-brand {
        display: inline-flex;
        align-items: center;
        gap: 0.75rem;
        flex-shrink: 0;
        text-decoration: none;
        font-size: 1.25rem;
        font-weight: 600;
    }
    /* Keep the brand treatment consistent in both ends of the page. */
    .site-brand,
    .site-footer strong {
        text-transform: uppercase;
    }
    .site-mark {
        width: 3rem;
        height: 3rem;
        display: grid;
        place-items: center;
        /* The logo frame remains maroon; gold belongs to secondary accents. */
        border: 1px solid var(--brand-color);
        background: var(--surface-background);
    }
    .site-mark img {
        width: 100%;
        transform: translateX(-0.08rem);
    }
    .nav-links {
        display: flex;
        align-items: center;
        gap: 1.75rem;
        margin: 0 0 0 auto;
        padding: 0;
        list-style: none;
    }
    .nav-item {
        position: relative;
    }
    .nav-menu-link,
    .nav-submenu a {
        display: block;
        padding-block: 0.75rem;
        font-size: var(--type-body-small);
        font-weight: 500;
        text-decoration: none;
        white-space: nowrap;
    }
    .nav-menu-link:hover,
    .nav-submenu a:hover {
        color: var(--brand-color-dark);
    }
    .nav-menu-link[aria-current],
    .nav-menu-link[data-current] {
        text-decoration: underline;
        text-decoration-color: var(--brand-color);
        text-underline-offset: 0.5rem;
    }
    .nav-item > .nav-menu-link::after {
        content: "";
        display: inline-block;
        width: 0.4rem;
        height: 0.4rem;
        margin: 0 0 0.2rem 0.55rem;
        border-right: 1px solid;
        border-bottom: 1px solid;
        transform: rotate(45deg);
    }
    .nav-submenu {
        display: none;
        position: absolute;
        top: 100%;
        left: -1rem;
        min-width: 13rem;
        width: max-content;
        margin: 0;
        padding: 0.5rem 1rem;
        list-style: none;
        border: 1px solid var(--border-medium);
        background: var(--surface-background);
    }
    .nav-item:hover .nav-submenu,
    .nav-item:focus-within .nav-submenu {
        display: block;
    }
    .nav-submenu a {
        font-size: var(--type-small);
        font-weight: 400;
    }

    /* Preserve the accepted quiet icon geometry and generous touch target. */
    .nav-menu-button {
        display: none;
        position: relative;
        flex: 0 0 2.75rem;
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: transparent;
    }
    .nav-menu-button:hover {
        background: var(--gold-background);
    }
    .nav-menu-button span {
        position: absolute;
        left: 0.75rem;
        width: 1.25rem;
        height: 2px;
        background: var(--brand-color);
        transition:
            transform 150ms ease,
            opacity 150ms ease;
    }
    .nav-menu-button span:nth-child(1) {
        top: 0.95rem;
    }
    .nav-menu-button span:nth-child(2) {
        top: 1.325rem;
    }
    .nav-menu-button span:nth-child(3) {
        top: 1.7rem;
    }
    .nav-menu-button[data-menu-open="true"] span:nth-child(1) {
        transform: translateY(0.375rem) rotate(45deg);
    }
    .nav-menu-button[data-menu-open="true"] span:nth-child(2) {
        opacity: 0;
    }
    .nav-menu-button[data-menu-open="true"] span:nth-child(3) {
        transform: translateY(-0.375rem) rotate(-45deg);
    }

    .site-footer {
        display: flex;
        justify-content: space-between;
        align-items: start;
        gap: 2rem;
        padding: 2.5rem var(--page-inset);
        border-top: 1px solid var(--border-medium);
        background: var(--footer-background);
        font-size: var(--type-small);
    }
    .site-footer strong {
        font-weight: 600;
    }
    .site-footer p {
        margin-top: 0.4rem;
        color: var(--text-muted);
        font-size: var(--type-meta);
    }
    .site-footer nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem 1.5rem;
    }
    .site-footer a {
        text-decoration: none;
    }
    .site-footer a:hover {
        text-decoration: underline;
        /* The shorthand above resets the decoration color; set it afterward. */
        text-decoration-color: var(--gold-color-dark);
    }
}

@layer state {
    /* Author grid/flex rules otherwise override the browser's hidden default. */
    [hidden] {
        display: none;
    }
    :focus-visible {
        outline: 2px solid var(--brand-color);
        outline-offset: 4px;
    }
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation: none;
            transition: none;
            scroll-behavior: auto;
        }
    }
}
