/* A bottle's details and the add / edit form: the dialog (a bottom sheet or full-screen form on
   phones), text fields, facts, the window bar, "How we know", the wine search menu. Shared by the
   cellar app and the home page's demo fridge. Load after tokens.css and components.css. */
/* ---------- Dialog ---------- */
/* Material basic dialog on wider screens: extra-large corners, a container surface, level 3.
   On phones (below 600 px) bottle details become a modal bottom sheet and forms a full-screen
   dialog (see the end of this block). */
dialog {
  border: 0;
  border-radius: var(--r-xl);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);   /* the visible height on phones, with the browser bars */
  overflow-y: auto;                  /* a long dialog scrolls inside itself... */
  overscroll-behavior: contain;      /* ...and reaching its end doesn't scroll the page behind */
  background: var(--surface-container-high);
  color: var(--on-surface);
  box-shadow: var(--elev-3);
}
/* The same backdrop as the details drawer: a light tint with the page behind softly blurred. */
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.dlg { padding: 24px; display: grid; gap: 16px; }
/* Swiping between bottles (carousel.js), like between fridges: the details follow the finger and
   the next bottle slides in from that side. Vertical scrolling stays with the browser. */
#dlg { touch-action: pan-y pinch-zoom; transition: transform .22s ease, opacity .22s ease; }
#dlg.in-right { animation: in-from-right .22s ease-out; }
#dlg.in-left { animation: in-from-left .22s ease-out; }
/* The dots stay in view: pinned to the bottom of the details while they scroll, floating over them. */
.dlg-dots { margin-top: 2px; position: sticky; bottom: 12px; z-index: 2; box-shadow: var(--elev-2); }
@media (prefers-reduced-motion: reduce) { #dlg.in-right, #dlg.in-left { animation: none; } #dlg { transition: none; } }
.dlg-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
/* Eyebrow above a title ("Rung 1 · Space 3"): Material label small. */
.slotcode { font-family: var(--body); font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--on-surface-variant); text-transform: uppercase; }
/* Dialog titles: Material headline small, in the sans (the app uses no serif). */
.dlg h3 { font-family: var(--body); font-size: 24px; font-weight: 500; line-height: 1.25; margin: 4px 0 0; text-wrap: balance; }
/* Close (×) and header icons: Material standard icon buttons. */
.x { appearance: none; border: 0; background: none; color: var(--on-surface-variant); width: 48px; height: 48px; border-radius: 50%; cursor: pointer; font-size: 26px; line-height: 1; flex: none;
  transition: background-color var(--dur-short) var(--ease); }
.x:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.style-line { margin: 2px 0 0; font-size: 13px; font-weight: 600; color: var(--primary); }
.dlg-head-actions { display: flex; gap: 0; margin: -8px -12px 0 0; }
.icon-btn:focus-visible, .x:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
/* A form's header: close, title, Save (Save only on phones; wider screens use the bottom buttons). */
.form-head { grid-template-columns: auto 1fr auto; align-items: center; }
.form-head .form-close { margin: -8px 0 -8px -12px; }
.top-save { display: none; }

/* The bottom sheet's drag handle (phones only). */
.sheet-handle { display: none; }

/* ---------- Text fields: Material outlined (label in the border, supporting text under) ---------- */
.tf { position: relative; display: grid; gap: 0; }
.tf .tf-l {
  position: absolute; top: -8px; left: 12px; z-index: 1; padding: 0 4px; max-width: calc(100% - 24px);
  font-size: 12px; line-height: 16px; font-weight: 400; color: var(--on-surface-variant);
  background: var(--tf-bg, var(--surface-container-high)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tf:focus-within .tf-l { color: var(--primary); }
.tf .tf-sup { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); padding: 4px 16px 0; }

@media (max-width: 599px) {
  /* Bottle details (and a drunk bottle): a modal bottom sheet. */
  #dlg:has(> .dlg[data-seq-id]) {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: calc(100dvh - 48px); background: var(--surface-container-low); --tf-bg: var(--surface-container-low);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #dlg:has(> .dlg[data-seq-id]) .dlg { padding-top: 0; }
  #dlg:has(> .dlg[data-seq-id]) .dlg-head .x:not(.icon-btn) { display: none; }   /* the handle, the scrim and Back close it */
  .sheet-handle {
    display: block; appearance: none; border: 0; background: none; cursor: grab; justify-self: center;
    width: 48px; height: 24px; margin: 0 auto -8px; padding: 0; position: relative; touch-action: none;
  }
  .sheet-handle::before { content: ""; position: absolute; left: 8px; right: 8px; top: 10px; height: 4px; border-radius: 2px; background: var(--on-surface-variant); opacity: .4; }
  #dlg:has(> .dlg[data-seq-id]) .actions .btn.primary { flex: 1; min-height: 48px; }
  /* Forms: a full-screen dialog with Save in the header. */
  #dlg:has(> form.dlg) {
    width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
    background: var(--surface); --tf-bg: var(--surface);
  }
  #dlg:has(> form.dlg)::backdrop { background: transparent; backdrop-filter: none; }
  form.dlg:has(.top-save) .actions { display: none; }
  .top-save { display: inline-flex; font-size: 15px; }
}

/* Fact lists (label, value): bottle details, the edit form's wine list block, Account. */
.facts, .acct-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt, .acct-facts dt { color: var(--muted); font-size: 13px; }
.facts dd, .acct-facts dd { margin: 0; overflow-wrap: anywhere; }

.window { display: grid; gap: 6px; }
.pill { justify-self: start; display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: var(--r-pill); border: 1px solid var(--c); color: var(--ink); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.window .track { position: relative; height: 34px; }
.window .track .bar { position: absolute; top: 8px; height: 8px; border-radius: var(--r-xs); background: var(--st-ready); opacity: .85; }
.window .track .axis { position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--line); }
.window .track .now { position: absolute; top: 2px; width: 2px; height: 20px; background: var(--ink); }
.window .track .tick { position: absolute; top: 20px; font-family: var(--body); font-size: 11px; font-weight: 500; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.window .track .tick.is-now { font-weight: 700; color: var(--ink); }
.row-nv { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.tn { display: grid; gap: 8px; }
.tnote { margin: 0; display: grid; gap: 4px; padding-left: 12px; border-left: 2px solid var(--line); }
.tnote blockquote { margin: 0; max-width: 65ch; }
.tnote figcaption { font-size: 12px; color: var(--muted); font-weight: 600; }
.srcs { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.dlg a { color: var(--accent); }
.notes-empty { color: var(--muted); font-style: italic; margin: 0; }
.added { font-size: 12px; color: var(--muted); margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
/* Buttons: look and variants in components.css; the app's size here. */
.btn.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.btn .btn-icon { display: inline-grid; }
.btn .btn-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

form.dlg label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
/* Text fields (Material outlined): 56 px, a 1 px outline, 4 px corners; focus is a 2 px primary outline. */
form.dlg input, form.dlg select, form.dlg textarea, .acct-sheet input, .acct-confirm input {
  font: inherit; font-size: 16px; color: var(--on-surface); background: transparent;
  border: 1px solid var(--outline); border-radius: var(--r-xs); padding: 0 16px; min-height: 56px; width: 100%;
}
form.dlg select { padding-right: 8px; }
form.dlg input::placeholder { color: var(--on-surface-variant); opacity: .8; }
form.dlg textarea { min-height: 110px; resize: vertical; padding: 16px; }
form.dlg input:hover, form.dlg select:hover, .acct-sheet input:hover { border-color: var(--on-surface); }
form.dlg input:focus, form.dlg select:focus, form.dlg textarea:focus, .acct-sheet input:focus, .acct-confirm input:focus { outline: 2px solid var(--primary); outline-offset: -2px; border-color: transparent; }
form.dlg .tf + .tf, .row-nv, .row2 { margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--on-surface-variant); margin: -4px 0 0; }
.err { color: var(--error); font-size: 13px; margin: 0; }
form.dlg [aria-invalid="true"] { border-color: var(--error); outline-color: var(--error); }

/* ---------- Wine list (catalogue): suggestions, the picked line, research states ---------- */
/* Suggestions under the name field, in the normal flow (an overlay would be clipped by the dialog). */
/* A Material menu under the field: a container surface, small corners, level 2. */
.cb-list { list-style: none; margin: -4px 0 0; padding: 8px 0; border: 0; border-radius: var(--r-xs); background: var(--surface-container); box-shadow: var(--elev-2); display: grid; gap: 0; }
.cb-list[hidden] { display: none; }
.cb-list li { padding: 10px 16px; min-height: 48px; display: grid; gap: 1px; align-content: center; cursor: pointer; }
.cb-list li[aria-selected="true"], .cb-list li[role="option"]:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.cb-list .nm { color: var(--ink); font-size: 15px; }
.cb-list .meta { font-size: 12px; color: var(--muted); }
.cb-list .cb-foot { cursor: default; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); border-radius: 0; margin-top: 2px; padding-top: 8px; }

/* "From our wine list" line under the name once a wine is picked. */
.linked { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; margin: -6px 0 0; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.linked[hidden] { display: none; }
.linked strong { color: var(--ink); font-weight: 600; }
.linked p { margin: 0; }
.dlg .link-btn { font-size: 14px; }
.source-line { margin: -6px 0 0; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }

/* "Is it one of these?" */
.review { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--notice-line); background: var(--notice-bg); border-radius: var(--r-md); }
.review h4 { margin: 0; font-size: 15px; font-weight: 600; }
.review > p { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.cand { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
.cand .nm { font-weight: 600; }
.cand .meta { font-size: 12px; color: var(--muted); }

/* The wine list's details in the edit form of a linked bottle (shown, not editable). */
.ro { display: grid; gap: 8px; padding: 12px 14px; }
.ro-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ro .facts dd { font-size: 14px; }

/* ======================================================================
   Identifying a bottle
   ====================================================================== */
.cb-list .cb-empty { border-top: 0; margin-top: 0; }
form.dlg label[hidden] { display: none; }

/* What the user typed, under a bottle now linked to a catalogue wine. */
.yours { margin: -6px 0 0; font-size: 12px; color: var(--muted); }
.yours q { color: var(--ink); quotes: "“" "”"; }

/* Where the lookup is: three quiet steps. */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.steps li { display: flex; gap: 8px; align-items: baseline; }
.steps li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--muted); flex: 0 0 auto; transform: translateY(-1px); }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--muted); }
.steps li.now::before { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* "How we know": identification, details, drinking window, a word each for how sure. */
.how { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md, 8px); background: var(--field); }
.how[hidden] { display: none; }
.how-row { display: grid; grid-template-columns: 7.5em 1fr auto; gap: 10px; align-items: baseline; font-size: 13px; }
.how-row .k { color: var(--muted); }
.how-row .v { color: var(--ink); }
.how-row .v small { display: block; color: var(--muted); font-size: 12px; }
/* How sure (High, Good, Fair ...): a small Material label chip in the sans. */
.sure { font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: var(--r-sm); background: var(--surface-container-highest); color: var(--on-surface-variant); white-space: nowrap; }
.sure.high { color: var(--st-ready-text); }
.sure.good { color: var(--st-wait-text); }
.sure.fair { color: var(--st-last-text); }

/* Typical for the style, until the producer's own details arrive (always labelled). */
.typical { margin: 0; font-size: 14px; color: var(--ink); }
.typical-k { font-size: 12px; color: var(--muted); }
.typical .typical-k { display: block; margin-bottom: 2px; }

/* Moved from cellar.css so the home page demo shares them. */
/* Page dots (scripts/cellar/page-dots.js): at most five in a sliding window; where more lie beyond
   an end, the last two on that side shrink. The window clips sideways only, so each dot keeps its
   tall tap area. */
.fridge-dots {
  display: flex; justify-content: center; align-items: center; min-height: 24px;
  width: fit-content; margin: 0 auto; padding: 8px 14px; border-radius: var(--r-pill); background: var(--dots-bg);
}
.pd-view { overflow-x: clip; }
.pd-track { display: flex; transition: transform var(--dur-medium) var(--ease); }
.fridge-dot {
  appearance: none; position: relative; flex: 0 0 20px; width: 20px; height: 24px; display: grid; place-items: center;
  border: none; padding: 0; background: none; cursor: pointer; border-radius: var(--r-pill);
}
.fridge-dot::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 48px; transform: translateY(-50%); }
.pd-dot {
  width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--dot-idle);
  transition: width var(--dur-medium) var(--ease), transform var(--dur-medium) var(--ease),
              background-color var(--dur-medium) var(--ease), opacity var(--dur-medium) var(--ease);
}
.fridge-dot.on .pd-dot { width: 20px; background: var(--dot-active); }
.fridge-dot.mid .pd-dot { transform: scale(.75); }
.fridge-dot.small .pd-dot { transform: scale(.5); }
.fridge-dot.out .pd-dot { transform: scale(0); opacity: 0; }
.fridge-dot.out { pointer-events: none; }
/* The last page's dot: a plus; on that page, the pill with a plus cut out. */
.pd-plus { width: 12px; height: 12px; background: none; display: grid; place-items: center; }
.pd-plus svg { width: 12px; height: 12px; fill: none; stroke: var(--outline); stroke-width: 2.6; stroke-linecap: round; }
.fridge-dot.on .pd-plus { width: 20px; height: 12px; background: var(--dot-active); }
.fridge-dot.on .pd-plus svg { width: 10px; height: 10px; stroke: var(--dots-bg); stroke-width: 3; }
.fridge-dot:focus-visible { outline: none; }
.fridge-dot:focus-visible .pd-dot { outline: 2px solid var(--primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .pd-track, .pd-dot { transition: none; } }
