/* ==========================================================================
   Cellar Log — design system
   Same structure as the Brew Log stylesheet (dark surface, condensed display
   face, one accent), re-skinned for wine: burgundy as the primary, aged gold
   as the highlight, on a warm near-black that leans plum rather than brown.

   Palette
       --wine        #8c1f3d   burgundy
       --wine-bright #b02c50
       --wine-deep   #5e1329
       --gold        #c9a227   aged gold
       --bg          #120a0e
   ========================================================================== */

/* ------------------------------------------------------------------ fonts */

@font-face {
    font-family: 'Anton';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/anton-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-400.woff2') format('woff2');
}

/* ----------------------------------------------------------------- tokens */

:root {
    /* surfaces */
    --bg:            #120a0e;
    --bg-raised:     #1b1015;
    --bg-raised-2:   #241620;
    --bg-input:      #150d12;

    /* lines */
    --border:        #3a2430;
    --border-strong: #543445;

    /* text */
    --text:          #f4eef0;
    --text-muted:    #b6a5ad;
    --text-faint:    #82707a;

    /* brand */
    --wine:          #8c1f3d;
    --wine-bright:   #b02c50;
    --wine-deep:     #5e1329;
    --wine-dim:      rgba(140, 31, 61, 0.18);
    --wine-text:     #dc93aa;

    /* gold */
    --gold:          #c9a227;
    --gold-bright:   #e2bd55;
    --gold-dim:      rgba(201, 162, 39, 0.14);

    /* status */
    --warn:          #dda23c;
    --warn-dim:      rgba(221, 162, 60, 0.14);
    --danger:        #cf4b52;
    --danger-dim:    rgba(207, 75, 82, 0.14);
    --success:       #7fae4a;
    --success-dim:   rgba(127, 174, 74, 0.14);

    --radius:        10px;
    --radius-sm:     6px;
    --radius-lg:     16px;

    --shadow:        0 1px 2px rgba(0, 0, 0, .45), 0 10px 30px rgba(0, 0, 0, .35);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --display: 'Anton', 'Arial Narrow', Impact, sans-serif;
    --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--wine-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.15; font-weight: 650; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 .75rem; }

.display {
    font-family: var(--display);
    font-weight: 400;
    letter-spacing: .01em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(18, 10, 14, .94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar__inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand__mark {
    filter: drop-shadow(0 0 10px rgba(140, 31, 61, .45));
}

.brand__text {
    font-family: var(--display);
    font-size: 1.22rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gold-bright);
}

.nav { display: flex; gap: .25rem; flex: 1; }

.nav__link {
    padding: .4rem .8rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: .92rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .12s ease, color .12s ease;
}
.nav__link:hover { background: var(--bg-raised-2); color: var(--text); text-decoration: none; }
.nav__link.is-active {
    background: var(--wine-dim);
    color: var(--wine-text);
    box-shadow: inset 0 -2px 0 var(--wine);
}

.topbar__logout { display: flex; align-items: center; gap: .6rem; }
.topbar__user {
    color: var(--text-muted);
    font-size: .85rem;
    font-family: var(--mono);
    padding: .15rem .5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
}

/* ------------------------------------------------------------------ page */

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 4rem;
}
.page--narrow { max-width: 460px; }

.page__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page__title {
    margin: 0;
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.85rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text);
}
.page__sub { color: var(--text-muted); font-size: .9rem; margin: .15rem 0 0; }

/* ----------------------------------------------------------------- cards */

.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}

/* A thin burgundy seam along the top of each card. */
.card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(90deg, var(--wine-deep), var(--wine) 40%, transparent 85%);
    opacity: .9;
}

.card__head {
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card__title { margin: 0; font-size: 1rem; font-weight: 650; letter-spacing: .01em; }
.card__hint { color: var(--text-faint); font-size: .82rem; }
.card__body { padding: 1.1rem; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }

@media (max-width: 1000px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .topbar__inner { flex-wrap: wrap; gap: .75rem; }
    .nav { order: 3; width: 100%; overflow-x: auto; }
    .page__title { font-size: 1.5rem; }
}

/* ----------------------------------------------------------------- stats */

.stat {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
}
.stat__label {
    color: var(--text-faint);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 600;
}
.stat__value {
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.75rem;
    letter-spacing: .02em;
    line-height: 1.2;
    color: var(--gold-bright);
}
.stat__meta { color: var(--text-muted); font-size: .83rem; }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: .9rem; }
.field--narrow { max-width: 8rem; }
.field__label {
    display: block;
    font-size: .74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-muted);
    margin-bottom: .3rem;
}
.field__hint { color: var(--text-muted); font-size: .8rem; margin-top: .25rem; }
.field__error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 6rem; }
.field-row > .field--narrow { flex: 0 0 8rem; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="email"], textarea, select {
    width: 100%;
    padding: .5rem .65rem;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: .92rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--wine-bright);
    box-shadow: 0 0 0 3px var(--wine-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 5rem; }

.input--mini {
    width: 4rem;
    padding: .25rem .4rem;
    font-size: .78rem;
    font-family: var(--mono);
}
.input--wide { width: 8rem; }

.inline-form {
    display: inline-flex;
    gap: .3rem;
    align-items: center;
    margin: 0;
}

.rule {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .9rem;
    color: var(--text);
    cursor: pointer;
}

/* Hide the native number spinners — they jar against the dark theme. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* The native date picker's calendar icon is near-black on near-black. */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.75) sepia(1) saturate(3) hue-rotate(310deg) brightness(1.1);
    cursor: pointer;
    opacity: .7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Dark scrollbars to match the page. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 6px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--wine-deep); }

.strong { font-weight: 650; color: var(--text); }

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem .95rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--wine);
    color: #fbdfe7;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 650;
    letter-spacing: .01em;
    cursor: pointer;
    text-decoration: none;
    transition: filter .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-muted);
}
.btn--ghost:hover { background: var(--bg-raised-2); color: var(--text); }

.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-dim); }

.btn--sm { padding: .3rem .6rem; font-size: .78rem; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- tables */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
table.data th {
    text-align: left;
    padding: .55rem .8rem;
    color: var(--text-faint);
    font-size: .7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-raised-2);
    white-space: nowrap;
}
table.data td {
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-raised-2); }
table.data .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
table.data .comment { color: var(--text-muted); font-size: .84rem; }

.short { display: none; }

@media (max-width: 720px) {
    .topbar__inner { flex-wrap: wrap; row-gap: .5rem; }
    .brand { order: 1; }
    .topbar__logout { order: 2; margin-left: auto; }

    .nav {
        order: 3;
        flex: 1 0 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
        mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav__link { flex-shrink: 0; padding: .35rem .55rem; font-size: .8rem; }

    /* The tables stay tables on a phone: they scroll sideways inside their
       card.  Squeezing seven columns onto 390px truncates every value. */
    table.data { table-layout: auto; width: 100%; }
    table.data th, table.data td { padding-left: .5rem; padding-right: .5rem; }

    table.data td.col-name,
    table.data td.col-comment {
        min-width: 7rem;
        max-width: 12rem;
        white-space: normal;
        word-break: normal;
        overflow-wrap: break-word;
    }

    .long { display: none; }
    .short { display: inline; }

    table.data .col-action { white-space: nowrap; }
    table.data .col-action .btn { padding-left: .5rem; padding-right: .5rem; font-size: .72rem; }

    /* Secondary columns go away on a phone; the detail is on the wine page. */
    table.data .col-drop,
    table.data .col-days,
    table.data .col-where { display: none; }

    .table-wrap { scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
}

/* ----------------------------------------------------------------- chips */

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    background: rgba(182, 165, 173, .12);
    color: var(--text-muted);
}

/* drinking-window status */
.chip--at_peak   { background: var(--success-dim); color: var(--success); }
.chip--drinking  { background: var(--wine-dim);    color: var(--wine-text); }
.chip--opening   { background: var(--gold-dim);    color: var(--gold-bright); }
.chip--drink_up  { background: var(--warn-dim);    color: var(--warn); }
.chip--too_young { background: rgba(182, 165, 173, .13); color: var(--text-muted); }
.chip--past      { background: var(--danger-dim);  color: var(--danger); }
.chip--unknown   { background: rgba(182, 165, 173, .13); color: var(--text-faint); }

/* bottle status */
.chip--in_cellar { background: var(--wine-dim); color: var(--wine-text); }
.chip--ready     { background: var(--success-dim); color: var(--success); }
.chip--opened    { background: var(--gold-dim); color: var(--gold-bright); }
.chip--consumed  { background: rgba(182, 165, 173, .13); color: var(--text-muted); }
.chip--gifted,
.chip--sold      { background: rgba(182, 165, 173, .13); color: var(--text-faint); }

.chip--dish {
    background: var(--bg-raised-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: .78rem;
    font-weight: 500;
    padding: .22rem .6rem;
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 .5rem; }

/* --------------------------------------------------------------- flashes */

.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.flash {
    padding: .6rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    font-size: .9rem;
}
.flash--success { border-color: rgba(127, 174, 74, .45); background: var(--success-dim); color: #c9e0a4; }
.flash--error   { border-color: rgba(207, 75, 82, .45);  background: var(--danger-dim);  color: #f0b0b3; }
.flash--warning { border-color: rgba(221, 162, 60, .45); background: var(--warn-dim);    color: #f2cd8e; }
.flash--info    { border-color: rgba(140, 31, 61, .55);  background: var(--wine-dim);    color: var(--wine-text); }

/* ---------------------------------------------------------------- login */

.login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(900px 480px at 50% -10%, rgba(140, 31, 61, .22), transparent 62%),
        radial-gradient(700px 380px at 80% 110%, rgba(201, 162, 39, .08), transparent 60%),
        var(--bg);
}
.login__card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    position: relative;
}
.login__card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(90deg, var(--wine-deep), var(--gold), var(--wine-deep));
}
.login__mark { line-height: 1; }
.login__title {
    margin: .6rem 0 .15rem;
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.9rem;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--gold-bright);
}
.login__sub { color: var(--text-muted); font-size: .88rem; margin-bottom: 1.4rem; }

/* ----------------------------------------------------------- wine cards */

.wine-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    position: relative;
    overflow: hidden;
}
.wine-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--wine-deep), var(--wine) 45%, transparent 90%);
    opacity: .85;
}
.wine-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.wine-card__name { font-weight: 650; font-size: 1.02rem; margin: 0; }
.wine-card__meta { color: var(--text-muted); font-size: .82rem; margin: 0; }
.wine-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.wine-card__stat { display: flex; flex-direction: column; }
.wine-card__stat .stat__label { font-size: .68rem; }
.wine-card__stat .stat__value { font-size: 1.2rem; }
.wine-card__stat .stat__meta { margin-top: auto; }

/* --------------------------------------------------------------- sources */

.source-list { list-style: none; margin: 0; padding: 0; }
.source-list__item {
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .86rem;
}
.source-list__item:last-child { border-bottom: none; }
.source-list__item.is-dropped { opacity: .55; }
.source-list__item.is-dropped a { text-decoration: line-through; }
.source-list__meta { margin-top: .1rem; }

/* -------------------------------------------------------------- timeline */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto;
    gap: .6rem;
    align-items: center;
    padding: .35rem 0;
    font-size: .84rem;
}
.timeline__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline__bar-wrap {
    position: relative;
    height: 8px;
    background: var(--bg-raised-2);
    border-radius: 999px;
    overflow: hidden;
}
.timeline__bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 999px;
    background: var(--text-faint);
}
.timeline__bar--at_peak  { background: var(--success); }
.timeline__bar--drinking { background: var(--wine); }
.timeline__bar--opening  { background: var(--gold); }
.timeline__bar--drink_up { background: var(--warn); }
.timeline__bar--too_young { background: var(--border-strong); }
.timeline__bar--past     { background: var(--danger); }
.timeline__years { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }

/* ---------------------------------------------------------------- charts */

.chart { position: relative; height: 220px; }
.chart--tall { height: 260px; }

/* --------------------------------------------------------------- helpers */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.small { font-size: .84rem; }
.tiny  { font-size: .76rem; }
.center { text-align: center; }
.right  { text-align: right; }
.stack > * + * { margin-top: .75rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-lg { margin-top: 2rem; }
.mb-lg { margin-bottom: 1.25rem; }
.hidden { display: none !important; }

.empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-faint);
}
.empty__icon { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .7; }

/* Advice / failure note — the shape beer_data uses for generated text. */
.advice {
    display: block;
    margin-top: .35rem;
    padding: .5rem .65rem;
    border-left: 2px solid var(--wine-bright);
    border-radius: 0 4px 4px 0;
    background: var(--wine-dim);
    color: var(--text);
    font-size: .8125rem;
    line-height: 1.5;
}
.advice__label {
    display: block;
    margin-bottom: .15rem;
    font-size: .625rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--wine-text);
}
.advice--failed {
    border-left-color: var(--danger);
    background: var(--danger-dim);
    color: var(--text-muted);
}
.advice--failed .advice__label { color: var(--danger); }
