/* Kept. Phone first: one column, big touch targets, a tab bar within thumb reach. */

:root {
    color-scheme: light dark;
    --bg: #faf7f5;
    --surface: #ffffff;
    --text: #1f1a1c;
    --muted: #6b6266;
    --border: #e6dfe1;
    --accent: #7b1e3a;
    --on-accent: #ffffff;
    --danger: #a8261c;
    --ok-bg: #e8f3ea;
    --ok-text: #1f5a2c;
    --warn-bg: #fbf0d9;
    --warn-text: #6b4a05;
    --radius: 12px;
    --tabbar-height: 62px;

    /* The brand bar keeps the logo's colours in light and dark mode alike. */
    --brand: #7b1e3a;
    --on-brand: #f7efe3;

    --red: #7b1e3a;
    --white: #e6cf6a;
    --rose: #ef9aa6;
    --sparkling: #cdbb86;
    --dessert: #c98a2b;
    --fortified: #4d2518;
    --orange: #e08a3c;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151113;
        --surface: #1f1a1c;
        --text: #f1ebed;
        --muted: #a79ea2;
        --border: #352d30;
        --accent: #cf5a78;
        --on-accent: #1a0d12;
        --danger: #ef7b70;
        --ok-bg: #1d3323;
        --ok-text: #a9dcb4;
        --warn-bg: #3a2e12;
        --warn-text: #f0d48a;
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
p { margin: .5rem 0; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Frame */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + .6rem) 1rem .6rem;
    background: var(--brand);
    color: var(--on-brand);
}

.brand { display: block; color: inherit; }
.wordmark { display: block; height: 1.75rem; width: auto; }
.topbar form { margin: 0; }
.topbar .link { color: inherit; opacity: .85; }

.page {
    max-width: 44rem;
    margin: 0 auto;
    padding: 1rem 1rem calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 1.5rem);
}

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.tab {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: .72rem;
    text-decoration: none;
}

.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Messages */

.flash, .notice, .problem {
    padding: .7rem .9rem;
    border-radius: var(--radius);
    margin: 0 0 1rem;
}

.flash { background: var(--ok-bg); color: var(--ok-text); }
.notice { background: var(--warn-bg); color: var(--warn-text); }
.problem, .validation-summary-errors { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.validation-summary-errors { padding: .7rem .9rem; border-radius: var(--radius); margin: 0 0 1rem; }
.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 1rem;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Buttons and forms */

.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 1.1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn.secondary { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.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(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
    width: 100%;
    min-height: 48px;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea { min-height: 5rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

details.more { margin-top: 1.25rem; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: .5rem 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem;
    margin-bottom: .75rem;
}

/* Cellar list */

.summary { color: var(--muted); margin: 0 0 .9rem; }
.search { margin-bottom: 1rem; }
.wines { list-style: none; margin: 0; padding: 0; }

.wine {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: .8rem;
    align-items: center;
    padding: .65rem .8rem;
    margin-bottom: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}

.thumb {
    width: 52px;
    height: 68px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--border);
}

.thumb.blank { display: grid; place-items: center; }
.wine-title { font-weight: 600; }
.wine-title .vintage { font-weight: 400; color: var(--muted); }
.wine-meta { display: block; color: var(--muted); font-size: .85rem; }
.count { min-width: 2.2rem; padding: .2rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); text-align: center; font-weight: 600; }

/* A colour class only names the wine's colour; the dot or slot 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(--muted)); vertical-align: baseline; }

/* Wine page */

.wine-head { display: grid; grid-template-columns: 96px 1fr; gap: 1rem; align-items: start; margin-bottom: 1rem; }
.wine-head img, .wine-head .thumb { width: 96px; height: 128px; border-radius: var(--radius); object-fit: cover; }
.facts { margin: .5rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .95rem; }
.bottle-where { font-weight: 600; }
.bottle .actions { margin-top: .6rem; }
.bottle details { flex: 1 1 100%; }
.bottle details > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; cursor: pointer; }
.bottle details[open] > summary { margin-bottom: .5rem; }
.bottle form { margin: 0; }

/* 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: .5rem;
    min-height: 11rem;
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
}

.capture input:focus-visible + .capture-button { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.capture-button svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.is-busy .capture-button { opacity: .45; pointer-events: none; }
.busy { text-align: center; font-weight: 600; }
.label-photo { display: block; max-width: 100%; max-height: 16rem; margin: 0 auto 1rem; border-radius: var(--radius); }

/* Racks */

.rack-link { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: inherit; text-decoration: none; }
.meter { height: 6px; margin-top: .5rem; border-radius: 3px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

.rack-scroll { overflow-x: auto; margin: 0 -1rem 1rem; padding: 0 1rem .5rem; }

.rack-grid {
    display: grid;
    grid-template-columns: 1.6rem repeat(var(--columns), minmax(2.4rem, 1fr));
    gap: 4px;
    min-width: calc(1.6rem + var(--columns) * 2.4rem + var(--columns) * 4px);
}

.rack-grid .axis { display: grid; place-items: center; color: var(--muted); font-size: .72rem; }

.slot {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border: 1.5px dashed var(--border);
    border-radius: 50%;
    color: var(--muted);
    font-size: .68rem;
    text-decoration: none;
}

.slot.filled { border: 0; background: var(--wine, var(--muted)); color: #fff; font-weight: 600; }
.slot.filled.colour-white, .slot.filled.colour-rose, .slot.filled.colour-sparkling { color: #2a2024; }
.slot.target { border: 2px solid var(--accent); color: var(--accent); }
.rack-contents { list-style: none; margin: 0; padding: 0; }
.rack-contents li { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.rack-contents .slot-name { display: inline-block; min-width: 2.6rem; font-weight: 600; }

/* History */

.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.history time { display: block; color: var(--muted); font-size: .85rem; }
.history q { display: block; color: var(--muted); font-style: italic; }

.signin { max-width: 22rem; margin: 3rem auto; }
.signin-icon { display: block; margin-bottom: 1.25rem; }
