/*
    Kept. A cellar at night: near-black wine, cream type, gold where something matters.
    Phone first: one column, big touch targets, a tab bar within thumb reach.
*/

:root {
    color-scheme: dark;

    --bg: #120a0e;
    --surface: #1e1217;
    --surface-raised: #2a1a21;
    --line: #3f2832;
    --text: #f5ede6;
    --muted: #b9a59d;
    --brand: #7b1e3a;
    --gold: #e3b24c;
    --gold-bright: #f3d283;
    --on-gold: #2a1a08;
    --danger: #ff9086;
    --ok: #a5dbb0;
    --warn: #f1cf86;

    --radius: 16px;
    --gutter: 1.1rem;
    --tabbar-height: 64px;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Wine colours. Every drawing of a bottle takes its colour from --wine. */
    --red: #a3213d;
    --white: #e6d37f;
    --rose: #f2a0ad;
    --sparkling: #cdbb85;
    --dessert: #d18f2c;
    --fortified: #7a3a22;
    --orange: #e78d3b;
    --unsorted: #8f807a;

    /* What racks are made of. */
    --wood: #6d4529;
    --wood-light: #94633d;
    --wood-dark: #3a2314;
    --steel: #b6bec4;
    --steel-dark: #58616a;
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(120% 34rem at 50% -8rem, rgba(123, 30, 58, .5), rgba(123, 30, 58, 0) 70%) no-repeat, var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--sans);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold-bright); text-underline-offset: 3px; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 .3rem; }
h2 { font-size: 1.25rem; margin: 2rem 0 .7rem; }
p { margin: .5rem 0; }
small, .muted { color: var(--muted); }
small { display: block; font-size: .82rem; line-height: 1.4; margin-top: .3rem; }
[hidden] { display: none !important; }

/* Frame */

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + .75rem) var(--gutter) .75rem;
    background: rgba(18, 10, 14, .74);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid rgba(227, 178, 76, .18);
    view-transition-name: topbar;
}

.brand { display: block; color: var(--text); }
.wordmark { display: block; height: 1.7rem; width: auto; }
.topbar form { margin: 0; }
.topbar .link { color: var(--muted); font-size: .88rem; text-decoration: none; }

.page {
    max-width: 44rem;
    margin: 0 auto;
    padding: 1.4rem var(--gutter) calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 3.2rem);
}

.crumb { margin: 0 0 .4rem; font-size: .88rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a::before { content: "‹ "; }

.tabbar {
    position: fixed;
    inset: auto .7rem calc(env(safe-area-inset-bottom) + .6rem);
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    max-width: 30rem;
    height: var(--tabbar-height);
    margin: 0 auto;
    padding: 0 .4rem;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(30, 18, 23, .82);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
    box-shadow: 0 14px 36px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
    view-transition-name: tabbar;
}

.tab {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: .45rem 0;
    color: var(--muted);
    font-size: .7rem;
    letter-spacing: .02em;
    text-decoration: none;
}

.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--gold-bright); }

/* Adding a bottle is what the app is for, so its tab is a button that stands proud of the bar. */
.tab-add svg {
    width: 46px;
    height: 46px;
    margin-top: -1.45rem;
    padding: 11px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--gold-bright), var(--gold) 55%, #b9872c);
    color: var(--on-gold);
    stroke-width: 2.2;
    box-shadow: 0 8px 20px rgba(227, 178, 76, .32), 0 0 0 4px var(--bg), inset 0 1px 0 rgba(255, 255, 255, .5);
}

/* Messages */

.flash, .notice, .problem, .validation-summary-errors {
    padding: .75rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    margin: 0 0 1rem;
}

.flash { background: rgba(165, 219, 176, .1); border-color: rgba(165, 219, 176, .3); color: var(--ok); }
.notice { background: rgba(227, 178, 76, .1); border-color: rgba(227, 178, 76, .3); color: var(--warn); }
.problem, .validation-summary-errors { background: rgba(255, 144, 134, .1); border-color: rgba(255, 144, 134, .35); color: var(--danger); }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }
.field-validation-error { color: var(--danger); font-size: .85rem; }

.empty {
    text-align: center;
    padding: 2.5rem 1.2rem;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.callout {
    display: grid;
    gap: .15rem;
    margin: 1.2rem 0;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(227, 178, 76, .45);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(227, 178, 76, .17), rgba(227, 178, 76, .04));
    color: var(--text);
    text-decoration: none;
}

.callout strong { font-family: var(--serif); font-size: 1.12rem; color: var(--gold-bright); }
.callout strong::after { content: " ›"; }
.callout span { color: var(--muted); font-size: .92rem; }
.callout.quiet { border-color: var(--line); background: linear-gradient(180deg, var(--surface-raised), var(--surface)); }
.hero .summary strong { color: var(--text); font-weight: 600; }

/* Buttons and forms */

.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 1.2rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: linear-gradient(160deg, var(--gold-bright), var(--gold) 55%, #b9872c);
    color: var(--on-gold);
    font: inherit;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(227, 178, 76, .2), inset 0 1px 0 rgba(255, 255, 255, .45);
}

.btn:active { translate: 0 1px; }
.btn.secondary { background: rgba(255, 255, 255, .03); border-color: var(--line); color: var(--text); box-shadow: none; }
.btn.danger { background: transparent; border-color: rgba(255, 144, 134, .5); color: var(--danger); box-shadow: none; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.actions .btn { flex: 1 1 10rem; }

button.link { border: 0; padding: 0; background: none; color: var(--gold-bright); font: inherit; text-decoration: underline; cursor: pointer; }

label { display: block; font-weight: 600; font-size: .86rem; letter-spacing: .01em; margin-bottom: .3rem; }
.field { margin-bottom: .95rem; }
.field .hint, label .hint { font-weight: 400; color: var(--muted); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.pair + small { margin: -.55rem 0 .95rem; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
    width: 100%;
    min-height: 50px;
    padding: .65rem .85rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, .3);
    color: var(--text);
    font: inherit;
}

input::placeholder { color: rgba(185, 165, 157, .6); }
textarea { min-height: 5rem; resize: vertical; }
select option { background: var(--surface); color: var(--text); }
input[type="checkbox"] { flex: none; width: 1.35rem; height: 1.35rem; accent-color: var(--gold); }

input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

details.more { margin-top: 1.4rem; }
details.more > summary { cursor: pointer; color: var(--gold-bright); font-weight: 600; padding: .5rem 0; }
details.more[open] > summary { margin-bottom: .6rem; }

.card {
    margin: 0 0 .8rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-raised), var(--surface));
    box-shadow: 0 10px 28px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .04);
}

fieldset.card { min-width: 0; }
.check { display: flex; align-items: center; gap: .7rem; margin: 0; font-size: 1rem; font-weight: 400; }
.check strong { font-family: var(--serif); font-size: 1.1rem; }
.suggestion > .muted { margin: .5rem 0 0; font-size: .9rem; }
.suggestion details.more { margin-top: .3rem; }

/* Three short fields side by side: what a wine costs and when to drink it. */
.trio { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: .6rem; }
.trio .field { margin-bottom: .3rem; }
.estimates { margin-bottom: 1.1rem; }
.estimates .notice { margin: .5rem 0; }
.estimates small { margin-bottom: .2rem; }
.estimates button.link, .place button.link { min-height: 44px; }

.place { margin-bottom: 1rem; scroll-margin-top: 5rem; }
.estimates { scroll-margin-top: 5rem; }

/* A suggestion the app has already filled in, with why. */
.advice {
    margin-bottom: .9rem;
    padding: .85rem 1rem;
    border: 1px solid rgba(227, 178, 76, .45);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(227, 178, 76, .16), rgba(227, 178, 76, .04));
}

.advice-label { display: block; color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.advice strong { display: block; font-family: var(--serif); font-size: 1.25rem; color: var(--gold-bright); }
.advice p { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; }

/* A form's first submit button is the one the return key presses. This one is there only to be that. */
.default-action, .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Where a wine is in its drinking window. */
.when { display: inline-block; padding: .05rem .5rem; border: 1px solid currentColor; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.when-hold { color: #9cc4e8; }
.when-ready { color: var(--ok); }
.when-drinksoon { color: var(--gold-bright); }
.when-past { color: var(--danger); }
.facts .when { margin-right: .35rem; }

.chips { display: flex; gap: .45rem; margin: 0 calc(var(--gutter) * -1) 1rem; padding: 0 var(--gutter); overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .88rem; text-decoration: none; }
.chip span { font-variant-numeric: tabular-nums; opacity: .75; }
.chip[aria-current="true"] { border-color: var(--gold); background: rgba(227, 178, 76, .14); color: var(--gold-bright); }

/* A plan: moves to make, in order. */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }

.step {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .15rem .8rem;
    align-items: center;
    margin-bottom: .6rem;
    padding: .8rem .9rem .8rem 2.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-raised), var(--surface));
    counter-increment: step;
}

.step::before {
    content: counter(step);
    position: absolute;
    top: .8rem;
    left: .8rem;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--wine, var(--unsorted));
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.step.first { border-color: rgba(227, 178, 76, .55); }
.step-tag { color: var(--gold-bright); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.step > * { grid-column: 1; }
.step form { grid-column: 2; grid-row: 1 / span 4; margin: 0; }
.step .btn { min-height: 44px; padding: 0 1rem; }
.step-wine { color: var(--text); font-family: var(--serif); font-size: 1.05rem; line-height: 1.25; text-decoration: none; }
.step-route { color: var(--muted); font-size: .88rem; }
.step-route strong { color: var(--gold-bright); font-weight: 600; }
.step-why { color: var(--muted); font-size: .8rem; line-height: 1.35; }

/* Cellar: the opening figures and the list */

.summary { color: var(--muted); margin: 0 0 1rem; }

.hero { margin-bottom: 1.3rem; }
.hero-count { margin: 0; font-size: 4.4rem; line-height: 1; color: var(--gold-bright); }
.hero-count span { margin-left: .5rem; font: 500 1.15rem var(--sans); letter-spacing: .02em; color: var(--muted); }
.hero .summary { margin: .25rem 0 1rem; }

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .hero-count {
        width: fit-content;
        background: linear-gradient(170deg, var(--gold-bright) 10%, var(--gold) 60%, #a97a25);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .hero-count span { -webkit-text-fill-color: var(--muted); }
}

.mix { display: flex; gap: 3px; height: 10px; border-radius: 999px; overflow: hidden; }
.mix-part { flex: 1 0 6px; background: var(--wine, var(--unsorted)); }
.mix-key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .65rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .86rem; }

.search { margin-bottom: 1rem; }
.search input { border-radius: 999px; padding-left: 1.1rem; }
.wines { list-style: none; margin: 0; padding: 0; }

.wine {
    position: relative;
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: .9rem;
    align-items: center;
    margin-bottom: .6rem;
    padding: .7rem .9rem .7rem 1.05rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-raised), var(--surface));
    color: inherit;
    text-decoration: none;
    overflow: hidden;
}

/* The stripe down the left edge is the wine's colour. */
.wine::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--wine, var(--unsorted)); }
.wine:active { background: var(--surface-raised); }

.thumb { width: 56px; height: 74px; border-radius: 9px; object-fit: cover; background: rgba(0, 0, 0, .35); }
.thumb.blank { display: grid; place-items: center; }
.wine-text { min-width: 0; }
.wine-title { display: block; font-family: var(--serif); font-size: 1.08rem; line-height: 1.25; }
.wine-meta { display: block; color: var(--muted); font-size: .84rem; line-height: 1.35; }
.wine-where { color: rgba(243, 210, 131, .78); }

.count {
    display: grid;
    place-items: center;
    min-width: 2.3rem;
    height: 2.3rem;
    padding: 0 .5rem;
    border: 1px solid rgba(227, 178, 76, .5);
    border-radius: 999px;
    color: var(--gold-bright);
    font-family: var(--serif);
    font-size: 1.05rem;
}

/* A colour class only names the wine's colour; whatever it sits on decides how to show it. */
.colour-red { --wine: var(--red); }
.colour-white { --wine: var(--white); }
.colour-rose { --wine: var(--rose); }
.colour-sparkling { --wine: var(--sparkling); }
.colour-dessert { --wine: var(--dessert); }
.colour-fortified { --wine: var(--fortified); }
.colour-orange { --wine: var(--orange); }

.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--wine, var(--unsorted)); }

/* Wine page */

.wine-head { display: grid; grid-template-columns: 112px 1fr; gap: 1.1rem; align-items: start; margin-bottom: 1.2rem; }
.wine-head img, .wine-head .thumb { display: block; width: 112px; height: 150px; border-radius: 14px; object-fit: cover; box-shadow: 0 14px 30px rgba(0, 0, 0, .5); }
.wine-head .thumb.blank { display: grid; }
.wine-head .thumb .dot { width: 1.6rem; height: 1.6rem; }
.wine-head h1 { font-size: 1.7rem; }
.wine-head p { margin: .1rem 0; }
.wine-name { font-family: var(--serif); font-size: 1.15rem; color: var(--gold-bright); }
.facts { margin: .6rem 0 .4rem; padding: 0; list-style: none; color: var(--muted); font-size: .92rem; }
.facts li + li { margin-top: .3rem; }

.bottle-where { display: block; font-family: var(--serif); font-size: 1.12rem; color: var(--text); text-decoration: none; }
a.bottle-where::after { content: " ›"; color: var(--gold); }
.card.bottle small { margin-top: 0; }
.card.bottle .actions { margin-top: .5rem; gap: 0 1.2rem; }
.card.bottle details { flex: 1 1 100%; }
.card.bottle details > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--gold-bright); font-weight: 600; cursor: pointer; }
.card.bottle details[open] > summary { margin-bottom: .5rem; }
.card.bottle form { margin: 0 0 .6rem; }

/* Capture */

.capture { display: block; margin: 1.25rem 0; }
.capture input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }

.capture-button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: .7rem;
    min-height: 13rem;
    border: 1.5px dashed rgba(227, 178, 76, .6);
    border-radius: 22px;
    background: radial-gradient(80% 80% at 50% 40%, rgba(227, 178, 76, .15), rgba(227, 178, 76, 0));
    color: var(--gold-bright);
    font-family: var(--serif);
    font-size: 1.3rem;
    cursor: pointer;
}

.capture input:focus-visible + .capture-button { outline: 2px solid var(--gold); outline-offset: 3px; }
.capture-button svg { width: 52px; height: 52px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.is-busy .capture-button { opacity: .4; pointer-events: none; }
.busy { text-align: center; font-family: var(--serif); font-size: 1.1rem; color: var(--gold-bright); animation: breathe 1.4s ease-in-out infinite; }
.label-photo { display: block; max-width: 100%; max-height: 17rem; margin: 0 auto 1rem; border-radius: 16px; box-shadow: 0 16px 36px rgba(0, 0, 0, .5); }

@keyframes breathe { 50% { opacity: .45; } }

/*
    Racks

    Every rack is drawn from the front. A bottle in a wooden rack points out at you, so it is a circle
    (.hole). A bottle in a fridge lies sideways behind the glass, so it is a bottle in profile (.profile).
    Either one is empty until it is also .filled, and then it takes the colour of its wine.

    Each drawing comes in two sizes: .full on the rack's own page, and .mini on the racks page, where
    everything is measured in --u, the width of one bottle end.
*/

.cellar-wall {
    --u: clamp(5px, 2vw, 10px);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 1.6rem .9rem;
    margin: 0 calc(var(--gutter) * -1) 1.3rem;
    padding: 1.8rem .9rem 1.3rem;
    border-block: 1px solid var(--line);
    background:
        radial-gradient(90% 60% at 50% 0, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 70%),
        linear-gradient(180deg, #1c1116, #150c10);
}

/* Each rack takes only the width of its drawing, so a long name wraps under it instead of pushing its neighbours away. */
.standing { display: grid; justify-items: center; width: min-content; color: inherit; text-align: center; text-decoration: none; }
.standing-name { margin-top: .6rem; font-family: var(--serif); font-size: .92rem; line-height: 1.2; }
.standing-count { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.standing:active .rack { scale: .97; }

.rack-stage { margin: 0 calc(var(--gutter) * -1) 1.3rem; padding: .6rem var(--gutter) 1.3rem; overflow-x: auto; }
.rack-stage .rack { margin-inline: auto; }
.rack { position: relative; transition: scale .12s ease; }

/* A bottle end-on. Empty, it is the dark mouth of the slot. */
.hole {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 58%, #040202 0 55%, rgba(0, 0, 0, .5) 58%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
    color: rgba(245, 237, 230, .4);
    font: normal 500 .6rem/1 var(--sans);
    text-decoration: none;
}

.hole.filled {
    background: var(--wine, var(--unsorted));
    box-shadow: 0 1px 3px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(0, 0, 0, .35);
    color: rgba(0, 0, 0, .78);
    font-weight: 700;
    font-size: .78rem;
}

/* A bottle in profile, neck to the right. Empty, it is a faint outline of where one would lie. */
.profile {
    display: block;
    aspect-ratio: 3.4;
    clip-path: polygon(3% 0, 56% 0, 63% 7%, 68% 18%, 72% 30%, 95% 30%, 95% 24%, 100% 24%, 100% 76%, 95% 76%, 95% 70%, 72% 70%, 68% 82%, 63% 93%, 56% 100%, 3% 100%, 0 88%, 0 12%);
    background: rgba(255, 255, 255, .075);
}

.profile.filled {
    --foil: rgba(0, 0, 0, .42);
    background:
        linear-gradient(#f7efe1, #e6d8bd) 22% 50% / 27% 64% no-repeat,
        linear-gradient(90deg, rgba(0, 0, 0, 0) 81%, var(--foil) 81%),
        linear-gradient(180deg, rgba(255, 255, 255, .45) 4%, rgba(255, 255, 255, 0) 40%, rgba(0, 0, 0, .5) 100%),
        var(--wine, var(--unsorted));
}

.profile.filled.colour-sparkling { --foil: var(--gold); }

/* Bottles are laid neck to neck, as they are on a real shelf. */
.profile:nth-child(even) { scale: -1 1; }

a.hole:active, a.profile:active { filter: brightness(1.35); }

@supports (color: color-mix(in srgb, red, blue)) {
    /* The foil cap on the end of the bottle, catching the light. */
    .hole.filled {
        background:
            radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .6) 0 6%, rgba(255, 255, 255, 0) 24%),
            radial-gradient(circle, color-mix(in srgb, var(--wine, var(--unsorted)) 80%, #fff) 0 17%, var(--wine, var(--unsorted)) 20% 48%, color-mix(in srgb, var(--wine, var(--unsorted)) 52%, #000) 72%);
    }
}

/* Opened from a wine, the rack dims and that wine's bottles stay lit. */
.rack:has(.lit) .filled:not(.lit) { opacity: .28; }
.hole.lit { box-shadow: 0 0 0 2px var(--gold-bright), 0 0 16px 5px rgba(243, 210, 131, .75); animation: glow 1.1s ease-in-out infinite alternate; }
.profile.lit { animation: gleam 1.1s ease-in-out infinite alternate; }

@keyframes glow { to { box-shadow: 0 0 0 2px var(--gold), 0 0 5px 1px rgba(243, 210, 131, .35); } }
@keyframes gleam { to { filter: brightness(1.7); } }

.axis { display: grid; place-items: center; color: rgba(245, 237, 230, .55); font: normal 500 .68rem/1 var(--sans); }

/* Bottles in a rack but in no slot. Inside a fridge this is the bay at the bottom. */
.bay {
    display: grid;
    grid-template-columns: repeat(var(--per), minmax(0, 2.4rem));
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px;
    border: 1px dashed rgba(255, 255, 255, .2);
    border-radius: 10px;
}

.mini .bay { grid-template-columns: repeat(var(--per), var(--u)); gap: 2px; margin-top: 3px; padding: 2px; border: 0; }

/* A rack with a slot for every bottle: timber, with a dark hole for each. */

.rack-slots { --track: minmax(1.75rem, 2.5rem); --break: .5rem; --axis: 1.3rem; }
.rack-slots.full { width: fit-content; }
.rack-slots.mini { --track: var(--u); --break: calc(var(--u) * .7); }

.slot-grid {
    display: grid;
    gap: 5px;
    padding: 8px 12px 13px 7px;
    border-radius: 12px;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, .1) 0 1px, rgba(0, 0, 0, 0) 1px 7px),
        linear-gradient(90deg, var(--wood-dark), var(--wood) 12%, var(--wood-light) 50%, var(--wood) 88%, var(--wood-dark));
    box-shadow: 0 16px 34px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .14);
}

/* Row numbers stay in view while a wide rack scrolls sideways. */
.slot-grid .axis-row { position: sticky; left: 4px; z-index: 1; border-radius: 6px; background: var(--wood-dark); }

.rack-slots.mini .slot-grid { gap: 2px; padding: 4px; border-radius: 4px; box-shadow: 0 8px 16px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .14); }

/* Shelves and fridges: each row is a shelf holding several bottles. */

.shelf { display: flex; align-items: center; gap: 6px; }
.shelf-run { flex: 1; display: grid; grid-template-columns: repeat(var(--per), minmax(0, 1fr)); gap: 4px; padding: 5px 0 4px; }

.rack-shelves {
    padding: 8px 14px 0;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--wood) 0 9px, rgba(0, 0, 0, .34) 9px calc(100% - 9px), var(--wood) calc(100% - 9px));
    box-shadow: 0 16px 34px rgba(0, 0, 0, .5);
}

.rack-shelves .shelf { margin-bottom: 6px; border-bottom: 7px solid var(--wood-light); box-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.rack-shelves.full { width: min(100%, 24rem); }
.rack-shelves.mini { padding: 3px 6px 0; border-radius: 3px; background: linear-gradient(90deg, var(--wood) 0 3px, rgba(0, 0, 0, .34) 3px calc(100% - 3px), var(--wood) calc(100% - 3px)); box-shadow: 0 8px 16px rgba(0, 0, 0, .5); }
.rack-shelves.mini .shelf { margin-bottom: 2px; border-bottom-width: 2px; box-shadow: none; }
.rack-shelves.mini .shelf-run { grid-template-columns: repeat(var(--per), var(--u)); gap: 2px; padding: 2px 0 1px; }

.rack-fridge {
    padding: 0 16px 12px 12px;
    border: 3px solid var(--steel-dark);
    border-radius: 16px;
    background: linear-gradient(180deg, #121a20, #080c0f);
    box-shadow:
        inset 0 0 0 2px rgba(182, 190, 196, .55),
        inset 0 0 50px rgba(60, 130, 190, .14),
        0 18px 40px rgba(0, 0, 0, .55);
}

/* The glass door: a sheen across it and a handle down one side. */
.rack-fridge::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(112deg, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, 0) 24%, rgba(255, 255, 255, 0) 66%, rgba(255, 255, 255, .06) 100%);
    pointer-events: none;
}

.rack-fridge::after {
    content: "";
    position: absolute;
    top: 24%;
    bottom: 24%;
    right: 4px;
    width: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--steel-dark), var(--steel), var(--steel-dark));
    pointer-events: none;
}

.fridge-head { display: flex; justify-content: center; align-items: center; min-height: 2.1rem; }
.fridge-temp { color: #86ccff; font: 600 .82rem ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; text-shadow: 0 0 10px rgba(70, 160, 255, .95); }
.rack-fridge.full { width: min(100%, 23rem); }
.rack-fridge .shelf { border-bottom: 2px solid rgba(182, 190, 196, .3); }
.rack-fridge .shelf-run { gap: 4px 6px; padding: 6px 0 5px; }
.rack-fridge .bay { grid-template-columns: repeat(var(--per), minmax(0, 1fr)); gap: 6px 10px; margin-top: 0; padding: 10px 7% 2px; border: 0; }

.rack-fridge.mini { padding: 0 calc(var(--u) * .85) calc(var(--u) * .5) calc(var(--u) * .6); border-width: 2px; border-radius: calc(var(--u) * .9); box-shadow: inset 0 0 0 1px rgba(182, 190, 196, .5), 0 10px 20px rgba(0, 0, 0, .55); }
.rack-fridge.mini::after { right: 1px; width: 2px; }
.rack-fridge.mini .fridge-head { min-height: calc(var(--u) * 1.7); }
.rack-fridge.mini .fridge-temp { font-size: calc(var(--u) * 1.05); letter-spacing: 0; text-shadow: 0 0 5px rgba(70, 160, 255, .95); }
.rack-fridge.mini .shelf { border-bottom-width: 1px; }
.rack-fridge.mini .shelf-run { grid-template-columns: repeat(var(--per), calc(var(--u) * 2)); gap: 1px 2px; padding: 1px 0; }
.rack-fridge.mini .profile { aspect-ratio: 4.4; }
.rack-fridge.mini .bay { grid-template-columns: repeat(var(--per), minmax(0, 1fr)); gap: 1px 3px; padding: 3px 6% 0; }

/* Diamond bins: a cube crossed corner to corner, with a pile of bottles in each quarter. */

.cubes { display: grid; grid-template-columns: repeat(var(--cubes), minmax(8.5rem, 12rem)); gap: 8px; }
.rack-bins.full { width: fit-content; max-width: none; }
.rack-bins.mini .cubes { grid-template-columns: repeat(var(--cubes), calc(var(--u) * 6.5)); gap: 3px; }

.cube {
    --slat: 3px;
    position: relative;
    aspect-ratio: 1;
    border: 7px solid var(--wood);
    border-radius: 6px;
    background:
        linear-gradient(45deg, rgba(0, 0, 0, 0) calc(50% - var(--slat)), var(--wood-light) calc(50% - var(--slat)) calc(50% + var(--slat)), rgba(0, 0, 0, 0) calc(50% + var(--slat))),
        linear-gradient(-45deg, rgba(0, 0, 0, 0) calc(50% - var(--slat)), var(--wood-light) calc(50% - var(--slat)) calc(50% + var(--slat)), rgba(0, 0, 0, 0) calc(50% + var(--slat))),
        #0d0806;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .5), inset 0 0 18px rgba(0, 0, 0, .8);
}

.mini .cube { --slat: 1px; border-width: 3px; border-radius: 3px; box-shadow: 0 8px 16px rgba(0, 0, 0, .5); }
.cube .hole { position: absolute; translate: -50% -50%; pointer-events: none; }

.bin { position: absolute; inset: 0; }
.bin:active { background: rgba(227, 178, 76, .22); }
.bin-top { clip-path: polygon(0 0, 100% 0, 50% 50%); }
.bin-right { clip-path: polygon(100% 0, 100% 100%, 50% 50%); }
.bin-bottom { clip-path: polygon(0 100%, 100% 100%, 50% 50%); }
.bin-left { clip-path: polygon(0 0, 0 100%, 50% 50%); }

.cube-name {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    translate: -50% -50%;
    border-radius: 50%;
    background: var(--wood-light);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
    color: var(--on-gold);
    font: 700 .75rem/1 var(--sans);
    pointer-events: none;
}

.rack-contents { list-style: none; margin: 0; padding: 0; }
.rack-contents li { display: flex; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.rack-contents .slot-name { flex: 0 0 4.8rem; color: rgba(243, 210, 131, .78); font-size: .88rem; }
.rack-contents .slot-wines { display: grid; gap: .3rem; }
.rack-contents a { color: var(--text); font-family: var(--serif); text-decoration: none; }

/* History */

.history { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 1px solid var(--line); }
.history li { position: relative; padding: 0 0 1.1rem; }
.history li::before { content: ""; position: absolute; left: calc(-1.1rem - 5px); top: .45rem; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px var(--bg); }
.history time { display: block; color: var(--muted); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.history a { color: var(--text); font-family: var(--serif); font-size: 1.08rem; text-decoration: none; }
.history q { display: block; color: var(--muted); font-style: italic; }

/* Sign-in */

.signin { max-width: 22rem; margin: 2.5rem auto; text-align: center; }
.signin-icon { display: block; margin: 0 auto 1.4rem; border-radius: 18px; box-shadow: 0 18px 40px rgba(0, 0, 0, .55); }
.signin form { text-align: left; margin-top: 1.4rem; }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    * { animation: none !important; transition: none !important; }
}
