@font-face {
  font-family: "DM Sans";
  src: url("fonts/pw-dm-sans-latin.woff2") format("woff2");
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("fonts/pw-atkinson-mono-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #16141a;
  --ground: #f2f2f6;
  --lavender: #ceb7ef;
  --lilac: #eee6f9;
  --muted: #45414c;
  --white: #fff;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --gutter: clamp(16px, 2.2vw, 28px);
  --sans: "DM Sans", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--lilac);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--lavender); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#stage canvas:active { cursor: grabbing; }
#stage.is-pointing canvas { cursor: pointer; }

/* Header */
.top {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(var(--gutter), env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.wordmark {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), 0 4px 0 0 var(--ink);
}
.wordmark svg { height: 18px; width: auto; }

/* Buttons: white face, 1px ink edge, 4px ink lip (primalwine.com clickable style) */
.btn {
  --face: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: var(--face);
  color: var(--ink);
  font: 600 16px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--ink), 0 4px 0 0 var(--ink);
  transform: translateY(0);
  transition: transform 90ms ease-out, box-shadow 90ms ease-out, background-color 150ms ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 1px var(--ink), 0 1px 0 0 var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--lilac); }
  .btn--primary:hover { background: #bfa3e8; }
}
.btn--primary { --face: var(--lavender); }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Bay bar */
.bays {
  position: fixed;
  left: 0; right: 0;
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.bays ul {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 10px 10px 14px;
  border-radius: 18px;
  background: rgb(242 242 246 / 0.92);   /* keeps the ink edge + lip readable over dark shelves */
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
}
.bays ul::-webkit-scrollbar { display: none; }
.bay-btn { gap: 10px; padding: 0 16px; }
.bay-btn .count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.bay-btn[aria-current="true"] { --face: var(--lavender); }
.bay-btn[aria-current="true"] .count { color: var(--ink); }
@media (max-width: 600px) {
  .bays { padding: 0; }
  .bays ul { padding: 10px var(--gutter) 14px; border-radius: 18px 18px 0 0; scroll-padding: 0 var(--gutter); }
  .bays { bottom: 0; }
  .bay-btn { min-height: 44px; padding: 0 14px; font-size: 15px; }
}

/* First-visit hint */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(max(var(--gutter), env(safe-area-inset-bottom)) + 92px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 14px;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 300ms ease, transform 300ms var(--ease-out);
  pointer-events: none;
}
.hint.is-gone { opacity: 0; transform: translate(-50%, 6px); }

/* Hover tooltip over a bottle */
.tip {
  position: fixed;
  left: 0; top: 0;
  max-width: 260px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--white);
  font-size: 14px;
  line-height: 1.3;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  will-change: left, top;
}
.tip b { display: block; font-weight: 500; }
.tip span { color: var(--lavender); font-variant-numeric: tabular-nums; }

/* Wine panel */
.panel {
  position: fixed;
  top: calc(var(--gutter) + 64px);
  right: var(--gutter);
  max-height: calc(100svh - var(--gutter) - 64px - 110px);
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 0 0 1px var(--ink), 0 18px 40px -12px rgb(22 20 26 / 0.35);
  overflow: hidden;
  transition: transform 320ms var(--ease-drawer), opacity 200ms ease;
}
.panel[hidden] { display: flex; visibility: hidden; opacity: 0; transform: translateX(24px); pointer-events: none; }
.panel__bar { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 8px; }
.panel__pos { flex: 1; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.panel__bar #p-prev { order: -2; }
.panel__bar #p-next { order: -1; margin-right: 8px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease-out;
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--lilac); } }
.panel__body { flex: 1; overflow-y: auto; padding: 0 20px; }
.panel__img { display: block; width: 100%; max-width: 260px; height: auto; aspect-ratio: 1; margin: 0 auto; }
.panel__title {
  margin: 4px 0 6px;
  font: 500 22px/1.15 var(--mono);
  letter-spacing: -0.035em;
  text-transform: uppercase;
  -webkit-text-stroke: 0.025em currentColor;
  text-wrap: balance;
}
.panel__price { margin: 0 0 14px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 16px; }
.facts th, .facts td { padding: 8px 0; border-top: 1px solid rgb(22 20 26 / 0.14); text-align: left; vertical-align: top; }
.facts th { width: 92px; color: var(--muted); font-weight: 500; }
.panel__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 20px 20px; border-top: 1px solid rgb(22 20 26 / 0.14); }

@media (max-width: 600px) {
  .panel {
    top: auto;
    max-height: 56svh;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 56svh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel[hidden] { transform: translateY(100%); opacity: 1; }
  .panel__body { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: start; padding: 4px 16px 0; }
  .panel__img { width: 112px; }
  .panel__title { font-size: 18px; margin-top: 2px; }
  .panel__price { font-size: 18px; margin-bottom: 8px; }
  .facts { font-size: 14px; }
  .facts th { width: 76px; }
  .panel__actions { padding: 12px 16px 16px; }
  body.has-panel .bays, body.has-panel .hint { visibility: hidden; }
}

/* Loading and error state */
.status {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--lilac);
  font: 500 18px/1.3 var(--mono);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  text-align: center;
  padding: var(--gutter);
  transition: opacity 500ms ease, visibility 500ms;
}
.status p { margin: 0; max-width: 32ch; }
.status.is-done { opacity: 0; visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .panel, .hint, .btn, .icon-btn, .status { transition-duration: 0ms; }
}
