/* The storefront — every store's, in its base theme.
 *
 * Light and dark from one set of tokens, every colour defined once on :root
 * and redefined under prefers-color-scheme. A theme (assets/themes/*.css) is
 * loaded after this file and redefines the same tokens; anything a theme
 * does not mention looks like this. No build step, no framework, no
 * webfont: the page has to come up fast on a phone over a bad connection,
 * because it is the page a purchase link opens.
 */

:root {
    color-scheme: light dark;

    --bg: #fbfbfa;
    --bg-raised: #ffffff;
    --bg-sunken: #f1f2f0;
    --fg: #16181a;
    --fg-muted: #5e646c;
    --fg-faint: #868d96;
    --rule: #e2e4e2;
    --rule-strong: #c9ccc9;

    --accent: #0b6bcb;
    --accent-fg: #ffffff;
    --accent-soft: #e8f1fc;

    --good: #16794c;
    --good-soft: #e4f4ec;
    --warn: #8a5a00;
    --warn-soft: #fcf2dd;
    --bad: #9d2f22;
    --bad-soft: #fbe9e6;

    --shadow: 0 1px 2px rgba(16, 18, 20, .05), 0 6px 20px rgba(16, 18, 20, .06);
    --radius: 14px;
    --radius-sm: 9px;
    --wrap: 70rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131517;
        --bg-raised: #1b1e21;
        --bg-sunken: #0e1012;
        --fg: #edeff1;
        --fg-muted: #a3abb4;
        --fg-faint: #7d858e;
        --rule: #2a2e32;
        --rule-strong: #3d4248;

        --accent: #5aa6f5;
        --accent-fg: #0b1420;
        --accent-soft: #15283c;

        --good: #5fcf9b;
        --good-soft: #10281e;
        --warn: #e2b75d;
        --warn-soft: #2a2110;
        --bad: #f0907c;
        --bad-soft: #2d1714;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-rendering: optimizeLegibility;
}

.wrap {
    max-width: var(--wrap);
    margin: 0 auto;
    padding-inline: 20px;
}

a {
    color: var(--accent);
}

/* Visible only when tabbed to: the first stop for a keyboard or a screen
   reader, since the product navigation can be long. */
.skip {
    position: absolute;
    left: -9999px;
}

.skip:focus {
    left: 1rem;
    top: 1rem;
    z-index: 10;
    background: var(--bg-raised);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: .5rem .9rem;
    text-decoration: none;
}

/* ------------------------------------------------------------- masthead */

.masthead {
    border-bottom: 1px solid var(--rule);
    background: var(--bg-raised);
    position: sticky;
    top: 0;
    z-index: 5;
}

.masthead .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1.4rem;
    padding-block: .85rem;
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: .5rem;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-mark {
    width: .7rem;
    height: .7rem;
    border-radius: 3px;
    background: var(--accent);
    align-self: center;
}

.brand-logo {
    height: 1.6rem;
    width: auto;
    max-width: 8rem;
    object-fit: contain;
    align-self: center;
}

.brand-name {
    font-size: 1.1rem;
}

.brand-sub {
    color: var(--fg-faint);
    font-weight: 500;
    font-size: .95rem;
}

.products {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-left: auto;
}

.products a {
    display: inline-block;
    padding: .3rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--rule);
    color: var(--fg-muted);
    text-decoration: none;
    font-size: .9rem;
}

.products a:hover {
    border-color: var(--rule-strong);
    color: var(--fg);
}

.products a[aria-current="page"] {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
    font-weight: 600;
}

/* ---------------------------------------------------------------- intro */

.intro {
    padding-block: 2.4rem 1.6rem;
    max-width: 46rem;
}

.intro h1 {
    font-size: clamp(1.6rem, 4.2vw, 2.3rem);
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0 0 .5rem;
}

.intro .tagline {
    font-size: 1.12rem;
    color: var(--fg-muted);
    margin: 0 0 .8rem;
}

.intro .blurb {
    color: var(--fg-muted);
    margin: 0 0 .8rem;
    white-space: pre-wrap;
}

.intro .links {
    margin: 0;
    font-size: .94rem;
}

/* --------------------------------------------------------------- banner */

.banner {
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    margin-bottom: 1.4rem;
    font-size: .95rem;
    border: 1px solid transparent;
}

.banner.warn {
    background: var(--warn-soft);
    border-color: color-mix(in srgb, var(--warn) 30%, transparent);
    color: var(--warn);
}

.banner.good {
    background: var(--good-soft);
    border-color: color-mix(in srgb, var(--good) 30%, transparent);
    color: var(--good);
}

/* ---------------------------------------------------------------- items */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 1.1rem;
    padding-bottom: 2.5rem;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.3rem 1.25rem 1.15rem;
    box-shadow: var(--shadow);
}

.card.featured {
    border-color: var(--accent);
}

.card .badge {
    position: absolute;
    top: -.65rem;
    left: 1.1rem;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: .2rem .6rem;
}

.card .for {
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--fg-faint);
    margin-bottom: .25rem;
}

.card h3 {
    margin: 0 0 .3rem;
    font-size: 1.18rem;
    letter-spacing: -.01em;
}

.card .headline {
    margin: 0 0 .9rem;
    color: var(--fg-muted);
    font-size: .95rem;
}

.card img.shot {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--rule);
    margin-bottom: .9rem;
    display: block;
}

.price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .2rem;
}

.price .amount {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.03em;
}

.price .per {
    color: var(--fg-muted);
    font-size: .95rem;
}

.price .was {
    color: var(--fg-faint);
    text-decoration: line-through;
    font-size: .95rem;
}

.terms {
    color: var(--fg-faint);
    font-size: .86rem;
    margin: 0 0 1rem;
    min-height: 1.3em;
}

.card ul {
    list-style: none;
    margin: 0 0 1.2rem;
    padding: 0;
    font-size: .93rem;
    display: grid;
    gap: .4rem;
}

.card ul li {
    display: grid;
    grid-template-columns: 1.1rem 1fr;
    gap: .4rem;
    color: var(--fg-muted);
}

.card ul li::before {
    content: "";
    width: .5rem;
    height: .5rem;
    margin-top: .45rem;
    border-radius: 2px;
    background: var(--accent);
    opacity: .75;
}

.card .buy-row {
    margin-top: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    font: inherit;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--rule-strong);
    background: var(--bg-sunken);
    color: var(--fg);
    padding: .65rem 1rem;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--fg-faint);
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
}

.btn.primary:hover {
    filter: brightness(1.07);
}

.btn.ghost {
    background: transparent;
}

.btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.btn.small {
    width: auto;
    padding: .35rem .8rem;
    font-size: .88rem;
    text-decoration: none;
}

/* A button that reads as a link: the quiet actions in the signed-in bar. */
button.link {
    font: inherit;
    font-size: .9rem;
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ------------------------------------------------------- signed-in bar */

/* Under the masthead when the visitor came from one of the store's apps:
   who they are, and the way back. Tinted so it reads as "you", not as part
   of the shop's chrome. */
.viewer {
    border-top: 1px solid var(--rule);
    background: var(--accent-soft);
    font-size: .92rem;
}

.viewer .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1.2rem;
    padding-block: .55rem;
}

.viewer-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
}

.card .owned {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--good);
    padding: .65rem 0;
    margin-right: auto;
}

.card .buy-row:has(.owned) {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.card .buy-row:has(.owned) .btn {
    width: auto;
}

.btn:focus-visible,
.products a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------- empty, loading */

.loading,
.empty {
    padding: 3rem 0 4rem;
    color: var(--fg-muted);
    text-align: center;
}

.empty strong {
    color: var(--fg);
}

.spinner {
    display: inline-block;
    width: .85rem;
    height: .85rem;
    border: 2px solid var(--rule-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: -.1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2.4s;
    }
}

/* --------------------------------------------------------------- dialog */

dialog {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--bg-raised);
    color: var(--fg);
    padding: 0;
    width: min(28rem, calc(100vw - 2rem));
    box-shadow: 0 10px 50px rgba(0, 0, 0, .25);
}

dialog::backdrop {
    background: rgba(12, 14, 16, .55);
}

dialog form {
    padding: 1.4rem 1.3rem 1.2rem;
}

dialog h2 {
    margin: 0 0 .25rem;
    font-size: 1.2rem;
}

.buy-price {
    margin: 0 0 1.1rem;
    color: var(--fg-muted);
}

.field {
    display: block;
    margin-bottom: 1rem;
    font-size: .92rem;
    font-weight: 600;
}

.field input {
    display: block;
    width: 100%;
    font: inherit;
    font-weight: 400;
    margin-top: .35rem;
    padding: .55rem .7rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--fg);
}

.field .hint {
    display: block;
    margin-top: .3rem;
    font-weight: 400;
    font-size: .84rem;
    color: var(--fg-faint);
}

.buy-actions {
    display: flex;
    gap: .6rem;
    margin-top: 1.2rem;
}

.buy-actions .btn {
    width: auto;
    flex: 1;
}

.msg {
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    font-size: .9rem;
    font-weight: 400;
}

.msg.bad {
    background: var(--bad-soft);
    color: var(--bad);
}

.msg.info {
    background: var(--accent-soft);
    color: var(--accent);
}

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

footer {
    border-top: 1px solid var(--rule);
    padding-block: 1.6rem 3rem;
    color: var(--fg-muted);
    font-size: .92rem;
}

footer p {
    margin: 0 0 .5rem;
    max-width: 46rem;
}

.fine {
    color: var(--fg-faint);
    font-size: .85rem;
}

/* ------------------------------------------------------------- the order
   page, which shares this stylesheet. */

.order {
    max-width: 34rem;
    margin: 0 auto;
    padding-block: 4rem 3rem;
}

.order .card {
    box-shadow: var(--shadow);
}

.order h1 {
    font-size: 1.5rem;
    margin: 0 0 .4rem;
    letter-spacing: -.02em;
}

.order .state {
    display: inline-flex;
    /* .card is a flex column, so an inline-flex child is stretched to the full
       width unless it is told not to be. */
    align-self: flex-start;
    align-items: center;
    gap: .45rem;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: .2rem .65rem;
    margin-bottom: 1rem;
}

.order .state.good {
    background: var(--good-soft);
    color: var(--good);
}

.order .state.wait {
    background: var(--warn-soft);
    color: var(--warn);
}

.order .state.bad {
    background: var(--bad-soft);
    color: var(--bad);
}

dl.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .45rem 1rem;
    margin: 0 0 1.3rem;
    font-size: .94rem;
}

dl.facts dt {
    color: var(--fg-faint);
}

dl.facts dd {
    margin: 0;
}

.keys {
    background: var(--bg-sunken);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1.2rem;
}

.keys h2 {
    font-size: .95rem;
    margin: 0 0 .6rem;
}

.key {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}

.key code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem;
    letter-spacing: .04em;
    background: var(--bg-raised);
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    padding: .3rem .55rem;
    user-select: all;
}

.key button {
    font: inherit;
    font-size: .82rem;
    padding: .25rem .6rem;
    border-radius: 6px;
    border: 1px solid var(--rule-strong);
    background: var(--bg-raised);
    color: var(--fg);
    cursor: pointer;
}
