/* Sauternes.ch – Frontend v4 on the design system (docs/design-system). Tokens: tokens.css (the only :root level).
   Components from docs/design-system/components/bundle.css (class names binding), followed by the page layouts.
   Mobile first: phone < 48rem (bp-md), tablet to 75rem (bp-lg), desktop above. No important flags, each class once.
   «.sx-page» in front of a selector only where a component must win over «.sx-page a» (links styled as buttons). */

/* ===== Basics ============================================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; touch-action: manipulation; }   /* no double-tap zoom delay; pinch zoom stays possible in the browser */
button, input, select { font: inherit; color: inherit; }
:root [hidden][hidden][hidden] { display: none; }   /* repeated attribute: wins over the display of any component rule */
h1, h2, h3, h4 { margin: 0; }

/* Page background with the veiled damask texture (PageBackground) */
.sx-page {
    --texture: image-set(url("img/bg-damask.avif") type("image/avif"), url("img/bg-damask.webp") type("image/webp"));
    background: linear-gradient(var(--texture-veil), var(--texture-veil)), var(--texture, none) top center / 60rem auto repeat, var(--bg);
    color: var(--ink);
    font: 400 1.0625rem/1.6 var(--font-serif);
    -webkit-font-smoothing: antialiased;
}
/* Dark texture: as tokens.css – system dark unless the ThemeToggle chose light; data-theme="dark" forces dark */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sx-page { --texture: image-set(url("img/bg-damask-dark.avif") type("image/avif"), url("img/bg-damask-dark.webp") type("image/webp")); }
}
:root[data-theme="dark"] .sx-page { --texture: image-set(url("img/bg-damask-dark.avif") type("image/avif"), url("img/bg-damask-dark.webp") type("image/webp")); }
.sx-page a { color: var(--accent); }
.sx-page :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ===== Buttons: Primary, Secondary, Text – each in md (standard) and sm (on cards) ========================= */
.btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--tap-target); padding: .5rem var(--space-4);
    border: 1px solid transparent; border-radius: var(--radius-md);
    font: 600 .9375rem/1.3 var(--font-sans); text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn .i { width: 1.1rem; height: 1.1rem; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sx-page .btn-primary { background: var(--accent); color: var(--on-accent); }
.sx-page .btn-primary:hover { background: var(--accent-hover); }
.sx-page .btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary .i { color: var(--accent); }
.sx-page .btn-secondary:hover { border-color: var(--accent); }
.sx-page .btn-text { background: transparent; color: var(--accent); padding-inline: var(--space-2); }
.btn-text:hover { text-decoration: underline; text-underline-offset: .2em; }
.btn-sm { min-height: 2.25rem; padding: .3rem .75rem; font-size: .875rem; }
.btn-sm .i { width: 1rem; height: 1rem; }
.btn-sm::before { content: ""; position: absolute; inset: -.25rem 0; }   /* touch target ≥ 44 px */
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Icon buttons */
.icon-btn {
    display: inline-grid; place-items: center; width: var(--tap-target); height: var(--tap-target);
    border: 0; border-radius: var(--radius-round); background: transparent; color: inherit; cursor: pointer;
}
.icon-btn .i { width: 1.3rem; height: 1.3rem; }
.icon-btn:hover, .icon-btn:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sx-page .round-btn { background: var(--surface); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow-card); text-decoration: none; }
.sx-page .round-btn:hover, .sx-page .round-btn:focus-visible { border-color: var(--accent); background: var(--surface); }

/* ===== Rating: pennant only for averages, points for single tastings ======================================= */
.pennant { position: relative; display: inline-block; flex: none; filter: drop-shadow(0 .15rem .15rem rgba(40, 0, 10, .25)); }
.pennant-body {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    width: 2.125rem; min-height: 2.875rem; padding: .4rem 0 .85rem; color: var(--on-wine); text-align: center;
    background: linear-gradient(90deg, var(--wine-shade) 0, var(--wine) 22%, var(--wine-light) 50%, var(--wine) 78%, var(--wine-shade) 100%);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
}
.pennant-body small { font: 600 .5625rem/1 var(--font-sans); opacity: .8; margin-bottom: .1rem; }
.pennant-body b { font: 600 .8125rem/1 var(--font-sans); letter-spacing: -.01em; }
/* Over the edge of a card: the band reaches 0.375rem over the border and runs back behind the card (fold left) */
.pennant-edge { position: absolute; top: -.375rem; right: var(--space-4); z-index: var(--z-content); }
.pennant-edge::before { content: ""; position: absolute; top: 0; left: -.375rem; width: .375rem; height: .375rem; background: var(--wine-deep); clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.pennant-edge .pennant-body { padding-top: .7rem; min-height: 3.25rem; }
.points { display: inline-flex; align-items: baseline; gap: .3rem; white-space: nowrap; color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); }
.points b { color: var(--score); font: 600 1.0625rem/1 var(--font-sans); }

.chip { display: inline-block; padding: .05rem .5rem; border-radius: var(--radius-sm); background: var(--tint); color: var(--ink); font: 400 .875rem/1.4 var(--font-sans); }
.nowine { margin: 0; color: var(--warn); font-style: italic; }

/* ===== Information levels: château (gold, sans) → vintage/wine (serif bold) → note (serif) ================= */
.wine-name { display: flex; flex-direction: column; gap: .1rem; }
.wine-chateau { color: var(--chateau-ink); font: 600 1rem/1.3 var(--font-sans); letter-spacing: .01em; }
.wine-vintage { color: var(--ink); font: 700 1.2rem/1.3 var(--font-serif); font-variant-numeric: lining-nums tabular-nums; }

/* ===== Tasting card: the same everywhere – feed, wine page, search results ================================= */
.tasting-card {
    position: relative; display: grid; grid-template-columns: 1fr auto; gap: 0 var(--space-4);
    padding: var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.tasting-card .tc-top { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: var(--space-3); }
.tasting-card .tc-top > :first-child { flex: 1; min-width: 0; }
.tasting-card .tc-top .points { margin-top: .15rem; }
.tasting-card .tc-title { margin: 0; font: inherit; }
.tasting-card .tc-title a { color: inherit; text-decoration: none; }
.tasting-card .tc-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }   /* whole card clickable when linked */
.tasting-card .tc-date { display: flex; align-items: center; gap: var(--space-2); margin: 0; color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); }
.tasting-card .tc-title + .tc-date, .tasting-card .tc-top + .tc-date { grid-column: 1 / -1; margin-top: var(--space-2); }
.tasting-card .tc-text { grid-column: 1; margin: var(--space-3) 0 0; font: 400 1.0625rem/1.6 var(--font-serif); white-space: pre-line; }
.tasting-card .tc-photo { grid-column: 2; align-self: start; width: 4.5rem; height: 4.5rem; margin-top: var(--space-3); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--tint); cursor: zoom-in; position: relative; z-index: 1; }
.tasting-card .tc-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tasting-card .tc-actions { grid-column: 1 / -1; position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
@media (hover: hover) { .tasting-card:has(.tc-title a):hover { box-shadow: var(--shadow-raised); border-color: var(--line-strong); } }
.tasting-list { display: grid; gap: var(--space-4); margin: 0; padding: 0; list-style: none; }

/* ===== Château group in the search results, vintage rows, rating card ===================================== */
.chateau { margin: 0 0 var(--space-5); overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.chateau > header { padding: var(--space-4) var(--space-4) var(--space-3); }
.chateau-name { margin: 0; font: 700 1.2rem/1.3 var(--font-serif); }
.chateau-name a { color: inherit; text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .2rem 0 0; color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); }
.chateau-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: 0 var(--space-4) var(--space-4); }
.wine { position: relative; display: flex; align-items: center; gap: var(--space-3); border-top: 1px solid var(--line); padding: var(--space-3) var(--space-4); }
.wine .wine-name::after { content: ""; position: absolute; inset: 0; }   /* the whole row leads to the wine page */
@media (hover: hover) { .wine:hover { background: var(--tint); } }
.wine .card-text { flex: 1; }
.wine h3, .wine h4 { flex: 1; margin: 0; font: 700 1.2rem/1.3 var(--font-serif); font-variant-numeric: lining-nums tabular-nums; }
.wine h3 a, .wine h4 a { color: inherit; text-decoration: none; }
.cards { display: grid; grid-template-columns: 1fr; gap: var(--space-4); margin: 0; padding: .375rem 0 0; list-style: none; }
.card a { position: relative; display: flex; align-items: center; gap: var(--space-3); height: 100%; min-height: 4.25rem; padding: var(--space-3) 4rem var(--space-3) var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); color: var(--ink); text-decoration: none; }
.card a:hover { border-color: var(--line-strong); box-shadow: var(--shadow-raised); }
.card-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.card-title { display: flex; flex-direction: column; gap: .1rem; margin: 0; font: inherit; }
.card-count { color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); }
/* ChateauTile: the castle sign for «Château» in a round surface circle (later coloured by classification) */
.chateau-icon { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: var(--radius-round); background: var(--surface); color: var(--accent); }
.chateau-icon .i { width: 1.25rem; height: 1.25rem; }
.chateau-tile a { padding-right: var(--space-4); }

/* ===== Drinking window: icon in a circle, two lines ======================================================== */

/* ===== Inputs ============================================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field label { color: var(--ink-muted); font: 600 .8125rem/1.3 var(--font-sans); letter-spacing: .01em; }
.field input, .field select, .sort-select select {
    width: 100%; min-width: 0; max-width: 100%; height: var(--control-h); padding: 0 .75rem;
    border: 1px solid var(--line-strong); border-radius: var(--radius-md);
    background: var(--surface); color: var(--ink); font: 400 1rem/1.4 var(--font-sans);
}
.field input:focus, .field select:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.combo { position: relative; }
.combo input { padding-right: 2.5rem; }
.combo-clear { position: absolute; right: .125rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: var(--radius-round); background: transparent; color: var(--ink-muted); cursor: pointer; }
.combo-clear .i { width: 1.2rem; height: 1.2rem; }
.combo-clear:hover, .combo-clear:focus-visible { background: var(--tint); color: var(--ink); }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + .25rem); z-index: var(--z-dropdown); margin: 0; padding: .25rem 0; list-style: none; max-height: 22rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-raised); }
.combo-list li { display: flex; justify-content: space-between; gap: var(--space-3); padding: .7rem var(--space-4); font: 400 1rem/1.4 var(--font-sans); cursor: pointer; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--tint); }
.opt-count { color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); white-space: nowrap; }
/* Search hit in château names (suggestions, group heads): no browser yellow – bold in ink, 2 px underline in accent */
mark.hit { background: transparent; color: var(--ink); font-weight: 700; text-decoration: underline 2px var(--accent); text-decoration-skip-ink: none; text-underline-offset: .15em; }
.combo-list mark.hit { font-weight: 600; }   /* sans: 600 is the bold cut */
.opt-name { min-width: 0; }
.sort-select { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink-muted); }
.sort-select select { width: auto; height: 2.5rem; padding: 0 .6rem; font-size: .9375rem; }
#q { scroll-margin-top: calc(var(--top-h, 4rem) + var(--space-2)); }
@media (min-width: 48rem) { .field input, .field select { height: 2.5rem; } }

/* Segmented control */
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; gap: .2rem; padding: .2rem; margin: 0 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.segmented button { flex: none; min-height: 2.5rem; padding: .3rem var(--space-4); border: 0; border-radius: calc(var(--radius-md) - .1rem); background: transparent; color: var(--ink); font: 600 .9375rem/1.3 var(--font-sans); cursor: pointer; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ===== Header: wordmark with pennant; from 48rem masthead with navigation (underline instead of pills) ===== */
.top { position: sticky; top: 0; z-index: var(--z-header); background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); max-width: var(--content-max); margin: 0 auto; padding: .55rem var(--space-4); }
/* Wordmark (design system): the name is the brand, the dot is a pennant */
.sx-page .brand { display: inline-flex; flex-direction: column; align-items: flex-start; color: var(--ink); text-decoration: none; }
.brand .wm { font-size: 1.7rem; }
.wm { font-family: var(--font-serif); font-weight: 900; line-height: 1; letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }
.wm-ch { color: var(--accent); }
.wm-dot { display: inline-block; width: .2em; height: .27em; background: var(--wine); clip-path: polygon(0 0,100% 0,100% 100%,50% 74%,0 100%); margin: 0 .035em 0 .045em; }
.wm-sub { display: none; margin-top: .5rem; color: var(--ink-muted); font: 600 .625rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .2em; }
.wm-on-wine .wm { color: var(--on-wine); }
.wm-on-wine .wm-ch { color: var(--on-wine-accent); }
.wm-on-wine .wm-dot { background: var(--on-wine-accent); }
/* ThemeToggle (bundle.css, unchanged): narrow rail, a round knob with sun or moon slides over it (model spring.io) */
.theme-toggle { position: relative; flex: none; width: 3rem; height: var(--tap-target); padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; }
.theme-toggle .tt-track { position: absolute; left: .375rem; right: .375rem; top: 50%; height: .625rem; margin-top: -.3125rem; border-radius: 1rem; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); }
.theme-toggle .tt-knob { position: absolute; left: 0; top: 50%; display: grid; place-items: center; width: 1.625rem; height: 1.625rem; margin-top: -.8125rem; border-radius: var(--radius-round); background: var(--ink); color: var(--surface); box-shadow: 0 .0625rem .1875rem rgba(0, 0, 0, .3); transition: transform .25s cubic-bezier(.2, .7, .2, 1), background-color .25s ease; }
.theme-toggle .tt-knob .i { width: .95rem; height: .95rem; }
.theme-toggle .tt-moon { display: none; }
.theme-toggle[aria-checked="true"] .tt-knob { transform: translateX(1.375rem); background: var(--accent); color: var(--on-accent); }
.theme-toggle[aria-checked="true"] .tt-sun { display: none; }
.theme-toggle[aria-checked="true"] .tt-moon { display: block; }
.theme-toggle:hover .tt-track { box-shadow: inset 0 0 0 1px var(--line-strong); }
.theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-md); }
.top-actions { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }
.sx-page .top-search { color: var(--ink); }
.menu { display: none; }
@media (min-width: 48rem) {
    .top { border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line), 0 3px 0 -2px var(--line); }   /* double line like a newspaper head */
    .top-inner { padding: 1rem var(--space-6) 0; flex-wrap: wrap; }
    .brand .wm { font-size: 4rem; }
    .brand .wm-sub { display: block; }
    .sx-page .top-search { display: none; }
    .menu { display: flex; gap: var(--space-6); width: 100%; margin-top: .7rem; border-top: 1px solid var(--line); }
    .sx-page .menu a { position: relative; display: inline-flex; align-items: center; gap: .4rem; min-height: var(--tap-target); color: var(--ink); text-decoration: none; font: 600 .9375rem/1.3 var(--font-sans); }
    .sx-page .menu a:hover { color: var(--accent); }
    .sx-page .menu a[aria-current="page"] { color: var(--accent); }
    .menu a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }
    .menu .menu-search { margin-left: auto; }
}

/* Strip with back / share below the header (--top-h = header height, set by app.js); content scrolls underneath */
.page-bar { position: sticky; top: var(--top-h, 4.3rem); z-index: var(--z-pagebar); display: flex; justify-content: space-between; align-items: center; margin: calc(-1 * var(--space-4)) 0 var(--space-4); padding: .4rem 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.share-btn { position: relative; }
.share-btn[data-done]::after {
    content: attr(data-done); position: absolute; right: 0; top: calc(100% + .35rem); padding: .25rem .6rem; border-radius: var(--radius-sm);
    background: var(--ink); color: var(--bg); font: 600 .75rem/1.2 var(--font-sans); white-space: nowrap;
}

/* Tab bar (phone): fixed at the bottom over the full width – as in the admin tool */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: stretch;
    padding: .3rem .3rem calc(.4rem + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line);
}
.sx-page .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 3.1rem; color: var(--ink-muted); text-decoration: none; font: 400 .6875rem/1.2 var(--font-sans); }
.tabbar a .i { width: 1.4rem; height: 1.4rem; }
.sx-page .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
html.keyboard .tabbar, html.panel-open .tabbar, html.lightbox-open .tabbar { display: none; }
@media (max-width: 47.99rem) {
    body { padding-bottom: calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom, 0px)); }   /* the tab bar never covers the end */
}
@media (min-width: 48rem) { .tabbar { display: none; } }

/* ===== Page layout ========================================================================================= */
main { max-width: var(--content-max); margin: 0 auto; padding: var(--space-4) var(--space-4) var(--space-8); outline: none; }   /* bottom: space-8 from the last element to the footer line */
main > :last-child { margin-bottom: 0; }
.loading main { min-height: 100vh; }   /* footer below the fold while data.js loads; app.js removes the class after the first render */
.hint, .summary, .feed-note, .intro, .counter { color: var(--ink-muted); font: 400 .875rem/1.4 var(--font-sans); }
.summary { margin: 0 0 var(--space-4); }
.feed-note { margin: 0 0 var(--space-3); }
.section-title { margin: var(--space-8) 0 var(--space-3); font: 600 .75rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); }
main > .section-title:first-child, .page-head + .section-title { margin-top: var(--space-2); }
.more-btn { display: flex; margin: var(--space-4) auto 0; }
.feed-end { height: 1px; }
.foot { padding: var(--space-6) var(--space-4) var(--space-8); border-top: 1px solid var(--line); color: var(--ink-muted); text-align: center; font: 400 .875rem/1.4 var(--font-sans); }
.foot p { margin: .2rem 0; }

/* Keyvisual (tablet and desktop): above the search, folds away as soon as there are search criteria */
.keyvisual { display: none; }
.keyvisual img { display: block; width: 100%; height: auto; aspect-ratio: 1680 / 450; object-fit: cover; }

/* Start page: title (title-xl), introduction, search (card) */
.finder { margin: var(--space-4); padding: var(--space-5) var(--space-4) var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.finder h1 { font: 700 1.5rem/1.2 var(--font-serif); }   /* phone: title-l; from 48rem title-xl */
.intro { margin: var(--space-2) 0 0; font-size: .9375rem; }
html.searching .intro { display: none; }
.search { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }
.field-q, .field-sort, .search-actions { grid-column: 1 / -1; }
.search-actions { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-2); }   /* the two buttons wrap cleanly on phones */
.search-actions:not(:has(.btn:not([hidden]))) { display: none; }
.counter { margin: var(--space-4) 0 0; }
.counter strong { color: var(--accent); font-weight: 600; }

/* Feed: masonry columns (each new card into the shortest column) */
.notes { display: flex; gap: var(--space-4); align-items: flex-start; }
.notes-col { flex: 1; min-width: 0; }

/* Search results */
.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.results-bar .summary { margin: 0; }

/* Château page, wine page, Châteaux (titles in title-l) */
.page-head { margin: 0 0 var(--space-4); }
.page-head h1 { font: 700 1.5rem/1.2 var(--font-serif); }
.page-head .chateau-actions { padding: var(--space-3) 0 0; }
.wine-list { overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.wine-list .wine:first-child { border-top: 0; }
.wine-header { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-4); align-items: start; margin: 0 0 var(--space-2); }
.wine-header h1 { margin: 0; }
.wine-header .wine-chateau { font-size: 1.125rem; }
.wine-header .wine-chateau a { color: inherit; text-decoration: none; }
.wine-header .wine-chateau a:hover { text-decoration: underline; text-underline-offset: .2em; }
.wine-header .wine-vintage { font-size: 1.5rem; line-height: 1.2; }
.wine-header .meta { grid-column: 1 / -1; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-6) 0 0; }
.portrait { display: grid; grid-template-columns: max-content 1fr; gap: .3rem var(--space-4); margin: var(--space-4) 0 0; }
.portrait dt { color: var(--ink-muted); font: 400 .875rem/1.7 var(--font-sans); }
.portrait dd { margin: 0; font: 400 1.0625rem/1.6 var(--font-serif); white-space: pre-line; overflow-wrap: anywhere; }
.about { padding: var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.about .portrait { margin: 0; }

/* ===== Panel (château information, imprint): side panel from 48rem, full-screen sheet from below on phones ========= */
.panel { position: fixed; inset: 0; z-index: var(--z-panel); }
.panel-backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .25s ease; }
.panel-sheet {
    position: absolute; inset: 0; overflow-y: auto; outline: none;
    padding: max(var(--space-4), env(safe-area-inset-top, 0px)) var(--space-5) calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sheet);
    transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .7, .2, 1);
}
.panel.open .panel-backdrop { opacity: 1; }
.panel.open .panel-sheet { transform: none; }
.panel-close { position: sticky; top: 0; float: right; margin: -.25rem -.5rem 0 0; background: var(--surface); }
.panel-kicker { display: flex; align-items: center; gap: .4rem; margin: .4rem 0 .2rem; color: var(--accent); font: 600 .75rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .06em; }
.panel-sheet h2 { margin: 0 0 .25rem; font: 700 1.5rem/1.2 var(--font-serif); }
.panel-stats { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; font: 600 .9375rem/1.3 var(--font-sans); }
.panel-sheet .portrait { margin-bottom: var(--space-5); }
/* Imprint (#/impressum): sections with h3 like the wine rows, running text in the page's body style */
.panel-sheet h3 { margin: var(--space-6) 0 var(--space-2); font: 700 1.2rem/1.3 var(--font-serif); }
.imprint p { margin: 0 0 var(--space-3); }
html.panel-open, html.lightbox-open { overflow: hidden; }
@media (min-width: 48rem) { .panel-sheet { left: auto; width: clamp(22rem, 40vw, 32.5rem); transform: translateX(100%); } }

/* ===== Floating hints and dialogs ========================================================================= */
.install-hint {
    position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(var(--tabbar-h) + var(--space-3) + env(safe-area-inset-bottom, 0px)); z-index: var(--z-floating);
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-2) var(--space-3);
    max-width: 32rem; margin: 0 auto; padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-raised);
}
.install-hint > .i { color: var(--accent); width: 1.5rem; height: 1.5rem; }
.install-hint p { margin: 0; font: 400 .9375rem/1.4 var(--font-sans); }
.install-hint .hint-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2); }
html.keyboard .install-hint { display: none; }
@media (min-width: 48rem) { .install-hint { bottom: var(--space-4); } }
.ios-help { position: fixed; inset: 0; z-index: var(--z-dialog); display: grid; place-items: center; padding: var(--space-4); background: var(--scrim); }
.dialog-card { position: relative; max-width: 22rem; padding: var(--space-5) var(--space-5) var(--space-4); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-raised); }
.dialog-card h2 { margin: 0 2rem .6rem 0; font: 700 1.5rem/1.2 var(--font-serif); }
.dialog-card ol { margin: 0; padding-left: 1.3rem; font: 400 1rem/1.9 var(--font-sans); }
.dialog-card .i { color: var(--accent); }
.dialog-close { position: absolute; top: .4rem; right: .4rem; }
.ios-help-arrow { position: absolute; left: 50%; bottom: calc(.6rem + env(safe-area-inset-bottom, 0px)); color: var(--lightbox-ink); transform: translateX(-50%) rotate(90deg); animation: nudge 1.2s ease-in-out infinite; }
.ios-help-arrow .i { width: 2.4rem; height: 2.4rem; }
.ios-help.ipad .ios-help-arrow { top: .8rem; bottom: auto; left: auto; right: 6.5rem; transform: rotate(-90deg); }
@keyframes nudge { 50% { translate: 0 .35rem; } }

/* ===== Image gallery ===================================================================================== */
.lightbox { position: fixed; inset: 0; z-index: var(--z-lightbox); display: grid; grid-template-rows: 1fr auto; background: var(--lightbox-bg); color: var(--lightbox-ink); }
.lb-stage { position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; user-select: none; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform .12s ease-out; will-change: transform; }
.lightbox.zoomed .lb-stage img { cursor: grab; transition: none; }
.sx-page .lb-btn { position: absolute; z-index: 2; color: var(--lightbox-ink); background: rgba(0, 0, 0, .35); }
.lb-close { top: max(.6rem, env(safe-area-inset-top, 0px)); right: .6rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: .6rem; }
.lb-next { right: .6rem; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
.lb-caption { margin: 0; padding: .6rem var(--space-4) calc(.8rem + env(safe-area-inset-bottom, 0px)); text-align: center; font: 400 .875rem/1.4 var(--font-sans); }

/* ===== Start screen: only in the installed app (see index.html), at most 2 s ============================== */
/* Icon in the middle of the screen (as the Android system start screen), wordmark and sub line 1.5rem below */
.splash { --splash-icon: min(33vw, 160px); position: fixed; inset: 0; z-index: var(--z-splash); background: var(--bg); color: var(--ink); text-align: center; transition: opacity .3s ease; }
.splash.closing { opacity: 0; }
.splash-icon { position: absolute; left: 50%; top: 50%; width: var(--splash-icon); height: var(--splash-icon); transform: translate(-50%, -50%); }
.splash-brand { position: absolute; left: 0; right: 0; top: calc(50% + var(--splash-icon) / 2 + 1.5rem); display: flex; flex-direction: column; align-items: center; }
.splash-brand .wm { font-size: 2rem; }
.splash-brand .wm-sub { display: block; }
.splash:not([hidden]) ~ .tabbar { display: none; }   /* the start screen covers everything, also the tab bar */
html.subpage #finder, html.subpage #keyvisual { display: none; }   /* see index.html, until app.js takes over */

/* ===== Toast: short feedback floating above the tab bar (phone) or bottom centre (desktop); 0.25 s in, 4 s, out == */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--space-3) + env(safe-area-inset-bottom, 0px)); z-index: var(--z-floating);
    display: flex; align-items: center; gap: var(--space-2); width: max-content; max-width: min(22rem, calc(100% - 2 * var(--space-4)));
    padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
    box-shadow: var(--shadow-raised); color: var(--ink); font: 600 .9375rem/1.3 var(--font-sans); cursor: pointer;
    opacity: 0; transform: translate(-50%, .5rem); transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .i { flex: none; width: 1.25rem; height: 1.25rem; color: var(--accent); }
html.keyboard .toast { display: none; }
@media (min-width: 48rem) { .toast { bottom: var(--space-6); } }

/* ===== Tablet 48–75rem ===================================================================================== */
@media (min-width: 48rem) {
    main { padding: var(--space-6) var(--space-6) var(--space-8); }
    .page-bar { margin-top: calc(-1 * var(--space-6)); }
    .keyvisual {
        display: grid; grid-template-rows: 1fr; max-width: var(--content-max); margin: var(--space-5) auto 0; padding: 0 var(--space-6);
        transition: grid-template-rows .45s ease, margin .45s ease, opacity .35s ease;
    }
    .keyvisual > picture { overflow: hidden; min-height: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    html.searching .keyvisual { grid-template-rows: 0fr; margin-top: 0; opacity: 0; }
    .finder { width: calc(100% - 2 * var(--space-6)); max-width: calc(var(--content-max) - 2 * var(--space-6)); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-5); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    html.searching .finder, html.no-keyvisual .finder { margin-top: var(--space-5); border-radius: var(--radius-lg); }
    .search { grid-template-columns: 2fr 1fr 1fr; }
    .search:has(.field-sort:not([hidden])) { grid-template-columns: 2fr 1fr 1fr 1.3fr; }
    .field-q, .field-sort { grid-column: auto; }
    .finder h1 { font-size: 2.25rem; line-height: 1.15; }
    .cards { grid-template-columns: 1fr 1fr; }
    /* PageColumn (design system): reading and list pages – Bewertungen, wine page, château page – in one centred
       column of reading-max; PageBar, title and content share one edge. Overviews keep content-max. */
    .page-column { width: calc(100% - 2 * var(--space-6)); max-width: var(--reading-max); margin-inline: auto; }
    main.page-column { padding-inline: 0; }
    .page-column .cards { grid-template-columns: 1fr; }
    .page-column .search:has(.field-sort:not([hidden])) { grid-template-columns: 1fr 1fr; }   /* Bewertungen: 2 × 2 fields in the column */
}
/* ===== Desktop ≥ 75rem ===================================================================================== */
@media (min-width: 75rem) {
    .cards { grid-template-columns: 1fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .btn, .tasting-card, .keyvisual, .splash, .panel-sheet, .panel-backdrop, .lb-stage img, .theme-toggle .tt-knob, .toast { transition: none; }
    .ios-help-arrow { animation: none; }
}
