/*
 * The Kapow gallery. Colors, radii and fonts come from tokens.css (design/tokens.css); the Compose stage uses the
 * same values through KapowTheme.
 */
@font-face {
    font-family: 'DM Sans Variable';
    font-weight: 100 1000;
    font-display: swap;
    src: url('fonts/dm_sans.ttf') format('truetype');
}

@font-face {
    font-family: 'Geist Variable';
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/geist.ttf') format('truetype');
}

@font-face {
    font-family: 'Geist Mono Variable';
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/geist_mono.ttf') format('truetype');
}

* {
    box-sizing: border-box;
}

html {
    scroll-padding-top: 88px;
}

body {
    margin: 0;
    background: var(--kapow-canvas);
    color: var(--kapow-ink);
    font: 400 16px/24px var(--kapow-font);
    -webkit-font-smoothing: antialiased;
}

[hidden] {
    display: none !important;
}

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: none;
    box-shadow: var(--kapow-focus);
}

h1,
h2 {
    margin: 0;
    font-weight: 500;
    color: var(--kapow-title);
}

code {
    font-family: var(--kapow-font-mono);
    font-size: 13px;
}

p code {
    padding: 1px 5px;
    background: var(--kapow-glass);
    border-radius: var(--kapow-radius-icon);
}

/* Floating nav */
.nav {
    position: fixed;
    inset: 16px 16px auto;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: calc(var(--kapow-max-width) - 32px);
    height: 56px;
    margin: 0 auto;
    padding: 0 12px 0 20px;
    background: color-mix(in srgb, var(--kapow-panel) 80%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-nav);
    box-shadow: var(--kapow-nav-shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--kapow-radius-pill);
    font: 500 18px/27px var(--kapow-font);
    color: var(--kapow-title);
}

.nav-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.version {
    padding: 1px 8px;
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-pill);
    font: 400 12px/18px var(--kapow-font-mono);
    color: var(--kapow-slate);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--kapow-radius-pill);
    font: 500 14px/20px var(--kapow-font);
    color: var(--kapow-ash);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--kapow-title);
    background: var(--kapow-glass);
}

/* Wide enough for words: the links are text. Narrower, they turn into icons (see the media queries). */
.nav-link svg {
    display: none;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-link svg.filled {
    fill: currentColor;
    stroke: none;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

#frame-meter {
    width: 168px;
    height: 28px;
}

.motion {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 500 13px/20px var(--kapow-font);
    letter-spacing: 0.33px;
    color: var(--kapow-ash);
}

.haptics {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 500 13px/20px var(--kapow-font);
    letter-spacing: 0.33px;
    color: var(--kapow-ash);
}

.haptics input {
    accent-color: var(--kapow-action);
}

select {
    padding: 4px 8px;
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-control);
    background: var(--kapow-panel);
    color: var(--kapow-ink);
    font: 500 13px/20px var(--kapow-font);
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-pill);
    background: transparent;
    color: var(--kapow-ink);
    cursor: pointer;
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
}

/* The icon shows the theme a click switches to. */
.theme-toggle .icon-moon,
:root[data-theme='light'] .theme-toggle .icon-sun {
    display: none;
}

:root[data-theme='light'] .theme-toggle .icon-moon {
    display: block;
}

/* Page */
.layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 48px;
    max-width: var(--kapow-max-width);
    margin: 0 auto;
    padding: 104px 24px 72px;
}

.sidebar {
    position: sticky;
    top: 88px;
    align-self: start;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
}

.sidebar summary {
    display: none;
}

.sidebar h2 {
    margin: 24px 0 8px;
    font: 500 13px/20px var(--kapow-font);
    letter-spacing: 0.33px;
    color: var(--kapow-slate);
}

.sidebar h2:first-child {
    margin-top: 0;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar a {
    display: block;
    padding: 6px 14px;
    border-radius: var(--kapow-radius-pill);
    color: var(--kapow-ash);
    font-size: 15px;
    line-height: 20px;
}

.sidebar a:hover {
    color: var(--kapow-title);
}

.sidebar a[aria-current='page'] {
    color: var(--kapow-title);
    background: var(--kapow-glass);
}

main {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 12px;
    font: 500 13px/20px var(--kapow-font);
    letter-spacing: 0.33px;
    text-transform: uppercase;
    color: var(--kapow-slate);
}

h1 {
    max-width: 16ch;
    font: 500 48px/48px var(--kapow-font-heading);
}

#example-title {
    max-width: none;
}

/* The title of an example with its Play/Pause pill. */
.example-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

.primary-pill,
.ghost-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--kapow-radius-pill);
    font: 500 14px/20px var(--kapow-font);
    white-space: nowrap;
    cursor: pointer;
}

/* The one filled button of a view. */
.primary-pill {
    padding: 8px 14px;
    background: var(--kapow-action);
    color: var(--kapow-on-action);
}

.ghost-pill {
    padding: 6px 14px;
    border: 1px solid var(--kapow-hairline);
    background: transparent;
    color: var(--kapow-ink);
}

.ghost-pill:hover {
    background: var(--kapow-glass);
}

.ghost-pill svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The icon shows what a press does. */
.autoplay .icon-play,
.autoplay[data-playing='false'] .icon-pause {
    display: none;
}

.autoplay[data-playing='false'] .icon-play {
    display: block;
}

/* Read the docs and the install line, under the overview's lede. */
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
}

.install {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
    padding: 4px 4px 4px 16px;
    background: var(--kapow-panel);
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-pill);
}

.install code {
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    color: var(--kapow-ash);
    scrollbar-width: none;
}

.install .copy {
    flex: none;
}

.lede {
    max-width: 60ch;
    margin: 20px 0 0;
    font: 500 18px/27px var(--kapow-font);
    color: var(--kapow-ash);
}

/*
 * The overview grid. The links are laid out here with the tile metrics of EffectTile.kt (12 px padding, a 4:3
 * stage, a 10 px gap and two 20 px caption lines), and stay transparent: one Compose canvas behind them, sticky
 * in the viewport, draws the tiles and headings that are in view at the same places. The page scrolls as usual
 * and the canvas takes no pointer, so wheel and touch never get caught in it.
 */
.grid-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-top: 72px;
}

#grid-title {
    font: 500 24px/32px var(--kapow-font-heading);
}

.effect-grid {
    position: relative;
    margin-top: 24px;
}

.grid-canvas-track {
    position: absolute;
    inset: 0;
}

#grid-canvas {
    position: sticky;
    top: 0;
    height: min(100vh, 100%);
    background: var(--kapow-canvas);
}

#grid-canvas,
#grid-canvas * {
    pointer-events: none !important;
}

.grid-group {
    position: relative;
}

.grid-group + .grid-group {
    margin-top: 32px;
}

/* The canvas draws the heading text; this keeps its place and its name. */
.grid-heading {
    height: 27px;
    margin: 0 0 12px;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.tile {
    display: block;
    padding: 12px 12px 62px;
    border-radius: var(--kapow-radius-card);
}

.tile::before {
    content: '';
    display: block;
    aspect-ratio: 4 / 3;
}

.tile:hover {
    box-shadow: inset 0 0 0 1px var(--kapow-hairline);
}

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

/* An example page */
.example-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    margin-top: 40px;
}

/* A page without source gives the stage the full width. */
.example-grid:has(#source[hidden]) {
    grid-template-columns: minmax(0, 1fr);
}

.stage-host {
    height: 520px;
}

/* Footer */
.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    width: min(100% - 48px, var(--kapow-max-width) - 48px);
    margin: 0 auto;
    padding: 24px 0 32px;
    border-top: 1px solid var(--kapow-hairline);
    font: 500 13px/20px var(--kapow-font);
    letter-spacing: 0.33px;
    color: var(--kapow-slate);
}

.site-footer p {
    margin: 0;
}

.site-footer ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
}

.site-footer li + li::before {
    content: '·';
    padding: 0 8px;
}

.site-footer a {
    color: var(--kapow-ash);
}

.site-footer p a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.site-footer a:hover {
    color: var(--kapow-title);
    text-decoration: underline;
}

/* Source panel */
.source {
    min-width: 0;
    background: var(--kapow-panel);
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-control);
    overflow: hidden;
}

.source-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--kapow-hairline);
}

.source-tabs {
    display: flex;
    gap: 4px;
    min-width: 0;
}

.source-tab {
    border: 0;
    border-radius: var(--kapow-radius-pill);
    padding: 4px 12px;
    background: transparent;
    color: var(--kapow-slate);
    font: 500 13px/20px var(--kapow-font);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-tab.source-name {
    font: 400 13px/20px var(--kapow-font-mono);
}

.source-tab[aria-selected='true'] {
    background: var(--kapow-glass);
    color: var(--kapow-title);
}

.source-tab:focus-visible {
    outline: none;
    box-shadow: var(--kapow-focus);
}

.source-name {
    font: 400 13px/20px var(--kapow-font-mono);
    color: var(--kapow-ash);
}

.copy,
.imports-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--kapow-hairline);
    border-radius: var(--kapow-radius-pill);
    background: transparent;
    color: var(--kapow-ink);
    cursor: pointer;
    white-space: nowrap;
}

.copy {
    padding: 4px 12px;
    font: 500 13px/20px var(--kapow-font);
}

.copy .check {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--kapow-success);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.copy.copied {
    color: var(--kapow-success);
    border-color: var(--kapow-success);
}

.source pre {
    margin: 0;
    max-height: 520px;
    overflow: auto;
    padding: 16px 20px 20px;
    font: 400 13px/20px var(--kapow-font-mono);
    tab-size: 4;
    color: var(--kapow-ink);
}

.source pre:focus-visible {
    box-shadow: inset var(--kapow-focus);
}

.imports-toggle {
    display: flex;
    width: fit-content;
    padding: 0 10px;
    font: 400 12px/18px var(--kapow-font-mono);
    color: var(--kapow-slate);
}

.imports-body {
    display: block;
}

.imports[data-collapsed='true'] .imports-body {
    display: none;
}

/* Highlighting stays inside the grey scale; weight and tone tell the tokens apart. */
.tok-keyword {
    color: var(--kapow-title);
    font-weight: 500;
}

.tok-type,
.tok-call {
    color: var(--kapow-title);
}

.tok-string,
.tok-number {
    color: var(--kapow-ash);
}

.tok-annotation {
    color: var(--kapow-slate);
}

.tok-comment {
    color: var(--kapow-slate);
    font-style: italic;
}

@media (min-width: 1100px) {
    .example-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }
}

/* Between the phone and a wide window the nav runs out of room for words: the links keep their icons. */
@media (max-width: 1060px) {
    .nav-link {
        width: 32px;
        padding: 0;
        justify-content: center;
    }

    .nav-link svg {
        display: block;
    }

    .nav-link span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .sidebar {
        position: static;
        max-height: none;
    }

    .sidebar summary {
        display: block;
        padding: 8px 16px;
        border: 1px solid var(--kapow-hairline);
        border-radius: var(--kapow-radius-pill);
        font: 500 14px/20px var(--kapow-font);
        cursor: pointer;
    }

    .sidebar nav {
        margin-top: 8px;
    }

    /* Hidden from sight only: the select still needs its name. */
    .motion span,
    .haptics span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
}

/* Just above phone width the version makes way for the links. */
@media (max-width: 760px) {
    .version {
        display: none;
    }

    .nav-links {
        margin-left: 0;
    }
}

@media (max-width: 640px) {
    .nav {
        inset: 8px 8px auto;
        padding: 0 8px 0 14px;
    }

    .brand span {
        display: none;
    }

    /* The footer and the overview carry these; the nav keeps GitHub. */
    .nav-docs,
    .nav-maven {
        display: none;
    }

    .nav-start {
        gap: 4px;
    }

    .nav-link {
        width: 28px;
    }

    .nav {
        gap: 8px;
    }

    .nav-tools {
        gap: 6px;
    }

    .site-footer {
        width: calc(100% - 32px);
    }

    #frame-meter {
        width: 150px;
    }

    .layout {
        padding: 80px 16px 48px;
    }

    h1 {
        font-size: 36px;
        line-height: 40px;
    }

    .stage-host {
        height: 560px;
    }

    /* Two tiles side by side on a phone. */
    .tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .grid-head {
        margin-top: 56px;
    }

    /* The whole line stays readable: it wraps instead of scrolling. */
    .install {
        width: 100%;
        border-radius: var(--kapow-radius-control);
    }

    .install code {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* A small phone has room for the bar's tools only; the footer keeps the links. */
@media (max-width: 400px) {
    .nav-links {
        display: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    a,
    .copy,
    .ghost-pill,
    .theme-toggle {
        transition: color 150ms, background-color 150ms, border-color 150ms;
    }
}
