/*
 * Tasting Moments v2 — Visual-First Styling
 *
 * Design principles:
 * - Photography stays FULL COLOR (landscapes are too spectacular to grade)
 * - Brand cohesion via the sommelier text card (warm sepia/burgundy treatment)
 * - Mobile-first, iOS-safe (100dvh + safe-area-inset)
 * - Animation budget: max 2 transforms, transform/opacity only, 600ms ceiling
 * - Honors prefers-reduced-motion
 * - WCAG AA contrast contract on all text
 * - Placeholders are display:none — never show "coming soon" tiles
 */

/* =====================================================================
   CSS Variables — wine palette, typography, spacing, motion
   ===================================================================== */
:root {
    /* Wine palette — same as v1 for brand continuity */
    --tm-bg: #1a0f14;
    --tm-bg-light: #2a1a22;
    --tm-bg-card: #33202a;
    --tm-bg-input: #241620;

    --tm-burgundy: #722F37;
    --tm-burgundy-light: #8B3A42;
    --tm-burgundy-dark: #4A1C23;

    --tm-gold: #C5A55A;
    --tm-gold-light: #D4B96E;
    --tm-gold-dim: #8B7640;

    --tm-cream: #F5E6D3;
    --tm-cream-dim: #C4B09A;
    --tm-cream-dark: #9A8672;

    --tm-white: #FAF5EF;
    --tm-white-dim: rgba(250, 245, 239, 0.7);

    /* Sepia/burgundy text card treatment — the brand cohesion device */
    --tm-card-bg: linear-gradient(
        135deg,
        rgba(33, 18, 22, 0.92) 0%,
        rgba(74, 28, 35, 0.88) 50%,
        rgba(58, 24, 30, 0.92) 100%
    );
    --tm-card-border: 1px solid rgba(197, 165, 90, 0.18);
    --tm-card-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                      0 0 0 1px rgba(0, 0, 0, 0.2) inset;

    /* Wine color gradients (used as fallback when no image) */
    --tm-gradient-red: linear-gradient(135deg, #4A1C23 0%, #722F37 50%, #8B3A42 100%);
    --tm-gradient-white: linear-gradient(135deg, #8a7830 0%, #C5A55A 50%, #F0E68C 100%);
    --tm-gradient-rose: linear-gradient(135deg, #7a3050 0%, #B85A75 50%, #E8A0B4 100%);
    --tm-gradient-sparkling: linear-gradient(135deg, #8a7840 0%, #C5A55A 50%, #F5E6B8 100%);

    /* Mood overlays (low-opacity tints over the background) */
    --mood-anticipation: rgba(120, 80, 40, 0.18);
    --mood-wonder:       rgba(74, 28, 35, 0.22);
    --mood-contemplative:rgba(20, 30, 50, 0.22);
    --mood-discovery:    rgba(80, 60, 20, 0.18);
    --mood-intimate:     rgba(120, 30, 50, 0.25);
    --mood-reflection:   rgba(40, 20, 30, 0.30);
    --mood-satisfaction: rgba(180, 130, 60, 0.18);
    --mood-balanced:     rgba(74, 28, 35, 0.18);
    --mood-curiosity:    rgba(120, 80, 40, 0.16);

    /* Typography */
    --tm-font-display: 'Cormorant Garamond', Georgia, serif;
    --tm-font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --tm-space-xs: 0.25rem;
    --tm-space-sm: 0.5rem;
    --tm-space-md: 1rem;
    --tm-space-lg: 1.5rem;
    --tm-space-xl: 2rem;
    --tm-space-xxl: 3rem;

    /* Borders */
    --tm-radius: 12px;
    --tm-radius-sm: 8px;
    --tm-radius-lg: 24px;

    /* Motion — capped 600ms */
    --tm-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --tm-duration-fast: 200ms;
    --tm-duration-base: 400ms;
    --tm-duration-slow: 600ms;
}

/* =====================================================================
   Reset
   ===================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body.tm-v2-body {
    font-family: var(--tm-font-body);
    background: var(--tm-bg);
    color: var(--tm-cream);
    min-height: 100dvh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Skip-link for screen readers */
.tm-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    color: var(--tm-cream);
    background: var(--tm-burgundy);
    padding: 0.75rem 1rem;
    text-decoration: none;
    z-index: 9999;
}
.tm-skip-link:focus {
    left: 0;
}

/* Screen-reader-only utility */
.tm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible — accessibility */
*:focus-visible {
    outline: 2px solid var(--tm-gold);
    outline-offset: 2px;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* =====================================================================
   Header (shared across all pages)
   ===================================================================== */
.tm-v2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tm-space-md) var(--tm-space-lg);
    border-bottom: 1px solid rgba(197, 165, 90, 0.12);
    position: relative;
    z-index: 10;
}

.tm-v2-brand {
    display: flex;
    align-items: center;
    gap: var(--tm-space-sm);
}

.tm-v2-glass {
    font-size: 1.4rem;
}

.tm-v2-wordmark {
    font-family: var(--tm-font-display);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--tm-gold);
    letter-spacing: 0.02em;
}

.tm-v2-back-link {
    font-size: 0.8rem;
    color: var(--tm-cream-dim);
    transition: color var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-back-link:hover {
    color: var(--tm-gold);
}

/* =====================================================================
   HOME PAGE
   ===================================================================== */
.tm-v2-home {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.tm-v2-hero {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--tm-space-xxl) var(--tm-space-lg);
    /* Full viewport — hero fills the screen so the image reads dramatically */
    min-height: calc(100dvh - 72px);  /* 72px leaves room for header */
    /* NOTE: intentionally no overflow:hidden — the search results dropdown
       needs to extend beyond the hero's visual bottom edge when there are
       many matches. The hero image is contained by .tm-v2-hero-bg's own
       inset:0 box, so there's nothing to clip at the hero level. */
}

/* .tm-v2-hero-bg already sets inset:0 + we add overflow:hidden here so the
   image itself stays contained (object-fit: cover can bleed otherwise). */
.tm-v2-hero-bg {
    overflow: hidden;
}

.tm-v2-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.tm-v2-hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Dark veil overlay on top of the hero image — ensures text stays legible
   without crushing the photography underneath. */
.tm-v2-hero-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.7) 100%),
        linear-gradient(180deg, rgba(26, 15, 20, 0.3) 0%, rgba(26, 15, 20, 0.65) 100%);
}

.tm-v2-hero-content {
    position: relative;
    z-index: 1;
    max-width: 640px;
    width: 100%;
    text-align: center;
}

.tm-v2-hero-title {
    font-family: var(--tm-font-display);
    font-size: clamp(2.8rem, 8vw, 4.5rem);
    font-weight: 500;
    color: var(--tm-gold);
    margin-bottom: var(--tm-space-md);
    letter-spacing: -0.01em;
}

.tm-v2-hero-tagline {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    color: var(--tm-cream-dim);
    margin-bottom: var(--tm-space-xxl);
}

.tm-v2-search-wrap {
    position: relative;
    margin: 0 auto var(--tm-space-xl);
    max-width: 480px;
}

.tm-v2-search-input {
    width: 100%;
    padding: var(--tm-space-md) var(--tm-space-lg);
    background: var(--tm-bg-input);
    border: 1px solid rgba(197, 165, 90, 0.3);
    border-radius: var(--tm-radius);
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 1.05rem;
    outline: none;
    transition: border-color var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-search-input:focus {
    border-color: var(--tm-gold);
}
.tm-v2-search-input::placeholder {
    color: var(--tm-cream-dark);
}

.tm-v2-search-results {
    /* Position + width + max-height come from inline :style (JS-computed
       against the input's bounding rect — always fits in the viewport
       with a 40px bottom margin). Falls back to absolute if JS fails. */
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: var(--tm-bg-card);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius);
    z-index: 1000;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.tm-v2-search-result {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: var(--tm-space-md) var(--tm-space-lg);
    text-align: left;
    border-bottom: 1px solid rgba(197, 165, 90, 0.08);
    transition: background var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-search-result:hover {
    background: rgba(197, 165, 90, 0.08);
}
.tm-v2-search-result:last-child {
    border-bottom: none;
}

.tm-v2-search-empty {
    /* Absolute + anchored ABOVE the input so (a) showing/hiding never
       reflows the flex-centered hero, and (b) it doesn't collide with
       the featured-cards row that sits right below. The dropdown still
       goes below; the status message floats above. */
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    padding: var(--tm-space-sm) var(--tm-space-md);
    text-align: center;
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--tm-cream-dim);
}

.tm-v2-result-name {
    font-family: var(--tm-font-display);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--tm-cream);
}

.tm-v2-result-detail {
    font-size: 0.78rem;
    color: var(--tm-cream-dim);
    margin-top: 2px;
}

/* Featured stories row — 3 cards side-by-side on desktop, stacked on mobile */
.tm-v2-featured-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--tm-space-md);
    max-width: 960px;
    width: 100%;
    margin: var(--tm-space-xl) auto 0;
}

@media (min-width: 720px) {
    .tm-v2-featured-row {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--tm-space-md);
    }
}

.tm-v2-featured-card {
    display: flex;
    flex-direction: column;
    gap: var(--tm-space-sm);
    padding: var(--tm-space-lg);
    background: var(--tm-card-bg);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-card-shadow);
    backdrop-filter: blur(12px) saturate(1.05);
    -webkit-backdrop-filter: blur(12px) saturate(1.05);
    text-align: center;
    transition: transform var(--tm-duration-fast) var(--tm-ease),
                border-color var(--tm-duration-fast) var(--tm-ease),
                box-shadow var(--tm-duration-fast) var(--tm-ease);
    min-height: 190px;
}

.tm-v2-featured-card:hover {
    transform: translateY(-2px);
    border-color: rgba(197, 165, 90, 0.45);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55),
                0 0 0 1px rgba(197, 165, 90, 0.1) inset;
}

.tm-v2-featured-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--tm-gold);
    margin-bottom: 0;
}

.tm-v2-featured-name {
    font-family: var(--tm-font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--tm-cream);
    line-height: 1.2;
    margin: 0;
}

.tm-v2-featured-tagline {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--tm-cream-dim);
    flex: 1;
    margin: 0;
}

.tm-v2-featured-cta-inline {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--tm-gold);
    padding-top: var(--tm-space-xs);
    border-top: 1px solid rgba(197, 165, 90, 0.15);
    margin-top: auto;
}

.tm-v2-featured-card:hover .tm-v2-featured-cta-inline {
    color: var(--tm-gold-light);
}

/* =====================================================================
   PRODUCER PAGE
   ===================================================================== */
.tm-v2-producer-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.tm-v2-producer-main {
    flex: 1;
}

.tm-v2-producer-hero {
    position: relative;
    height: 60dvh;
    min-height: 400px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.tm-v2-producer-hero-bg {
    position: absolute;
    inset: 0;
    background: var(--tm-gradient-red);
}

.tm-v2-producer-hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tm-v2-producer-hero-content {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: var(--tm-space-xxl) var(--tm-space-lg);
    background: linear-gradient(180deg, transparent 0%, rgba(26, 15, 20, 0.85) 100%);
}

.tm-v2-producer-region-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--tm-gold);
    margin-bottom: var(--tm-space-sm);
}

.tm-v2-producer-name {
    font-family: var(--tm-font-display);
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 500;
    color: var(--tm-cream);
    margin-bottom: var(--tm-space-sm);
}

.tm-v2-producer-tagline {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--tm-cream-dim);
}

.tm-v2-tier-badge {
    display: inline-block;
    margin-top: var(--tm-space-md);
    padding: 4px 12px;
    background: rgba(197, 165, 90, 0.15);
    border: 1px solid rgba(197, 165, 90, 0.4);
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--tm-gold);
}

.tm-v2-producer-story {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--tm-space-xxl) var(--tm-space-lg);
}

.tm-v2-story-text p {
    font-family: var(--tm-font-display);
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--tm-cream);
    margin-bottom: var(--tm-space-md);
}

.tm-v2-partner-link {
    display: inline-block;
    margin-top: var(--tm-space-lg);
    color: var(--tm-gold);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(197, 165, 90, 0.4);
    padding-bottom: 2px;
    transition: color var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-partner-link:hover {
    color: var(--tm-gold-light);
}

.tm-v2-wines {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 var(--tm-space-lg) var(--tm-space-xxl);
}

.tm-v2-wine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--tm-space-md);
}

.tm-v2-wine-card {
    display: flex;
    align-items: center;
    gap: var(--tm-space-md);
    padding: var(--tm-space-md);
    background: var(--tm-bg-card);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius);
    transition: all var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-wine-card:hover {
    border-color: var(--tm-gold);
    background: rgba(197, 165, 90, 0.06);
    transform: translateY(-1px);
}

.tm-v2-wine-color {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tm-v2-color-red       { background: var(--tm-gradient-red); }
.tm-v2-color-white     { background: var(--tm-gradient-white); }
.tm-v2-color-rosé,
.tm-v2-color-rose      { background: var(--tm-gradient-rose); }
.tm-v2-color-sparkling { background: var(--tm-gradient-sparkling); }

.tm-v2-wine-card-info {
    flex: 1;
    min-width: 0;
}

.tm-v2-wine-card-name {
    font-family: var(--tm-font-display);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--tm-cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-v2-wine-card-detail {
    font-size: 0.75rem;
    color: var(--tm-cream-dim);
    margin-top: 2px;
}

.tm-v2-wine-card-cta {
    display: block;
    font-size: 0.78rem;
    color: var(--tm-gold);
    margin-top: var(--tm-space-sm);
}

/* =====================================================================
   STORY PAGE — the immersive tasting experience
   ===================================================================== */
.tm-v2-story-page {
    position: relative;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    /* No overflow:hidden — page must scroll when sommelier text exceeds viewport.
       Background layers are position:fixed so they don't affect scroll width. */
}

/* Background image layers — full color, no duotone */
.tm-v2-bg-layers {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.tm-v2-bg-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity var(--tm-duration-slow) var(--tm-ease);
}

.tm-v2-bg-layer.is-active {
    opacity: 1;
}

.tm-v2-mood-overlay {
    position: absolute;
    inset: 0;
    transition: background-color var(--tm-duration-slow) var(--tm-ease);
    background: var(--mood-balanced);
    pointer-events: none;
}
.tm-v2-mood-anticipation  { background: var(--mood-anticipation); }
.tm-v2-mood-wonder        { background: var(--mood-wonder); }
.tm-v2-mood-contemplative { background: var(--mood-contemplative); }
.tm-v2-mood-discovery     { background: var(--mood-discovery); }
.tm-v2-mood-intimate      { background: var(--mood-intimate); }
.tm-v2-mood-reflection    { background: var(--mood-reflection); }
.tm-v2-mood-satisfaction  { background: var(--mood-satisfaction); }
.tm-v2-mood-balanced      { background: var(--mood-balanced); }
.tm-v2-mood-curiosity     { background: var(--mood-curiosity); }

/* Story page header — translucent over the photography */
.tm-v2-story-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tm-space-md) var(--tm-space-lg);
    position: relative;
    z-index: 20;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
    border-bottom: none;
}

.tm-v2-brand-light .tm-v2-wordmark {
    color: var(--tm-cream);
    text-shadow:
        0 0 4px rgba(0, 0, 0, 1),
        0 0 12px rgba(0, 0, 0, 0.85),
        0 1px 3px rgba(0, 0, 0, 1);
}

/* Kebab menu (replaces the old "New wine" button — quieter affordance) */
.tm-v2-header-menu {
    position: relative;
}

.tm-v2-menu-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tm-cream);
    font-size: 1.4rem;
    line-height: 1;
    border-radius: 50%;
    background: transparent;
    transition: background var(--tm-duration-fast) var(--tm-ease),
                color var(--tm-duration-fast) var(--tm-ease);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.tm-v2-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--tm-gold);
}

.tm-v2-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--tm-card-bg);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius);
    box-shadow: var(--tm-card-shadow);
    backdrop-filter: blur(16px) saturate(1.1);
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
    overflow: hidden;
    z-index: 100;
}

.tm-v2-menu-item {
    display: block;
    width: 100%;
    padding: var(--tm-space-md) var(--tm-space-lg);
    text-align: left;
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 0.9rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(197, 165, 90, 0.08);
    text-decoration: none;
    transition: background var(--tm-duration-fast) var(--tm-ease),
                color var(--tm-duration-fast) var(--tm-ease);
    cursor: pointer;
}

.tm-v2-menu-item:last-child {
    border-bottom: none;
}

.tm-v2-menu-item:hover {
    background: rgba(197, 165, 90, 0.1);
    color: var(--tm-gold);
}

/* Story main content area */
.tm-v2-story-main {
    flex: 1;
    position: relative;
    z-index: 5;
    padding: var(--tm-space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--tm-space-lg);
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

/* Wine identity strip (small, above the card) */
.tm-v2-wine-identity {
    display: flex;
    align-items: center;
    gap: var(--tm-space-sm);
    font-size: 0.85rem;
    color: var(--tm-cream);
    text-shadow:
        0 0 4px rgba(0, 0, 0, 1),
        0 0 12px rgba(0, 0, 0, 0.85),
        0 1px 3px rgba(0, 0, 0, 1);
}

.tm-v2-wine-id-name {
    font-family: var(--tm-font-display);
    font-weight: 500;
    font-size: 1rem;
}

.tm-v2-wine-id-sep {
    color: var(--tm-gold);
    opacity: 0.6;
}

.tm-v2-wine-id-detail {
    color: var(--tm-cream-dim);
    font-size: 0.8rem;
}

/* THE SOMMELIER CARD — brand cohesion device, warm sepia/burgundy treatment */
.tm-v2-sommelier-card {
    width: 100%;
    max-width: 640px;
    padding: var(--tm-space-xl) var(--tm-space-xl);
    background: var(--tm-card-bg);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-card-shadow);
    backdrop-filter: blur(12px) saturate(1.1);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
    position: relative;
}

.tm-v2-sommelier-text {
    font-family: var(--tm-font-display);
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--tm-cream);
}

.tm-v2-sommelier-text p {
    margin-bottom: var(--tm-space-md);
}
.tm-v2-sommelier-text p:last-child {
    margin-bottom: 0;
}

/* Story beat — italic serif marginalia, set INTO the card */
.tm-v2-story-beat {
    margin-top: var(--tm-space-lg);
    padding-top: var(--tm-space-lg);
    border-top: 1px solid rgba(197, 165, 90, 0.18);
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--tm-gold);
    text-align: center;
    opacity: 0.92;
}

/* Connection error retry */
.tm-v2-error-retry {
    text-align: center;
    padding: var(--tm-space-lg);
}

.tm-v2-error-text {
    font-family: var(--tm-font-display);
    font-style: italic;
    color: var(--tm-cream-dim);
    margin-bottom: var(--tm-space-md);
}

/* Wine search section (in story page wine_input step) */
.tm-v2-wine-search-section {
    width: 100%;
    max-width: 560px;
    background: var(--tm-card-bg);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius);
    padding: var(--tm-space-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Pull-quote suggestion chips — magazine pull-quote styling, NOT bubble buttons */
.tm-v2-pullquotes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tm-space-md) var(--tm-space-xl);
    justify-content: center;
    width: 100%;
    max-width: 640px;
    padding: 0 var(--tm-space-md);
}

/* Pull-quote chip: italic serif marginalia inside a soft dark glass pill.
   The pill is the minimum structure needed to stay legible on bright
   photographic backgrounds while preserving the "magazine pull-quote"
   feel (italic serif, bookend quote marks, no chunky button affordance). */
.tm-v2-pullquote {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--tm-cream);
    background: rgba(20, 10, 14, 0.62);
    backdrop-filter: blur(10px) saturate(1.1);
    -webkit-backdrop-filter: blur(10px) saturate(1.1);
    border: 1px solid rgba(197, 165, 90, 0.18);
    border-radius: 999px;
    padding: 8px 18px;
    text-align: center;
    transition: background var(--tm-duration-fast) var(--tm-ease),
                color var(--tm-duration-fast) var(--tm-ease),
                border-color var(--tm-duration-fast) var(--tm-ease),
                transform var(--tm-duration-fast) var(--tm-ease);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.tm-v2-pullquote:hover {
    background: rgba(40, 20, 26, 0.72);
    color: var(--tm-gold);
    border-color: rgba(197, 165, 90, 0.5);
    transform: translateY(-1px);
}

.tm-v2-pullquote-mark {
    font-family: var(--tm-font-display);
    color: var(--tm-gold);
    font-size: 1.3em;
    line-height: 0;
    vertical-align: -0.1em;
    margin: 0 0.15em;
    opacity: 0.7;
}

.tm-v2-pullquote-perma {
    color: var(--tm-cream);
}

.tm-v2-pullquote-context {
    color: var(--tm-cream-dim);
}

.tm-v2-pullquote-dynamic {
    color: var(--tm-cream);
}

/* Chat input — strong contrast so it stands out against any background */
.tm-v2-chat-section {
    display: flex;
    gap: var(--tm-space-sm);
    width: 100%;
    max-width: 560px;
    background: var(--tm-card-bg);
    backdrop-filter: blur(16px) saturate(1.1);
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
    border: 1px solid rgba(197, 165, 90, 0.35);
    border-radius: var(--tm-radius);
    padding: var(--tm-space-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.tm-v2-chat-input {
    flex: 1;
    padding: var(--tm-space-sm) var(--tm-space-md);
    background: transparent;
    border: none;
    color: var(--tm-cream);
    font-family: var(--tm-font-body);
    font-size: 0.95rem;
    outline: none;
}
.tm-v2-chat-input::placeholder {
    color: var(--tm-cream-dark);
    font-style: italic;
}

.tm-v2-chat-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tm-burgundy);
    border-radius: var(--tm-radius-sm);
    color: var(--tm-gold);
    font-size: 0.9rem;
    transition: all var(--tm-duration-fast) var(--tm-ease);
}
.tm-v2-chat-send:hover:not(:disabled) {
    background: var(--tm-burgundy-light);
}
.tm-v2-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Info box — invisible by default; appears only when asset present */
.tm-v2-info-box {
    width: 100%;
    max-width: 480px;
    padding: var(--tm-space-md);
    background: var(--tm-card-bg);
    border: var(--tm-card-border);
    border-radius: var(--tm-radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.tm-v2-info-box-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--tm-gold);
    margin-bottom: var(--tm-space-sm);
}

.tm-v2-info-box-asset img,
.tm-v2-info-box-asset video {
    width: 100%;
    height: auto;
    border-radius: var(--tm-radius-sm);
}

/* Loading state */
.tm-v2-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--tm-space-md);
    padding: var(--tm-space-xxl) 0;
}

.tm-v2-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(197, 165, 90, 0.2);
    border-top-color: var(--tm-gold);
    border-radius: 50%;
    animation: tm-v2-spin 1s linear infinite;
}

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

.tm-v2-loading-text {
    font-family: var(--tm-font-display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--tm-cream-dim);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Step progress — labeled bar, not bare dots */
.tm-v2-progress {
    position: relative;
    z-index: 5;
    padding: var(--tm-space-md) var(--tm-space-lg);
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.tm-v2-progress-label {
    text-align: center;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--tm-gold);
    margin-bottom: var(--tm-space-sm);
    text-shadow:
        0 0 4px rgba(0, 0, 0, 1),
        0 0 12px rgba(0, 0, 0, 0.85),
        0 1px 3px rgba(0, 0, 0, 1);
}

.tm-v2-progress-counter {
    color: var(--tm-cream-dim);
    margin-left: 0.4em;
}

.tm-v2-progress-track {
    height: 2px;
    background: rgba(197, 165, 90, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.tm-v2-progress-fill {
    height: 100%;
    background: var(--tm-gold);
    border-radius: 2px;
    transition: width var(--tm-duration-slow) var(--tm-ease);
}

/* Action bar */
.tm-v2-actions {
    position: relative;
    z-index: 5;
    padding: var(--tm-space-md) var(--tm-space-lg) calc(var(--tm-space-xl) + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tm-v2-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tm-space-sm);
    padding: var(--tm-space-md) var(--tm-space-xl);
    border-radius: var(--tm-radius);
    font-family: var(--tm-font-body);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--tm-duration-fast) var(--tm-ease);
}

.tm-v2-btn-primary {
    background: linear-gradient(135deg, var(--tm-burgundy), var(--tm-burgundy-dark));
    color: var(--tm-cream);
    border: 1px solid rgba(197, 165, 90, 0.3);
}
.tm-v2-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--tm-burgundy-light), var(--tm-burgundy));
    border-color: var(--tm-gold);
}

.tm-v2-btn-ghost {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--tm-cream-dim);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 300;
}
.tm-v2-btn-ghost:hover:not(:disabled) {
    color: var(--tm-gold);
    border-color: rgba(197, 165, 90, 0.3);
}

.tm-v2-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tm-v2-arrow {
    font-size: 1.1em;
}

/* =====================================================================
   Footer (powered by MDIL)
   ===================================================================== */
.tm-v2-footer {
    padding: var(--tm-space-md) var(--tm-space-lg) calc(var(--tm-space-md) + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.tm-v2-powered-by {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.35;
    transition: opacity var(--tm-duration-base) var(--tm-ease);
}
.tm-v2-powered-by:hover {
    opacity: 0.7;
}

.tm-v2-powered-text {
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--tm-cream-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.tm-v2-powered-logo {
    height: 14px;
    max-height: 14px;
    width: auto;
    max-width: 60px;
}

/* =====================================================================
   Reduced motion — kill all transitions
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .tm-v2-bg-layer {
        transition: none !important;
    }
    .tm-v2-mood-overlay {
        transition: none !important;
    }
    .tm-v2-spinner {
        animation: none !important;
        border-top-color: var(--tm-gold);
    }
}

/* =====================================================================
   Tablet+ adjustments
   ===================================================================== */
@media (min-width: 768px) {
    .tm-v2-story-main {
        padding: var(--tm-space-xl) var(--tm-space-xxl);
        gap: var(--tm-space-xl);
    }

    .tm-v2-sommelier-text {
        font-size: 1.3rem;
    }

    .tm-v2-pullquote {
        font-size: 1.15rem;
    }
}
