/*
 * Music Instinct design system.
 * One stylesheet, no build step. Rules and markup: design/README.md.
 * Live reference: design/components.html.
 */

/* Fonts ------------------------------------------------------------------ */

@font-face {
    font-family: "Hanken Grotesk";
    src: url("fonts/hanken-grotesk-normal-latin.woff2") format("woff2");
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Hanken Grotesk";
    src: url("fonts/hanken-grotesk-italic-latin.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

/* Tokens ----------------------------------------------------------------- */

:root {
    --ink: #141414;
    --paper: #ffffff;
    --dim: #666666;
    --rule: #dcdcdc;
    --plate: #efefec;
    --error: #b3261e;
    --error-ground: #fcefee;

    /* Overridden per product with data-product. */
    --product: var(--ink);
    --product-ink: var(--paper);

    --font: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
    --text-small: 0.8125rem;
    --text-body: 0.9375rem;
    --text-lead: 1.125rem;
    --text-figure: 1.625rem;
    --text-title: 1.875rem;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 40px;
    --space-8: 56px;
    --space-9: 80px;

    --page-max: 1360px;
    --gutter: clamp(16px, 3vw, 40px);
    --column-gap: 24px;
    --measure: 40em;
    --control-height: 40px;
    --header-height: 64px;
    /* Lines menu panels up with the page content at any window width. */
    --panel-inset: max(var(--gutter), (100% - var(--page-max)) / 2 + var(--gutter));
}

[data-product="mi03"] { --product: #ffe800; --product-ink: var(--ink); }
[data-product="mix-rebalance"] { --product: #00bcf2; --product-ink: var(--ink); }
[data-product="handpan"] { --product: #2e3034; --product-ink: var(--paper); }

/* Base ------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    color: var(--ink);
    background: var(--paper);
    font: var(--text-body) / 1.5 var(--font);
    font-variant-numeric: tabular-nums;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--gutter) var(--space-9);
}

::selection { background: var(--product); color: var(--product-ink); }

h1, h2, h3, h4 { margin: 0; font-size: inherit; font-weight: 500; line-height: 1.3; }
p, ul, ol, dl, dd, figure, blockquote, fieldset { margin: 0; }
ul, ol { padding: 0; }
fieldset { padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
b, strong { font-weight: 600; }
small { font-size: var(--text-small); }
img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

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

/* Utilities -------------------------------------------------------------- */

.vh {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: var(--space-4);
    padding: var(--space-2) var(--space-3);
    color: var(--paper);
    background: var(--ink);
}
.skip-link:focus { top: var(--space-4); }

.lead { font-size: var(--text-lead); line-height: 1.4; }
.meta { font-size: var(--text-small); color: var(--dim); }
.dim { color: var(--dim); }

.link-button {
    padding: 0;
    color: inherit;
    background: none;
    border: 0;
    text-decoration: underline;
    text-decoration-color: var(--rule);
    text-underline-offset: 0.2em;
    cursor: pointer;
}
.link-button:hover { text-decoration-color: currentColor; }

/* Site header ------------------------------------------------------------
 * Menus use the browser's popover attribute: they open, close on Escape and
 * close on an outside click with no script. Panels sit in the top layer, so
 * they are placed against the page, directly under the header.
 */

.site-header {
    display: flex;
    align-items: center;
    gap: var(--space-7);
    height: var(--header-height);
    border-bottom: 1px solid var(--ink);
}

.site-header__brand {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    text-decoration: none;
}
.site-header__brand img { width: 30px; }

.site-header__menu-button { display: none; }

/* The nav is itself a popover so it can fold into the phone menu. On wide
   screens it is shown in the header bar, with the popover defaults undone. */
.site-nav {
    position: static;
    inset: auto;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    color: inherit;
    background: none;
    border: 0;
}

.site-nav__list { list-style: none; display: flex; align-items: center; gap: var(--space-5); }
.site-nav__list a { text-decoration: none; }
.site-nav__list > li > a:hover,
.site-nav__list > li > a[aria-current="page"] { text-decoration: underline; text-decoration-color: currentColor; }

.site-nav__toggle,
.site-header__menu-button {
    align-items: center;
    gap: 6px;
    padding: 0;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}
.site-nav__toggle { display: inline-flex; }
.site-nav__toggle:hover { text-decoration: underline; }
.site-nav__chevron { width: 10px; height: 6px; }
li:has(> .site-nav__panel:popover-open) > .site-nav__toggle .site-nav__chevron,
.site-header:has(> .site-nav:popover-open) > .site-header__menu-button .site-nav__chevron { rotate: 180deg; }

.site-nav__heading { display: none; }

.site-nav__panel {
    position: absolute;
    inset: var(--header-height) auto auto auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    color: var(--ink);
    background: var(--paper);
    border: 0;
}

.products-menu {
    right: 0;
    left: 0;
    width: auto;
    padding: var(--space-5) var(--panel-inset) var(--space-7);
}
.products-menu::after {
    content: "";
    position: absolute;
    right: var(--panel-inset);
    bottom: 0;
    left: var(--panel-inset);
    border-bottom: 1px solid var(--ink);
}
.products-menu__list { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.site-nav .products-menu__item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    column-gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--rule);
    text-decoration: none;
}
.products-menu__item .mark { grid-row: span 2; }
.products-menu__name { font-weight: 500; }
.products-menu__text { color: var(--dim); }
.products-menu__item:hover .products-menu__name,
.products-menu__item[aria-current="page"] .products-menu__name { text-decoration: underline; }

.account-menu {
    right: var(--panel-inset);
    width: 18em;
    padding: var(--space-4);
    border: 1px solid var(--ink);
    border-top: 0;
}
.account-menu > .meta { margin-bottom: var(--space-3); }
.account-menu__list { list-style: none; display: grid; gap: var(--space-2); }

/* Site footer ------------------------------------------------------------ */

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-2) var(--space-5);
    padding-top: var(--space-5);
    font-size: var(--text-small);
    color: var(--dim);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Row: the sheet's one layout. Label on the left, content on the right. -- */

.row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--column-gap);
    padding: var(--space-6) 0 var(--space-8);
    border-bottom: 1px solid var(--rule);
}
.row__label { grid-column: 1 / 4; font-weight: 400; color: var(--dim); }
.row__label .mark { display: inline-block; margin-right: var(--space-2); vertical-align: -3px; }
.row__body { grid-column: 4 / -1; min-width: 0; }
.row__body > * + * { margin-top: var(--space-4); }
.row__body > p { max-width: var(--measure); }
.row--wide .row__body { grid-column: 1 / -1; }

/* Intro: the top of a page. Text, optional media, optional facts. ------- */

.intro {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--column-gap);
    row-gap: var(--space-7);
    align-items: start;
    padding: var(--space-7) 0 var(--space-8);
    border-bottom: 1px solid var(--rule);
}
.intro__text { grid-column: 1 / 5; }
.intro:not(:has(.intro__media)) .intro__text { grid-column: 1 / 9; }
.intro__media { grid-column: 5 / -1; }
.intro > .facts { grid-column: 1 / -1; }

.intro__title { font-size: var(--text-title); line-height: 1.15; letter-spacing: -0.01em; }
.intro__tagline { margin-top: var(--space-2); font-size: var(--text-lead); line-height: 1.35; }
.intro__lede { margin-top: var(--space-4); color: var(--dim); }
.intro__text > .mark { margin-bottom: var(--space-4); }
.intro__text > .actions { margin-top: var(--space-6); }

/* Plate: grey ground for screenshots and product shots. ----------------- */

.plate { background: var(--plate); padding: clamp(16px, 5%, 56px); }
.plate img { margin-inline: auto; }
.plate--fixed { position: relative; aspect-ratio: 4 / 3; padding: 0; }
.plate--fixed img { position: absolute; inset: 10%; width: 80%; height: 80%; object-fit: contain; }

/* Mark: a product's own icon. ------------------------------------------- */

.mark { flex: none; width: 16px; height: 16px; object-fit: contain; }
.mark--md { width: 24px; height: 24px; }
.mark--lg { width: 48px; height: 48px; }

/* Facts: four short label/value pairs in a strip. ----------------------- */

.facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
    padding-top: var(--space-3);
    border-top: 1px solid var(--rule);
}
.facts dt { color: var(--dim); }

/* Spec: term and description rows between hairlines. -------------------- */

.spec > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--space-5);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--rule);
}
.spec > div:last-child { border-bottom: 1px solid var(--rule); }
.spec--soft dd { color: var(--dim); }

/* Buttons ---------------------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: 0 18px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--paper);
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: #3a3a3a; border-color: #3a3a3a; }
.button--secondary { color: var(--ink); background: transparent; }
.button--secondary:hover { background: var(--plate); border-color: var(--ink); }
.button--danger { background: var(--error); border-color: var(--error); }
.button--danger:hover { background: #8c1d17; border-color: #8c1d17; }
.button:disabled { opacity: 0.4; cursor: not-allowed; }
/* Set by mi.js while a form is sending. The spinner covers the label so the button keeps its width. */
.button[data-busy] { position: relative; color: transparent; cursor: progress; }
.button[data-busy]::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 1em;
    height: 1em;
    margin: auto;
    border: 2px solid var(--paper);
    border-right-color: transparent;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}
.button--secondary[data-busy]::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .button[data-busy]::after { animation-duration: 2.4s; }
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }

.store-badge { display: inline-block; }
.store-badge img { width: auto; height: var(--control-height); }

/* Listen and watch ------------------------------------------------------- */

.tracks { list-style: none; }
.tracks > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--space-5);
    align-items: center;
    padding: var(--space-2) 0;
    border-top: 1px solid var(--rule);
}
.tracks > li:last-child { border-bottom: 1px solid var(--rule); }
.tracks audio { width: 100%; height: 36px; }

.videos { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.videos a { text-decoration: none; }
.videos a:hover span { text-decoration: underline; }
.videos img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; margin-bottom: var(--space-2); background: var(--plate); }

/* Pay what you want ------------------------------------------------------ */

.pay {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    max-width: var(--measure);
    padding: var(--space-5);
    background: var(--plate);
    border-top: 3px solid var(--product);
}
.pay__label { color: var(--dim); }
.pay__hint { color: var(--dim); }
.pay > .button { justify-self: start; margin-top: var(--space-2); }

.price-field { display: flex; max-width: 20em; }
.price-field > * { border: 1px solid var(--ink); border-radius: 0; background: var(--paper); }
.price-field > * + * { border-left: 0; }
.price-field__symbol { display: grid; place-items: center; padding-left: var(--space-3); border-right: 0; font-size: var(--text-figure); }
.price-field__symbol::before { content: "£"; }
.price-field:has(option[value="USD"]:checked) .price-field__symbol::before { content: "$"; }
.price-field:has(option[value="EUR"]:checked) .price-field__symbol::before { content: "€"; }
.price-field__amount { flex: 1; min-width: 0; padding: 6px var(--space-2); font-size: var(--text-figure); }
.price-field__currency { padding: 0 var(--space-2); }

/* Form controls ---------------------------------------------------------- */

.form { display: grid; justify-items: start; gap: var(--space-4); max-width: 24em; }
.form > .field { width: 100%; }

.field { display: grid; gap: var(--space-1); max-width: 24em; }
.field__label { font-weight: 500; }
.field__hint { font-size: var(--text-small); color: var(--dim); }
.field__error { font-size: var(--text-small); color: var(--error); }

.input, .select {
    width: 100%;
    min-height: var(--control-height);
    padding: 0 var(--space-3);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 0;
}
.input::placeholder { color: var(--dim); }
.input[aria-invalid="true"] { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.input--code { width: 7.5em; font-size: var(--text-figure); letter-spacing: 0.25em; }

input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }

.checks { display: grid; gap: var(--space-3); }
.checks label { display: flex; align-items: baseline; gap: var(--space-3); }
.checks input { flex: none; transform: translateY(2px); }

.inline-form { display: flex; flex-wrap: wrap; max-width: 30em; }
.inline-form .input { flex: 1 1 14em; width: auto; }
.inline-form .input + .button { flex: none; }

/* Notice: a message after an action. ------------------------------------ */

.notice {
    max-width: var(--measure);
    padding: var(--space-3) var(--space-4);
    background: var(--plate);
    border-left: 2px solid var(--ink);
}
.notice--error { color: var(--error); background: var(--error-ground); border-left-color: var(--error); }

/* Product list ----------------------------------------------------------- */

.products { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6) var(--space-5); }
.products__item { position: relative; }
.products__item > .plate { margin-bottom: var(--space-3); }
.products__name { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; text-decoration: none; }
a.products__name:hover { text-decoration: underline; }
a.products__name::after { content: ""; position: absolute; inset: 0; }
.products__text { margin-top: 2px; color: var(--dim); }
.products__meta { margin-top: var(--space-2); }
.products__meta a { position: relative; z-index: 1; }
.products--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Table ------------------------------------------------------------------ */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: var(--space-3) var(--space-4) var(--space-3) 0;
    text-align: left;
    vertical-align: baseline;
    font-weight: 400;
    border-top: 1px solid var(--rule);
}
.table tbody tr:last-child > * { border-bottom: 1px solid var(--rule); }
.table thead th { padding-top: 0; color: var(--dim); border-top: 0; }
.table th[scope="row"] { font-weight: 500; }
.table th[scope="row"] .meta { display: block; font-weight: 400; }
.table .table__end { padding-right: 0; text-align: right; }

/* Disclosure ------------------------------------------------------------- */

.disclosure { padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.disclosure > summary { cursor: pointer; }
.disclosure[open] > summary { margin-bottom: var(--space-3); }

/* Version history -------------------------------------------------------- */

.history { list-style: none; }
.history > li {
    display: grid;
    grid-template-columns: 5em 7em minmax(0, 1fr);
    gap: var(--space-4);
    padding: var(--space-2) 0;
    border-top: 1px solid var(--rule);
}
.history time { color: var(--dim); }

/* Prose: running text inside a row body. -------------------------------- */

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--space-4); }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose ul { list-style: disc; }
.prose li + li { margin-top: var(--space-1); }

/* Small screens ---------------------------------------------------------- */

@media (max-width: 800px) {
    .row, .intro { display: block; }
    .row__label { margin-bottom: var(--space-4); }
    .intro__media, .intro > .facts { margin-top: var(--space-6); }
    .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .products, .products--compact { grid-template-columns: minmax(0, 1fr); }
    .videos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .spec > div, .tracks > li { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
    .history > li { grid-template-columns: 5em minmax(0, 1fr); }
    .history > li > :last-child { grid-column: 2; }

    /* Header: one Menu button opens the whole nav, with every panel laid flat. */
    .site-header__menu-button { display: inline-flex; margin-left: auto; }
    .site-nav:not(:popover-open) { display: none; }
    .site-nav {
        position: absolute;
        inset: var(--header-height) 0 auto 0;
        display: block;
        max-height: calc(100dvh - var(--header-height));
        padding: var(--space-2) var(--gutter) var(--space-6);
        overflow-y: auto;
        background: var(--paper);
        border-bottom: 1px solid var(--ink);
    }
    .site-nav__list { display: block; }
    .site-nav__list > li { border-top: 1px solid var(--rule); }
    .site-nav__list:first-child > li:first-child { border-top: 0; }
    .site-nav__list > li > a { display: block; padding: var(--space-3) 0; }
    .site-nav__list + .site-nav__list { margin-top: var(--space-5); }
    .site-nav__toggle { display: none; }
    .site-nav__heading { display: block; padding: var(--space-3) 0 var(--space-2); color: var(--dim); }
    .site-nav__panel { position: static; display: block; width: auto; padding: 0 0 var(--space-3); border: 0; }
    .products-menu::after { display: none; }
    .products-menu__list { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .site-nav .products-menu__item { padding: var(--space-2) 0; border-top: 0; }
}

/* Browsers without popovers (before Safari 17, Firefox 125) get a plain bar of links. */
@supports not selector(:popover-open) {
    .site-header__menu-button, .site-nav__toggle, .site-nav__panel { display: none; }
    .site-nav { position: static; display: flex; max-height: none; padding: 0; border: 0; }
    .site-nav__list { display: flex; }
    .site-nav__list > li { border: 0; }
    .site-nav__list + .site-nav__list { margin-top: 0; }
}
