/* Expo project search page. */

:root {
    --bg: #0a0a0d;
    --bg-soft: #111116;
    --bg-soft-2: #16161d;
    --paper: #f5f3ed;
    --dim: #8b8b93;
    --accent: #3e63ff;
    --accent-hover: #5478ff;
    --line: rgba(245, 243, 237, 0.13);
    --line-strong: rgba(245, 243, 237, 0.24);
    --shadow: rgba(0, 0, 0, 0.55);
    --radius: 0.5rem;
    /* Opaque ground for the sticky site nav, so content scrolls under it. */
    --site-nav-bg: #0a0a0d;
    /* Reveal footer ground: a step lighter than the page, so it reads as a
       separate surface as it is uncovered. */
    --site-footer-bg: #16161d;
    --radius-lg: 0.75rem;

    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--paper);
    /* Body text, 1em desktop / 0.9375em mobile (Digital Guidelines p.3-4).
       Served as Roboto — see brand.css. */
    font-family: var(--font-body);
    font-weight: 400;
    font-size: var(--type-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, fieldset, legend, figure {
    margin: 0;
    padding: 0;
}

fieldset {
    border: 0;
    min-width: 0;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    display: block;
    flex-shrink: 0;
}

::selection {
    background: var(--accent);
    color: var(--paper);
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Page shell */

/* position/z-index so the page scrolls over the fixed reveal footer, which
   sits at z-index 0; the opaque background is what hides it until the end. */
.expo-search {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
    background-color: var(--bg);
    color: var(--paper);
}

.expo-search__sidebar {
    display: none;
}

/* Prevent content width from squeezing the sidebar. */
.expo-search__main {
    display: flex;
    flex: 1 1 0%;
    flex-direction: column;
    min-width: 0;
}

.expo-search__content {
    flex: 1 1 auto;
    padding: 1rem;
}

.expo-search__brand {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--paper);
    margin-bottom: 2rem;
}

.expo-search__brand:hover {
    color: var(--accent);
}

.expo-search__hint {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--dim);
    margin-bottom: 1.5rem;
}

.expo-search__placeholder {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    min-height: 6rem;
    padding: 1rem;
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius);
    background-color: rgba(17, 17, 22, 0.5);
}

.expo-search__placeholder p {
    font-size: 0.875rem;
    text-align: center;
    color: var(--dim);
}

/* Mobile header bar */

/* Sticks beneath the site nav rather than at the top of the viewport, which
   would put the two sticky bars on top of each other. --site-nav-h is measured
   at runtime in expo.js; the fallback covers a first paint. */
.expo-search__mobilebar {
    position: sticky;
    top: var(--site-nav-h, 0px);
    z-index: 20;
    padding: 1rem;
    background-color: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 2px 0 var(--shadow);
}

.expo-search__mobilebar .expo-search__brand {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 1rem;
}

/* Search field */

.search-field {
    position: relative;
}

.search-field--sidebar {
    margin-bottom: 1rem;
}

.search-field__input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 2.5rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--paper);
    background-color: var(--bg-soft-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.search-field__input::placeholder {
    color: var(--dim);
}

.search-field__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

/* Chrome repaints autofilled fields white - force them back. */
.search-field__input:-webkit-autofill,
.search-field__input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--paper);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-soft-2) inset;
    transition: background-color 9999s ease-in-out 0s;
}

.search-field__icon {
    position: absolute;
    left: 0.75rem;
    top: 0.875rem;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--dim);
    opacity: 0.8;
    pointer-events: none;
}

.search-field__voice {
    position: absolute;
    right: 0.5rem;
    top: 0.625rem;
    padding: 0.375rem;
    color: var(--dim);
    background: none;
    border: 0;
    border-radius: 0.375rem;
    cursor: pointer;
}

.search-field__voice svg {
    width: 1.25rem;
    height: 1.25rem;
}

.search-field__voice:hover {
    color: var(--paper);
    background-color: var(--bg-soft-2);
}

.search-field__voice:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Suggestions */

.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 30;
    margin-top: 0.25rem;
    max-height: 24rem;
    overflow-y: auto;
    background-color: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px var(--shadow);
}

.suggestions--mobile {
    max-height: 20rem;
}

.suggestions__group {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dim);
}

.suggestions__item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font: inherit;
    text-align: left;
    color: var(--paper);
    background: none;
    border: 0;
    cursor: pointer;
}

.suggestions__item:hover,
.suggestions__item:focus,
.suggestions__item.is-active {
    background-color: var(--bg-soft-2);
    outline: none;
}

.suggestions__label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--paper);
}

.suggestions__sub {
    display: block;
    font-size: 0.75rem;
    color: var(--dim);
}

/* Category filters */

.filter-group {
    margin-bottom: 1rem;
}

.filter-group__legend {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--paper);
    margin-bottom: 0.25rem;
}

.filter-group__note {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--dim);
    margin-bottom: 0.5rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    cursor: pointer;
}

.filter-option__checkbox {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
    margin: 0;
}

.filter-option__swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.filter-option__label {
    font-size: 0.875rem;
    color: var(--paper);
}

/* Buttons */

.btn {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn--primary {
    color: #fff;
    background-color: var(--accent);
    margin-bottom: 0.75rem;
}

.btn--primary:hover {
    background-color: var(--accent-hover);
}

.btn--ghost {
    color: var(--paper);
    background-color: transparent;
    border-color: var(--line);
    margin-bottom: 1.5rem;
}

.btn--ghost:hover {
    background-color: var(--bg-soft-2);
}

.link-clear {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
}

.link-clear:hover {
    color: var(--accent-hover);
}

/* Section headings */

.expo-section {
    margin-bottom: 2rem;
}

.expo-section__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.expo-section__head--baseline {
    align-items: baseline;
}

/* H2 intro heading: Century Schoolbook Regular, 2.625em/42px desktop,
   1.5em/24px mobile. */
.expo-section__title {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: var(--type-intro-heading);
    color: var(--paper);
}

.expo-section__count {
    font-size: 0.875rem;
    color: var(--dim);
}

.expo-section__scrollhint {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--dim);
}

.expo-section__scrollhint svg {
    width: 0.75rem;
    height: 0.75rem;
    margin-left: 0.25rem;
}

.expo-section__scrollhint--desktop {
    display: none;
}

/* Category tiles */

.category-grid {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0 1rem 1rem;
    margin-left: -1rem;
    margin-right: -1rem;
}

.category-tile {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 1rem;
    min-height: 120px;
    width: 40vw;
    max-width: 160px;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px 0 var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.category-tile:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.category-tile.is-active {
    transform: scale(0.98);
    box-shadow:
        0 0 0 2px var(--bg),
        0 0 0 6px var(--accent),
        0 4px 6px -1px var(--shadow);
}

.category-tile__image {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.category-tile__scrim {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.55) 100%);
}

.category-tile__label {
    position: relative;
    z-index: 10;
    font-family: var(--font-heading);
    font-size: var(--type-featured-heading);
    font-weight: 400;
    letter-spacing: 0.025em;
    text-align: center;
    overflow-wrap: break-word;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.category-tile--image .category-tile__label {
    color: #ffffff;
}

/* Project cards */

.project-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.project-grid__empty {
    grid-column: 1 / -1;
    padding: 4rem 0;
    text-align: center;
    color: var(--dim);
}

.project-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px 0 var(--shadow);
    transition: box-shadow 0.2s;
}

.project-card:hover {
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.project-card__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-bottom: 1px solid var(--line);
    background-color: var(--bg-soft-2);
    background-image: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 13px,
        rgba(245, 243, 237, 0.022) 13px,
        rgba(245, 243, 237, 0.022) 14px
    );
}

.project-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.project-card:hover .project-card__image {
    transform: scale(1.05);
}

.project-card__placeholder {
    width: 3rem;
    height: 3rem;
    color: var(--dim);
    opacity: 0.8;
}

.project-card__body {
    display: flex;
    flex: 1 1 0%;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: 1rem;
}

.project-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Badge colours are paired inline for contrast. */
.project-card__tag {
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 9999px;
}

/* H2 featured box heading: Century Schoolbook Regular, 1.5em/24px desktop,
   1.3125em/21px mobile. */
.project-card__title {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: var(--type-featured-heading);
    line-height: 1.25;
    color: var(--paper);
    margin-bottom: 0.25rem;
}

.project-card__meta {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--dim);
    margin-bottom: 0.5rem;
}

.project-card__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--paper);
    opacity: 0.85;
}

/* Tablet and up */

@media (min-width: 768px) {
    .expo-search {
        flex-direction: row;
    }

    .expo-search__sidebar {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        width: 16rem;
        height: 100vh;
        height: 100svh;
        padding: 1.5rem;
        overflow-y: auto;
        background-color: var(--bg-soft);
        border-right: 1px solid var(--line);
        box-shadow: 0 1px 2px 0 var(--shadow);
    }

    .expo-search__mobilebar {
        display: none;
    }

    .expo-search__content {
        padding: 2rem;
    }

    .expo-search__filters {
        display: flex;
        flex: 1 1 0%;
        flex-direction: column;
        min-height: 0;
    }

    .expo-section__scrollhint--mobile {
        display: none;
    }

    .expo-section__scrollhint--desktop {
        display: flex;
    }

    /* Replace the mobile scroll strip with two rows. */
    .category-grid {
        display: grid;
        grid-auto-flow: column;
        grid-template-rows: repeat(2, 1fr);
        grid-auto-columns: calc((100% - 2rem) / 3);
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .category-tile {
        width: auto;
        max-width: none;
        min-height: 96px;
    }

    .category-tile__label {
        font-size: 1.125rem;
    }

    .project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project-card__excerpt {
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
}

@media (min-width: 1024px) {
    .expo-search__sidebar {
        width: 20rem;
    }

    .project-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .project-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Active voice search */
.search-field__voice.is-listening {
    color: #ef4444;
    animation: search-field-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes search-field-pulse {
    50% { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
    .search-field__voice.is-listening {
        animation: none;
    }
}
