/* ═══════════════════════════════════════════════════════════════
   CELLAR NOIR — Wine Auction Tracker Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
    --wine: #9f1239;
    --wine-hover: #881337;
    --wine-glow: rgba(159, 18, 57, 0.25);
    --gold: #d4a574;
    --gold-dim: rgba(212, 165, 116, 0.12);
    --surface: #1c1917;
    --surface-hover: #252220;
    --border: #292524;
}

/* ─── Base ───────────────────────────────────────────────────── */
body {
    font-family: 'Outfit', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Atmospheric noise texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ─── Typography ─────────────────────────────────────────────── */
h1, h2, h3, .font-display {
    font-family: 'Crimson Pro', Georgia, serif;
}

.text-balance {
    text-wrap: balance;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    border-color: #3a3532;
}

.card-glow:hover {
    box-shadow: 0 0 24px -4px var(--wine-glow);
    border-color: rgba(159, 18, 57, 0.3);
}

/* ─── Nav accent line ────────────────────────────────────────── */
.nav-accent {
    position: relative;
}

.nav-accent::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--wine);
    border-radius: 1px;
    transition: width 0.25s ease, left 0.25s ease;
}

.nav-accent.active::after,
.nav-accent:hover::after {
    width: 100%;
    left: 0;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.data-table thead th {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #78716c;
    padding: 0.75rem 1rem;
    background: rgba(12, 10, 9, 0.5);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(41, 37, 36, 0.5);
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(41, 37, 36, 0.35);
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

/* ─── Score badges ───────────────────────────────────────────── */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.score-badge-gold {
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.2), rgba(180, 130, 70, 0.2));
    color: var(--gold);
    border: 1px solid rgba(212, 165, 116, 0.3);
    text-shadow: 0 0 12px rgba(212, 165, 116, 0.4);
}

.score-badge-green {
    background: rgba(52, 211, 153, 0.12);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.score-badge-blue {
    background: rgba(96, 165, 250, 0.12);
    color: #93c5fd;
    border: 1px solid rgba(96, 165, 250, 0.2);
}

.score-badge-stone {
    background: rgba(120, 113, 108, 0.12);
    color: #a8a29e;
    border: 1px solid rgba(120, 113, 108, 0.2);
}

/* ─── Score medallion (wine detail) ──────────────────────────── */
.score-medallion {
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
}

.score-medallion::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid;
    border-color: inherit;
    opacity: 0.4;
}

.score-medallion-gold {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-dim);
    box-shadow: 0 0 20px rgba(212, 165, 116, 0.15);
}

.score-medallion-green {
    color: #6ee7b7;
    border-color: #6ee7b7;
    background: rgba(52, 211, 153, 0.08);
}

.score-medallion-blue {
    color: #93c5fd;
    border-color: #93c5fd;
    background: rgba(96, 165, 250, 0.08);
}

/* ─── Confidence bar ─────────────────────────────────────────── */
.conf-bar-track {
    height: 4px;
    background: rgba(120, 113, 108, 0.2);
    border-radius: 9999px;
    overflow: hidden;
    width: 4rem;
}

.conf-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    background: var(--wine);
    color: white;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn-primary:hover {
    background: var(--wine-hover);
    box-shadow: 0 4px 12px rgba(159, 18, 57, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    background: transparent;
    color: #d6d3d1;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(41, 37, 36, 0.5);
    border-color: #3a3532;
    color: #fafaf9;
}

/* ─── Form inputs ────────────────────────────────────────────── */
input[type="text"], input[type="number"], input[type="password"],
select, textarea {
    background: #0c0a09;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #fafaf9;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]::placeholder, input[type="number"]::placeholder,
input[type="password"]::placeholder {
    color: #57534e;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--wine);
    box-shadow: 0 0 0 3px var(--wine-glow);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2378716c' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
}

input[type="checkbox"] {
    accent-color: var(--wine);
}

/* ─── Section headers ────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fafaf9;
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination-link {
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #d6d3d1;
    background: transparent;
    transition: all 0.15s ease;
}

.pagination-link:hover {
    background: rgba(41, 37, 36, 0.5);
    border-color: #3a3532;
    color: #fafaf9;
}

/* ─── Flash messages ─────────────────────────────────────────── */
.flash-message {
    animation: fadeSlideIn 0.35s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Page load animation ────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeUp 0.5s ease-out both;
}

.animate-in-d1 { animation-delay: 0.05s; }
.animate-in-d2 { animation-delay: 0.1s; }
.animate-in-d3 { animation-delay: 0.15s; }
.animate-in-d4 { animation-delay: 0.2s; }
.animate-in-d5 { animation-delay: 0.25s; }
.animate-in-d6 { animation-delay: 0.3s; }

/* ─── Stat card glow ─────────────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.25s ease;
}

.stat-card:hover::before {
    background: linear-gradient(90deg, transparent, var(--wine), transparent);
}

.stat-card-accent {
    border-color: rgba(159, 18, 57, 0.3);
}

.stat-card-accent::before {
    background: linear-gradient(90deg, transparent, var(--wine), transparent);
}

/* ─── PWA install banner ────────────────────────────────────── */
#pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

.pwa-banner-inner {
    max-width: 80rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.pwa-btn-install {
    padding: 0.4rem 1rem;
    background: var(--wine);
    color: white;
    border-radius: 8px;
    white-space: nowrap;
    font-weight: 500;
}

.pwa-btn-dismiss {
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    color: #78716c;
}

/* ─── Custom scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0c0a09;
}

::-webkit-scrollbar-thumb {
    background: #292524;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3532;
}

/* ─── Wine stain gradient (login) ────────────────────────────── */
.wine-stain {
    background:
        radial-gradient(ellipse at 30% 60%, rgba(159, 18, 57, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(120, 53, 15, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 90%, rgba(159, 18, 57, 0.06) 0%, transparent 40%);
}

/* ─── Divider line ───────────────────────────────────────────── */
.divider-wine {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--wine), transparent);
    opacity: 0.3;
}

/* ─── Mobile card layout for tables ─────────────────────────── */
@media (max-width: 640px) {
    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        display: block;
        padding: 0.875rem 1rem;
        border-bottom: 1px solid rgba(41, 37, 36, 0.5);
    }

    .data-table tbody tr:last-child {
        border-bottom: none;
    }

    .data-table tbody td {
        display: flex;
        align-items: baseline;
        padding: 0.25rem 0;
        border: none;
    }

    .data-table tbody td[data-label]:before {
        content: attr(data-label);
        font-family: 'Outfit', system-ui, sans-serif;
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: #57534e;
        min-width: 5.5rem;
        flex-shrink: 0;
    }

    .data-table tbody td[data-label=""]:before {
        display: none;
    }

    .data-table tbody td:first-child {
        display: block;
        padding-bottom: 0.5rem;
        margin-bottom: 0.375rem;
        border-bottom: 1px solid rgba(41, 37, 36, 0.3);
    }

    .data-table tbody td:first-child:before {
        display: none;
    }

    .pagination-link {
        padding: 0.625rem 1rem;
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 2.75rem;
    }

    .conf-bar-track {
        height: 5px;
    }

    form.flex.flex-wrap {
        width: 100%;
    }
}

/* ─── Taste profile bars (wine detail) ───────────────────────── */
.taste-bar-track {
    height: 4px;
    background: rgba(120, 113, 108, 0.15);
    border-radius: 9999px;
    overflow: hidden;
}

.taste-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Halliday progress bar override ─────────────────────────── */
#halliday-progress-bar {
    background: var(--wine);
    transition: width 0.3s ease;
}
