:root {
    /* @link https://utopia.fyi/space/calculator?c=360,18,1.2,1240,21,1.25,6,2,&s=0.75|0.5|0.25,1.5|2|3|4|6,&g=s,l,xl,12 */
    --space-3xs: clamp(0.3125rem, 0.3125rem + 0vw, 0.3125rem);
    --space-2xs: clamp(0.5625rem, 0.5114rem + 0.2273vw, 0.6875rem);
    --space-xs: clamp(0.875rem, 0.8239rem + 0.2273vw, 1rem);
    --space-s: clamp(1.125rem, 1.0483rem + 0.3409vw, 1.3125rem);
    --space-m: clamp(1.6875rem, 1.5597rem + 0.5682vw, 2rem);
    --space-l: clamp(2.25rem, 2.0966rem + 0.6818vw, 2.625rem);
    --space-xl: clamp(3.375rem, 3.1449rem + 1.0227vw, 3.9375rem);
    --space-2xl: clamp(4.5rem, 4.1932rem + 1.3636vw, 5.25rem);
    --space-3xl: clamp(6.75rem, 6.2898rem + 2.0455vw, 7.875rem);
    /* @link https://utopia.fyi/type/calculator?c=360,16,1.2,1240,18,1.25,7,1,&s=0.75|0.5|0.25,1.5|2|3|4|6,&g=s,l,xl,12 */

    --step--1: clamp(0.8333rem, 0.8061rem + 0.1212vw, 0.9rem);
    --step-0: clamp(1rem, 0.9489rem + 0.2273vw, 1.125rem);
    --step-1: clamp(1.2rem, 1.1156rem + 0.375vw, 1.4063rem);
    --step-2: clamp(1.44rem, 1.31rem + 0.5778vw, 1.7578rem);
    --step-3: clamp(1.728rem, 1.536rem + 0.8532vw, 2.1973rem);
    --step-4: clamp(2.0736rem, 1.7983rem + 1.2236vw, 2.7466rem);
    --step-5: clamp(2.4883rem, 2.1018rem + 1.718vw, 3.4332rem);
    --step-6: clamp(2.986rem, 2.4519rem + 2.3737vw, 4.2915rem);
    --step-7: clamp(3.5832rem, 2.8545rem + 3.2386vw, 5.3644rem);

    /* Vars */
    --text: #1D1A15;
    --text-muted: #5C5548;
    --accent: #314B3C;
    --border: #1D1A15;
    --page: #FFF;
    --forms: #FFF;
    --white: #fff;
    --black: #000;

    --prose-width: 767px;
    --control-height: 50px;
}

/* 
    Utility classes
*/

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-xs {
    gap: var(--space-xs);
}

.gap-s {
    gap: var(--space-s);
}

.gap-m {
    gap: var(--space-m);
}

.gap-l {
    gap: var(--space-l);
}

.gap-2xl {
    gap: var(--space-2xl);
}

.pt-l {
    padding-top: var(--space-l);
}

.pt-s {
    padding-top: var(--space-s);
}

.pb-l {
    padding-bottom: var(--space-l);
}

.pt-2xl {
    padding-top: var(--space-2xl);
}

.pb-2xl {
    padding-bottom: var(--space-2xl);
}

.pb-s {
    padding-bottom: var(--space-s);
}

.width-prose {
    max-width: var(--prose-width);
}

.color-muted {
    color: var(--text-muted);
}

/*
    Accessibility
*/
.visually-hidden {
    border: 0;
    clip-path: inset(50%);
    height: 1px;
    margin: 0;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

[x-cloak] {
    display: none !important;
}

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

.skip-link {
    position: absolute;
    left: 0;
    top: 0;
    
    /* Move it off-screen without removing it from the tab order */
    transform: translateY(-120%);
    z-index: 1000;
    transition: transform 0.15s ease-in-out;

    /* Bring it into view when a keyboard user tabs onto it */
    &:focus {
        transform: translateY(0);
        outline: 3px solid var(--accent);
        outline-offset: 2px;
    }
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* 
    Base
*/

body {
    background: var(--page);
    color: var(--text);
    font: var(--step-0)/1.6 system-ui,sans-serif;
    max-width: 1440px;
    margin: 0 auto;
    padding-left: var(--space-s);
    padding-right: var(--space-s);
}

/* 
    Typography
*/
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    line-height: 1.05;
    letter-spacing: -.04em;
    font-weight: 700;
}

.h1 {
    font-size: var(--step-6);
}

.h2 {
    font-size: var(--step-5);
}

.h3 {
    font-size: var(--step-4);
}

.h4 {
    font-size: var(--step-3);
}

.h5 {
    font-size: var(--step-2);
}

/* Uppercase label around the site. */
.title {
    font-weight: 400;
    letter-spacing: normal;
    text-transform: uppercase;
    font-size: var(--step--1);
    color: var(--text-muted);
}

.title--divider {
    margin-top: var(--space-m);
    border-bottom: 1.5px solid var(--border);
    padding-bottom: var(--space-3xs);
    margin-bottom: var(--space-xs);
}

a {
    text-decoration: underline;
    color: var(--text);

    &:hover {
        text-decoration-thickness: 3px;
    }
}

p {
    max-width: var(--prose-width);
}

.page {
    max-width: var(--prose-width);

    > * + * {
        margin-top: var(--space-s);
    }

    > * + h2 {
        margin-top: var(--space-l);
    }

    > h1 {
        font-size: var(--step-6);
    }

    > h2 {
        font-size: var(--step-3);
    }

    ul, ol {
        padding-left: var(--space-s);
    }

    ul {
        list-style: disc;
    }

    ol {
        list-style: decimal;
    }
}


/* 
    Button
*/
.button {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-height);
    padding: 0 16px;
    font-family: inherit;
    font-size: var(--step-0);
    font-weight: 600;
    border-radius: 2px;
    text-decoration: none;
    border: 0;
    cursor: pointer;

    &:hover {
        text-decoration: none;
    }
}

.button--main {
    color: var(--white);
    background-color: var(--black);

    &:hover {
        background-color: var(--accent);
    }
}

.button--outline {
    color: var(--text);
    background-color: transparent;
    border: 1px solid var(--accent);

    &:hover {
        color: var(--white);
        background-color: var(--accent);
    }
}

/* For a button to look like a link */
.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--text);
    text-decoration: underline;
    cursor: pointer;

    &:hover {
        text-decoration-thickness: 3px;
    }
}

.icon-external {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: var(--space-3xs);
    flex-shrink: 0;
    vertical-align: -2px;
    background-color: currentColor;
    -webkit-mask: url("icons/arrow-outward.svg") no-repeat center / contain;
    mask: url("icons/arrow-outward.svg") no-repeat center / contain;
}

/*
    Forms
*/

input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
    flex-grow: 1;
    height: var(--control-height);
    padding: 0 8px;
    background: var(--forms);
    border: 1px solid var(--text);
    border-radius: 2px;
    color: var(--text);
    font-size: var(--step-0);
}

input[type="checkbox"] {
    flex: 0 0 auto;
    accent-color: var(--accent);
    height: 20px;
    width: 20px;
}

/*
    Header
*/

header {
    height: var(--space-xl);
    font-size: var(--step--1);
    margin-bottom: var(--space-l);

    nav {
        a {
            text-decoration: none;

            &:hover {
                text-decoration: underline 3px;
            }
        }
    }

    .site-name {
        font-weight: 750;
        text-decoration: none;
        color: var(--black);
    }
}

/* 
    Modules
*/

.contact-frame {
    background: transparent;
    border: 0;
    display: block;
    min-height: 460px;
    width: 100%;
}

.filters {
    font-size: var(--step--1);
    flex-shrink: 0;
    border-top: 1.5px solid var(--border);

    fieldset {
        padding-bottom: var(--space-xs);
        border-bottom: 1px solid var(--text-muted);
    }

    legend {
        padding: var(--space-s) 0 var(--space-3xs);
    }

    label {
        display: flex;
        align-items: center;
        gap: var(--space-3xs);
        cursor: pointer;
        min-height: var(--control-height);
    }

   /* For filters to hide on mobile, see below */
    summary {
        display: none;
    }

    .filters__option {
        display: flex;
        flex-direction: column;
    }
}

.listing__yarns {
    flex: 1;
    border-top: 1.5px solid var(--border);
}

.yarn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(max(min(100%, 18rem), calc((100% - var(--space-m)) / 2)), 1fr));
    gap: var(--space-xl) var(--space-m);
    padding-top: var(--space-l);
    list-style: none;
}

.status-pill {
    display: inline-block;
    padding: 5px 10px;
    text-transform: uppercase;
    border-radius: 2px;
    font-size: var(--step--1);
}

.status-pill--filled {
    background-color: var(--accent);
    color: var(--white);
}

.status-pill--empty {
    border: 1px solid var(--accent);
}

.browse {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--space-m) var(--space-l);
    border-top: 1.5px solid var(--border);

    > h2 {
        grid-column: 1 / -1;
        margin: 0;
    }

    .browse-group {
        min-width: 0;

        li + li {
            margin-top: var(--space-2xs);
        }
    }
}

.yarn-card {
    position: relative;

    h3 {
        font-size: var(--step-3);
        padding-bottom: var(--space-2xs);

        a::after {
            content: "";
            position: absolute;
            inset: 0;
        }
    }

    .yarn-card__brand {
        text-decoration: none;
        z-index: 1;
        position: relative;
    }
}

.yarn-details__header {
    border-bottom: 1.5px solid var(--border);
}

.yarn-details__facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-l) var(--space-m);
    margin: 0;
}

.yarn-details__facts > div {
    display: flex;
    flex-direction: column;
    gap: var(--space-3xs);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-s);
}

.yarn-details__facts dt,
.yarn-details__facts dd {
    margin: 0;
}

.yarn-details__facts dd {
    font-size: var(--step-2);
}

/* Craft Yarn Council symbol beside the weight, as on a ball band. */
.weight-fact {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.weight-fact__symbol {
    height: 56px;
    width: auto;
    flex-shrink: 0;
}

@media (max-width: 40rem) {
    .yarn-details__facts {
        grid-template-columns: 1fr;
    }

    .yarn-details__body {
        flex-direction: column;
    }

    .listing {
        gap: 0;
        flex-direction: column;
    }

    .filters summary {
        display: list-item;
        line-height: var(--control-height);
        cursor: pointer;
        border-bottom: 1px solid var(--text-muted);
    }

    .filters .filters__option {
        flex-direction: row;
        flex-wrap: wrap;
        column-gap: var(--space-m);
    }

    .listing .listing__yarns {
        border-top: 0;
    }
}
/* Focus lands here after a search so screen readers read the count; it isn't a control. */
.listing__status:focus {
    outline: none;
}
