/* I Love a Piano — Homepage: the app's dark wallpaper, its cover decal, the story in tiles, and a playable MultiPiano */

/* The piano rides over the page; the story scrolls under it. Set from piano.js as the piano resizes. */
:root {
    --piano-height: 0px;
    --decal-piano-height: 0px;
    /* The site nav's 56px bar plus its 2px bottom padding */
    --nav-height: 58px;
    /* The glass controls' 38px row and the 10px over the keys */
    --controls-height: 48px;
    /* The page shows between the nav and the controls: Page Down, Space, and the page-down button step by that
       much, and anchors land under the nav */
    scroll-padding: var(--nav-height) 0 calc(var(--piano-height) + var(--controls-height));
    /* On the root, not the body: with overflow-x set on both, Chromium makes the body its own scroller, and
       overscroll-behavior there stops trackpad scrolls from reaching the page */
    overscroll-behavior: none;
}

/* Under the browser's bars and past the safe areas, the wallpaper's darker end */
body.home-dark {
    background: #141414;
    padding-bottom: calc(var(--piano-height) + var(--controls-height));
    -webkit-tap-highlight-color: transparent;
}

/* Matches the app's dark-mode Wallpaper; held to the screen, as iOS ignores a fixed background */
body.home-dark::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(to bottom, #313130, #141414);
}

.home-dark .nav-mobile-menu {
    background: rgba(36, 36, 40, 0.98);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.home-dark .nav-mobile-link:hover { background: rgba(255, 255, 255, 0.08); }
.home-dark .nav-mobile-divider { border-top-color: rgba(255, 255, 255, 0.12); }

/* CoverDecal's piano logo at half size; the nav fades it in once the title scrolls away */
.nav-scroll-link { text-decoration: none; }

.compact-decal {
    display: flex;
    align-items: center;
    height: 40px;
    filter: drop-shadow(0 0.5px 0.5px rgba(0, 0, 0, 0.35));
}

.mark-piano {
    width: 26px;
    height: 26px;
}

/* 920px wide, with the story's inset */
.home-dark :is(.nav-container, .footer-container) {
    max-width: 920px;
    padding-left: max(var(--story-pad), env(safe-area-inset-left));
    padding-right: max(var(--story-pad), env(safe-area-inset-right));
}

/* The nav's ends, inset by their own links' 16px, reach the column's edges */
.home-dark .nav-heart {
    margin-left: -16px;
}

.home-dark .nav-right {
    margin-right: -16px;
}

.home-dark .site-footer { background: transparent; }
.home-dark .footer-divider { background: rgba(255, 255, 255, 0.12); }


/* ==========================================================================
   CONTROLS, IN LIQUID GLASS
   Riding on the piano they play, rising and falling with its rows and sizes
   ========================================================================== */

.controls {
    position: fixed;
    bottom: var(--piano-height);
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    /* Sound at the left, page down centered */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 0 max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    -webkit-user-select: none;
    user-select: none;
}

.glass {
    position: relative;
    border-radius: 999px;
    color: rgb(255 255 255 / 0.92);
    background: linear-gradient(to bottom, rgb(255 255 255 / 0.13), rgb(255 255 255 / 0.05));
    -webkit-backdrop-filter: blur(16px) saturate(1.8);
    backdrop-filter: blur(16px) saturate(1.8);
    box-shadow:
        inset 0 1px 0.5px rgb(255 255 255 / 0.3),
        inset 0 -1px 1px rgb(255 255 255 / 0.06),
        0 1px 2px rgb(0 0 0 / 0.25),
        0 8px 24px rgb(0 0 0 / 0.3);
}

/* The rim: brightest where the light catches the top-left and bottom-right */
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgb(255 255 255 / 0.5), rgb(255 255 255 / 0.06) 35%, rgb(255 255 255 / 0.06) 65%, rgb(255 255 255 / 0.3));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.controls > * {
    pointer-events: auto;
}

.controls button {
    appearance: none;
    border: 0;
    margin: 0;
    padding: 0;
    background-color: transparent;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: grid;
    place-items: center;
    touch-action: manipulation;
}

.controls button:disabled {
    cursor: default;
}

.controls svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

/* Pressed, the glass swells and brightens */
.glass-circle {
    width: 46px;
    height: 46px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
}

.glass-circle:active:not(:disabled) {
    transform: scale(1.1);
    background-color: rgb(255 255 255 / 0.12);
    transition-duration: 0.12s;
}

.glass-circle:disabled {
    color: rgb(255 255 255 / 0.3);
}

/* A cycle and a speaker: restart the sound. It and page down share one height */
.controls .sound-button {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 13px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
}

.sound-button svg {
    width: 20px;
    height: 20px;
    stroke-linejoin: round;
}

#page-down {
    justify-self: center;
    width: 38px;
    height: 38px;
    color: rgb(255 255 255 / 0.55);
    transition: color 0.2s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#page-down:hover:not(:disabled),
#page-down:active:not(:disabled) {
    color: #fff;
}

#page-down:active:not(:disabled) {
    transform: scale(1.12);
    transition-duration: 0.12s;
}

#page-down:disabled {
    color: rgb(255 255 255 / 0.2);
}

#page-down svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    stroke-linejoin: round;
}

.controls .sound-button:active {
    transform: scale(1.08);
    background-color: rgb(255 255 255 / 0.12);
    transition-duration: 0.12s;
}

/* ==========================================================================
   COVER DECAL
   The logo over the name, in gold, then the tagline, the badge, and the
   devices: the first screen's room between the nav and the piano's controls,
   exactly, the devices taking what the rest leaves. Room the devices can't use
   splits evenly over the title, under the badge, and under the devices, so the
   title sits as far from the top as the devices from the controls
   ========================================================================== */

.decal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    height: max(100svh - var(--decal-piano-height), 34rem);
    padding: calc(var(--nav-height) + 24px) max(24px, env(safe-area-inset-right)) calc(var(--controls-height) + 16px) max(24px, env(safe-area-inset-left));
    text-align: center;
}

.decal > :not(.hero-devices) {
    flex: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.decal-logo {
    width: 72px;
    height: 72px;
    margin-top: auto;
}

.decal-name {
    margin: 0;
    font-family: ui-serif, "New York", Georgia, serif;
    font-size: 50px;
    font-weight: 800;
    line-height: 60px;
    text-transform: uppercase;
    /* Runs cap height to baseline, so the letters span the whole gradient */
    background: linear-gradient(to bottom, #F5DB99 22%, #C29952 78%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.decal-subtitle {
    margin: 0;
    font-size: 28px;
    font-weight: 500;
    line-height: 1.25;
    color: #a0a0ab;
}

.store-badge {
    margin: 8px 0 16px;
    line-height: 0;
}

.store-badge img {
    display: block;
}

/* iPhone, iPad, Mac, and Duo on one baseline, scaled 1, 1.15, 1.3, and 1. The row takes the decal's leftover height,
   up to the height that spans the page; --unit is the iPhone's height, the smaller of what the room's height and width
   allow, from the images' aspect ratios times their scales (0.49 + 1.56 + 2.15 + 0.72 = 4.92 wide, 1.3 tall). */
.hero-devices {
    --device-gap: 24px;
    --row-width: min(100vw - 48px, 912px);
    --unit: min(100cqh / 1.3, (100cqw - 3 * var(--device-gap) - 1px) / 4.92);
    container-type: size;
    flex: 1 1 0;
    min-height: 0;
    max-height: calc((var(--row-width) - 3 * var(--device-gap)) / 4.92 * 1.3);
    width: min(100%, 912px);
    margin: auto 0;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    align-items: flex-end;
    justify-content: center;
    gap: var(--device-gap);
}

/* <picture> is display: contents, which would make each <source> a gap-taking flex item */
.hero-devices source {
    display: none;
}

.hero-device {
    width: auto;
    height: calc(var(--scale) * var(--unit));
}

/* ==========================================================================
   THE STORY, UNDER THE PIANO
   The site's copy in tiles: square features, darker than the wallpaper, with
   the highlight in their hue; then Version 1's hero cards, in the same dark
   ========================================================================== */

/* Version 1's measure: 1100px wide, inset 32px, or 12px on a phone, the nav and footer sharing the inset. The full-width
   cards, the features, and the half-width cards sit a section gap apart */
body.home-dark {
    --story-width: 1100px;
    --story-pad: 32px;
}

.story {
    --section-gap: 84px;
    max-width: var(--story-width);
    margin: 0 auto;
    padding: 0 max(var(--story-pad), env(safe-area-inset-right)) 12vh max(var(--story-pad), env(safe-area-inset-left));
    color: #f5f5f7;
}

.story .tiles {
    --columns: 3;
    --tile-gap: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--tile-gap);
    margin: 0;
    padding: 12vh 0 0;
    list-style: none;
}

/* The features in two rows, filled column by column, paged by the cover carousel's arrows (CoverViewPageArrowsView).
   The rows run the window's width, resting and snapping in line with the story; the arrows hold still at the window's
   edges, as the tiles slide under them. --inset is the story's margin: its padding, plus half of what its max-width leaves. */
.carousel {
    --inset: max(var(--story-pad), env(safe-area-inset-left), (100vw - var(--story-width)) / 2 + var(--story-pad));
    position: relative;
    margin: var(--section-gap) calc(50% - 50vw) 0;
    scroll-margin-top: 72px;
}

.story .features {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: auto auto;
    /* A quarter of the next column shows past the last whole one, so the line reads as more to scroll */
    grid-auto-columns: calc((100% - var(--columns) * var(--tile-gap)) / (var(--columns) + 0.25));
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    padding: 0 var(--inset);
    scroll-padding-inline: var(--inset);
}

.story .features::-webkit-scrollbar {
    display: none;
}

.features li {
    scroll-snap-align: start;
}

/* A tight pill, as the Mac App Store's carousel arrows, at the window's edges */
.page-arrow {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 44px;
    translate: 0 -50%;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: rgb(255 255 255 / 0.55);
    background: rgb(255 255 255 / 0.1);
    -webkit-backdrop-filter: blur(12px) saturate(1.8);
    backdrop-filter: blur(12px) saturate(1.8);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, opacity 0.2s;
}

.page-arrow[data-step="-1"] { left: max(8px, env(safe-area-inset-left)); }
.page-arrow[data-step="1"] { right: max(8px, env(safe-area-inset-right)); }

/* Lit while the tiles scroll its way, or under the pointer */
.page-arrow.lit,
.page-arrow:hover {
    color: #fff;
    background: rgb(255 255 255 / 0.18);
}

/* Shown where there's a tile to go to */
.page-arrow:disabled {
    opacity: 0;
    pointer-events: none;
}

.page-arrow svg {
    width: 8px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tiles li {
    --pad: 24px;
    box-sizing: border-box;
    flex: 0 0 calc((100% - (var(--columns) - 1) * var(--tile-gap)) / var(--columns));
    aspect-ratio: 1;
    padding: var(--pad);
    border-radius: 24px;
}

.features li {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: rgb(0 0 0 / 0.3);
}

.features p {
    margin: 0;
}

.features em {
    font-style: normal;
    color: var(--hue);
}

/* Too dark to read on glass, purple, green, and navy take ColorPalette's highlight */
.features .purple { --hue: #A10499; }
.features .blue { --hue: #0497C0; }
.features .green { --hue: #38A35E; }
.features .orange { --hue: #FC711B; }
.features .red { --hue: #E3211D; }
.features .navy { --hue: #006EE6; }
.features .pink { --hue: #C93391; }
.features .yellow { --hue: #FEAF02; }
.features .gray { --hue: #757F9A; }
.features .brown { --hue: #D07028; }

.tile-media {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    /* An image taller than the room hangs downward, clipped by the tile, rather than over the text */
    align-items: safe center;
    justify-content: center;
    margin-top: 16px;
}

.tile-media img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    height: auto;
}

.features .tile-bleed { padding-bottom: 0; }
.tile-bleed .tile-media { align-items: flex-end; }

/* Runs edge to edge */
.tile-edge .tile-media { margin-inline: calc(var(--pad) * -1); }

/* A touch wider than the tile, hung under the text so the phones' bottoms clip */
.features .tile-wide { padding-bottom: 0; }

.tile-wide .tile-media {
    position: relative;
    margin-inline: calc(var(--pad) * -1);
    overflow: hidden;
}

.tile-wide .tile-media img {
    position: absolute;
    top: 8px;
    left: 50%;
    height: 88%;
    width: auto;
    max-width: none;
    max-height: none;
    transform: translateX(-50%);
}

/* As tall as the room under the text, from the tile's inset on the left past its right edge */
.tile-bleed-right .tile-media {
    justify-content: flex-start;
    margin-right: calc(var(--pad) * -1);
    overflow: hidden;
}

.tile-bleed-right .tile-media img {
    height: 100%;
    max-width: none;
    max-height: none;
}

/* Wider than the tile and hung from just under the text, clipped at the tile's sides and bottom */
.features .tile-fill { padding-bottom: 0; }

.tile-fill .tile-media {
    position: relative;
    margin-inline: calc(var(--pad) * -1);
    overflow: hidden;
}

.tile-fill .tile-media img {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 115%;
    max-width: none;
    max-height: none;
    transform: translateX(-50%);
}

.tile-edge .tile-media img {
    width: 100%;
    max-width: none;
    max-height: none;
}

/* Version 1's full-width hero card, in the features' dark: the title over the screenshot over the detail */
.story-intro {
    max-width: 760px;
    margin: 8vh auto 0;
    font-size: 28px;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
}

.story .feature-card {
    margin-top: 8vh;
    padding: 40px 48px;
    border-radius: 24px;
    text-align: center;
    color: #fff;
    background: rgb(0 0 0 / 0.3);
}

.feature-card h2 {
    margin: 0;
    font-size: 48px;
    font-weight: 600;
    line-height: 1.1;
}

.feature-card img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 32px auto 0;
}

.feature-card p {
    max-width: 700px;
    margin: 32px auto 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
}

.story :is(.feature-card, .feature-pair) + :is(.feature-card, .feature-pair) {
    margin-top: 16px;
}

.story .feature-card + .feature-pair {
    margin-top: var(--section-gap);
}

/* Two to a row, as Version 1's hero card pairs: smaller titles, and the images centered in what the text leaves.
   Stacked into full-width cards once the halves get too narrow for their text, as Version 1's music pair does */
.feature-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.story .feature-pair .feature-card {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    padding: 32px;
}

.feature-pair h2 {
    font-size: 32px;
}

.feature-pair picture {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-pair p {
    font-size: 17px;
}

/* An image that runs off the card's left edge, as the MIDI keyboard does */
.story .bleed-left {
    --bleed: 32px;
}

.bleed-left picture {
    margin-left: calc(-1 * var(--bleed));
    justify-content: flex-start;
}

.bleed-left img {
    margin-left: 0;
}

/* ==========================================================================
   FREE VS. UPGRADE, IN DARK
   ========================================================================== */

.story .compare {
    margin-top: 6vh;
}

/* Set as the hero cards' titles, with the app's name as the cover decal sets it */
.compare-title {
    margin: 0 0 var(--space-2xl);
    font-size: 48px;
    font-weight: 600;
    line-height: 1.1;
    color: #fff;
}

.compare-title em {
    font-family: ui-serif, "New York", Georgia, serif;
    font-size: 0.92em;
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
    background: linear-gradient(to bottom, #F5DB99 22%, #C29952 78%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.home-dark .compare-product,
.home-dark .compare-table thead td {
    border-bottom-color: rgb(255 255 255 / 0.16);
}

.home-dark .compare-table tbody + tbody {
    border-top-color: rgb(255 255 255 / 0.1);
}

/* The cover decal again to close, logo over name over badge */
.closing-decal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: var(--section-gap);
}

.closing-decal > * {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.closing-decal .store-badge {
    margin-bottom: 0;
}


/* ==========================================================================
   THE MULTIPIANO
   ========================================================================== */

.piano {
    --duration: 0.4s;
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* A light shade over the story just above the keys, then the wallpaper's dark end, frosted as the nav is, beside and
   below the chassis */
.piano::before,
.piano::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    z-index: -1;
    pointer-events: none;
}

.piano::before {
    top: -24px;
    height: 24px;
    background: linear-gradient(to bottom, rgb(20 20 20 / 0), rgb(20 20 20 / 0.4));
}

.piano::after {
    top: 0;
    bottom: 0;
    background: rgb(20 20 20 / 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Window resizes and first layout land at once; size and row changes ease */
.piano.instant *,
.piano.instant *::before {
    transition: none !important;
}

.piano-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    /* The keys rest clear of a landscape notch; scrolled, the chassis runs under it to the screen's edge */
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    scroll-padding-inline: calc(var(--gap) + env(safe-area-inset-left)) calc(var(--gap) + env(safe-area-inset-right));
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    /* Room for the chassis shadow above, and the scroll indicator's strip below */
    padding-top: 16px;
    margin-top: -16px;
    padding-bottom: var(--clearance);
}

.piano-scroller::-webkit-scrollbar {
    display: none;
}

.chassis {
    box-sizing: border-box;
    width: calc(var(--columns) * var(--w) + (var(--columns) + 1) * var(--gap));
    margin-inline: auto;
    padding: var(--gap) var(--gap) 0;
    background-color: var(--chassis);
    border-radius: var(--chassis-radius);
    /* Cast up over the page only: below, it would read as a gap under the keys */
    box-shadow: 0 -6px 12px -4px rgba(0, 0, 0, 0.33);
    transition:
        background-color 0.167s ease-out,
        width var(--duration) var(--ease),
        padding var(--duration) var(--ease),
        border-radius var(--duration) var(--ease);
}

.chassis.lit {
    background-color: var(--chassis-lit);
}

/* One row slot: its title strip over its keys, and the gap below; content-box against the site's border-box reset,
   so the gap adds to the row's height instead of eating the chassis's top lip */
.row {
    box-sizing: content-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--gap);
    height: calc(var(--badge-height) + var(--gap) + var(--keyboard-height));
    padding-bottom: var(--gap);
    transition:
        height var(--duration) var(--ease),
        padding var(--duration) var(--ease),
        gap var(--duration) var(--ease),
        opacity var(--duration) var(--ease);
}

.row.collapsed {
    height: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Title strip: each C's register number */
.title-strip {
    flex: none;
    display: flex;
    gap: var(--gap);
    height: var(--badge-height);
    transition: height var(--duration) var(--ease), gap var(--duration) var(--ease);
}

@media (pointer: fine) {
    .title-strip { cursor: grab; }
    .dragging, .dragging * { cursor: grabbing; }
}

.title-cell {
    flex: none;
    width: var(--w);
    display: flex;
    align-items: center;
    transition: width var(--duration) var(--ease);
}

.title-cell.trailing {
    justify-content: flex-end;
}

.title-cell.snap {
    scroll-snap-align: start;
}

.badge {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--badge-height);
    min-width: calc(var(--badge-text) * 1.85);
    padding: 0 calc(var(--badge-text) * 0.5);
    border-radius: 999px;
    font: 600 var(--badge-text) / 1 system-ui, -apple-system, sans-serif;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
    transition-property: height, min-width, padding, font-size;
    transition-duration: var(--duration);
    transition-timing-function: var(--ease);
}

/* Keys */
.keyboard {
    flex: none;
    display: flex;
    gap: var(--gap);
    height: var(--keyboard-height);
    touch-action: none;
    transition: height var(--duration) var(--ease), gap var(--duration) var(--ease);
}

.key {
    --press: none;
    --tint: none;
    position: relative;
    box-sizing: border-box;
    flex: none;
    background-image: var(--press), var(--tint);
    transition-property: width, height, left, border-radius;
    transition-duration: var(--duration);
    transition-timing-function: var(--ease);
}

/* Touch reach past the drawn key: half the gap between keys, the whole rim on outer edges */
.key::before {
    content: "";
    position: absolute;
    inset: calc(var(--gap) / -2);
    border-radius: inherit;
}

.key.white {
    width: var(--w);
    height: 100%;
    background-color: #fff;
    border-radius: var(--top-radius) var(--top-radius) var(--bottom-radius) var(--bottom-radius);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.key.white.first {
    border-top-left-radius: var(--end-top-radius);
    border-bottom-left-radius: var(--end-radius);
}

.key.white.first::before {
    left: calc(var(--gap) * -1);
}

.key.white.last {
    border-top-right-radius: var(--end-top-radius);
    border-bottom-right-radius: var(--end-radius);
}

.key.white.last::before {
    right: calc(var(--gap) * -1);
}

.bottom-row > .key.white::before {
    bottom: calc(var(--gap) * -1 - var(--clearance));
}

.key.black {
    position: absolute;
    top: 0;
    z-index: 2;
    width: var(--black-width);
    height: var(--black-height);
    background-color: #000;
    border-radius: 0 0 var(--bottom-radius) var(--bottom-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.key.white.pressed {
    --press: linear-gradient(rgb(0 0 0 / 0.2) 0 0);
}

.key.black.pressed {
    --press: linear-gradient(rgb(255 255 255 / 0.25) 0 0);
}

/* Matching or sustained: the chassis color over the key */
.key.white.tinted {
    --tint: linear-gradient(rgb(229 29 29 / 0.25) 0 0);
}

.key.black.tinted {
    --tint: linear-gradient(rgb(229 29 29 / 0.5) 0 0);
}

.key > .name {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    white-space: nowrap;
    font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
    font-weight: 500;
    line-height: 1.2;
    color: #8E8E93;
    pointer-events: none;
    transition: bottom var(--duration) var(--ease), font-size var(--duration) var(--ease);
}

.white > .name {
    bottom: var(--white-foot);
    font-size: var(--white-name);
}

.black > .name {
    bottom: var(--black-foot);
    font-size: var(--black-name);
}

.middle-c {
    position: absolute;
    left: var(--midc-left);
    right: var(--midc-left);
    bottom: var(--gap);
    height: 5px;
    border-radius: 2.5px;
    background: rgb(88 92 109 / 0.3);
    pointer-events: none;
    transition-property: left, right, bottom;
    transition-duration: var(--duration);
    transition-timing-function: var(--ease);
}

.key > .keycap {
    position: absolute;
    left: 50%;
    translate: -50% 0;
    box-sizing: border-box;
    width: var(--keycap);
    height: var(--keycap);
    display: grid;
    place-items: center;
    border-radius: calc(var(--keycap) / 4);
    font: 500 var(--hint-size) / 1 system-ui, -apple-system, sans-serif;
    pointer-events: none;
    transition-property: width, height, bottom, border-radius, font-size;
    transition-duration: var(--duration);
    transition-timing-function: var(--ease);
}

.white > .keycap {
    bottom: var(--white-foot);
    color: rgb(60 60 67 / 0.6);
    background: rgb(242 242 247 / 0.9);
    border: 0.5px solid rgb(60 60 67 / 0.29);
}

.black > .keycap {
    bottom: var(--black-foot);
    color: rgb(235 235 245 / 0.6);
    background: rgb(36 36 38 / 0.95);
    border: 0.5px solid rgb(84 84 88 / 0.6);
}

/* The app's own scroll indicator, in the strip below the chassis */
.scroll-indicator {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(3px + env(safe-area-inset-bottom));
    height: 3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.scroll-indicator.shown {
    opacity: 1;
    transition: none;
}

.scroll-indicator > div {
    height: 100%;
    border-radius: 1.5px;
    background: rgb(255 255 255 / 0.35);
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 600px) {
    /* A phone's first screen is short on height, not width: tighter type and gaps over the devices give them the
       room */
    .decal {
        gap: 10px;
        height: max(100svh - var(--decal-piano-height), 26rem);
        padding-top: calc(var(--nav-height) + 12px);
        padding-bottom: calc(var(--controls-height) + 10px);
    }

    .decal-logo {
        width: 40px;
        height: 40px;
    }

    .decal-name {
        font-size: 30px;
        line-height: 36px;
    }

    .decal-subtitle {
        font-size: 17px;
    }

    .store-badge {
        margin: 4px 0 6px;
    }

    .store-badge img {
        width: auto;
        height: 40px;
    }

    /* Two to a row, iPhone and iPad over Mac and Duo: Mac and Duo set the width (2.15 + 0.72 = 2.87), the rows the
       height (1.15 + 1.3 = 2.45) */
    .hero-devices {
        --device-gap: 12px;
        --unit: min((100cqh - 16px) / 2.45, (100cqw - var(--device-gap) - 1px) / 2.87);
        max-height: calc((var(--row-width) - var(--device-gap)) / 2.87 * 2.45 + 16px);
        row-gap: 8px;
    }

    /* A full-width break keeps two to a row when a short window shrinks the devices enough to fit three; its two
       row gaps make the 16px between the rows */
    .hero-devices::after {
        content: "";
        flex-basis: 100%;
        order: 1;
    }

    .hero-devices picture:nth-of-type(n + 3) > img {
        order: 2;
    }
}

/* A short phone leaves too little height for two rows to beat one: back to the single row, at the phone's width */
@media (max-width: 600px) and (max-height: 750px) {
    .hero-devices {
        --device-gap: 8px;
        --unit: min(100cqh / 1.3, (100cqw - 3 * var(--device-gap) - 1px) / 4.92);
        max-height: calc((var(--row-width) - 3 * var(--device-gap)) / 4.92 * 1.3);
    }

    .hero-devices::after {
        display: none;
    }

    .hero-devices picture:nth-of-type(n + 3) > img {
        order: 0;
    }
}

@media (max-width: 768px) {
    .story .tiles { --columns: 2; }
    .compare-title { font-size: 36px; }
    .home-dark .nav-menu-button { margin-right: -12px; }
    .story .feature-card { padding: 32px; }
    .feature-card h2 { font-size: 36px; }
    .feature-pair { grid-template-columns: 1fr; }
    .feature-pair h2 { font-size: 36px; }
    .feature-pair p { font-size: 18px; }
}

@media (max-width: 480px) {
    body.home-dark { --story-pad: 12px; }
    .story .tiles { --tile-gap: 12px; }
    .tiles li { --pad: 16px; border-radius: 18px; }
    .decal-subtitle { font-size: 20px; }
    .story-intro { font-size: 20px; }
    .features li { font-size: 16px; }
    .tile-media { margin-top: 10px; }
    .compare-title { font-size: 28px; }
    .story .feature-card,
    .story .feature-pair .feature-card { padding: 24px 16px; border-radius: 18px; }
    .story .bleed-left { --bleed: 16px; }
    .feature-card h2,
    .feature-pair h2 { font-size: 28px; }
    .feature-card img { margin-top: 20px; }
    .feature-card p,
    .feature-pair p { margin-top: 20px; font-size: 16px; }
}
