/**
 * TERROIR — critical stylesheet, loaded on every page.
 *
 * Holds only what every page needs: the reset, the type scale, the section
 * grid, and the shared primitives (button, field, paper sheet, data row).
 * Everything else lives inside its own section's {% stylesheet %} tag.
 *
 * Colours are never written literally here. Every value reads a token from
 * snippets/css-variables.liquid, so a merchant recolouring the theme in the
 * editor recolours this file too — and a region wrapped in .on-label flips
 * to paper without a single override.
 */

/* ---------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html:has(dialog[scroll-lock][open], details[scroll-lock][open]),
html:has(body[data-scroll-locked]) {
  overflow: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/**
 * Lists lose their markers wherever the theme lays them out itself — menus,
 * footers, filter groups. The role="list" attribute on each one restores the
 * semantics VoiceOver drops when list-style is none, so the markup stays a
 * list to a screen reader while the design stops looking like one.
 */
ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
  margin: 0;
}

svg {
  fill: currentcolor;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

p {
  text-wrap: pretty;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p:empty {
  display: none;
}

:is(p, h1, h2, h3, h4, h5, h6):first-child {
  margin-block-start: 0;
}

:is(p, h1, h2, h3, h4, h5, h6):last-child {
  margin-block-end: 0;
}

/* ----------------------------------------------------------------- type */

h1,
h2,
h3,
h4,
.h1,
.h2,
.h3,
.h4 {
  font-family: var(--font-head);
  font-weight: 400;
  line-height: var(--leading-head);
  letter-spacing: -0.012em;
  font-optical-sizing: auto;
  text-wrap: balance;
}

h1,
.h1 {
  font-size: clamp(var(--step-3), 4.6vw, var(--step-5));
  line-height: var(--leading-tight);
}

h2,
.h2 {
  font-size: clamp(var(--step-2), 3.2vw, var(--step-4));
}

h3,
.h3 {
  font-size: var(--step-2);
}

h4,
.h4 {
  font-size: var(--step-1);
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

a:hover {
  text-decoration-color: var(--color-accent);
}

/**
 * Eyebrow — the small tracked capital line above a heading.
 * Tracking comes from a token so a merchant can loosen every one at once.
 */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/**
 * Data — altitude, weight, vintage, lot number.
 * These read as measurements through tabular figures and tracking, not
 * through a third typeface. Lining figures keep columns aligned.
 */
.data {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  letter-spacing: var(--tracking-data);
}

/* Provenance is the one thing allowed to be verdigris. */
.origin {
  color: var(--color-origin);
}

.rte > * + * {
  margin-block-start: var(--space-s);
}

.rte :is(h2, h3, h4) {
  margin-block-start: var(--space-l);
}

.rte a {
  text-decoration: underline;
}

.rte :is(ul, ol) {
  padding-inline-start: 1.25em;
}

.rte img {
  width: 100%;
  border-radius: var(--radius);
}

/* --------------------------------------------------------------- layout */

/**
 * Three-column grid: margin, content, margin. Children sit in the centre
 * column by default; .full-width children span the viewport. Lets a section
 * bleed an image edge to edge without leaving the grid.
 */
.shopify-section {
  --content-width: min(
    calc(var(--page-width) - var(--page-margin) * 2),
    calc(100% - var(--page-margin) * 2)
  );
  --content-margin: minmax(var(--page-margin), 1fr);

  position: relative;
  display: grid;
  grid-template-columns: var(--content-margin) var(--content-width) var(--content-margin);
  width: 100%;
}

.shopify-section > * {
  grid-column: 2;
}

.shopify-section > .full-width {
  grid-column: 1 / -1;
}

.main {
  flex: 1 0 auto;
  min-width: 0;
}

/**
 * A flex or grid item defaults to min-width:auto, which means it refuses to
 * shrink below its own min-content width. A section holding a
 * repeat(auto-fit, minmax(min(140px, 100%), 1fr)) grid reports a min-content width of
 * three whole columns, so on a narrow phone the section stops shrinking and
 * the page scrolls sideways. Setting min-width:0 on everything the layout
 * owns lets sections shrink to the viewport, which is what they should do.
 */
body > *,
.main > * {
  min-width: 0;
}

.main:focus {
  outline: none;
}

.page-width {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--page-margin);
}

.section-padding {
  padding-block: var(--space-2xl);
}

@media screen and (max-width: 749px) {
  .section-padding {
    padding-block: var(--space-xl);
  }
}

.hairline {
  border: 0;
  border-block-start: 1px solid var(--color-hairline);
}

/* -------------------------------------------------------- accessibility */

.visually-hidden {
  position: absolute !important;
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/**
 * One focus rule for the whole theme. :focus-visible keeps the ring off
 * mouse users without ever hiding it from the keyboard.
 */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius);
}

.skip-link {
  position: absolute;
  z-index: 100;
  inset-inline-start: var(--space-s);
  inset-block-start: var(--space-s);
  transform: translateY(-200%);
  transition: transform var(--motion-fast) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* -------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background-color: var(--color-accent);
  color: var(--color-accent-contrast);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: var(--button-tracking);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-transform: var(--button-transform);
  cursor: pointer;
  transition: background-color var(--motion) var(--ease), color var(--motion) var(--ease),
    border-color var(--motion) var(--ease), opacity var(--motion) var(--ease);
}

.button:hover {
  background-color: color-mix(in oklab, var(--color-accent) 84%, var(--color-bg));
}

.button:disabled,
.button[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.button--secondary {
  background-color: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.button--secondary:hover {
  background-color: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.button--ghost {
  min-height: 0;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--color-text);
  text-transform: none;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.button--ghost:hover {
  background: none;
  color: var(--color-accent);
}

.button--full {
  width: 100%;
}

/**
 * Shopify's dynamic checkout buttons — Shop Pay, Apple Pay, Google Pay.
 * Only reachable through {{ form | payment_button }} inside a real
 * {% form 'product' %}; a hand-written form to /cart/add cannot render them.
 */
.shopify-payment-button {
  margin-block-start: var(--space-2xs);
}

.shopify-payment-button__button--unbranded {
  min-height: 44px;
  border-radius: var(--radius) !important;
  background-color: transparent !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text) !important;
  font-family: var(--font-body) !important;
  font-weight: 600 !important;
  letter-spacing: var(--button-tracking) !important;
  text-transform: var(--button-transform) !important;
}

/* --------------------------------------------------------------- fields */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.field__label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.field__input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: transparent;
  color: var(--color-text);
  font-size: 0.95rem;
}

.field__input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.field__input:focus {
  border-color: var(--color-accent);
}

/* An invalid field says so on its edge as well as in its message. The message
   still carries the meaning — the border alone would be colour as the only
   channel, which WCAG 1.4.1 does not allow. */
.field__input[aria-invalid='true'],
.field__input:user-invalid {
  border-color: var(--color-error);
}

.field__error {
  color: var(--color-error);
  font-size: 0.82rem;
}

select {
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* ---------------------------------------------------------- paper sheet */

/**
 * The paper primitive. Any block that carries product data — the product
 * sheet, the lot card, the tasting notes — sits on this. The .on-label
 * class in css-variables.liquid re-points every colour token, so children
 * need no overrides of their own.
 */
.sheet {
  background-color: var(--color-label);
  color: var(--color-label-ink);
  border-radius: var(--radius-label);
  padding: var(--space-l);
}

.sheet--tight {
  padding: var(--space-m);
}

/* A data row as it appears on a producer's label: term left, value right,
   joined by a dotted rule so the eye tracks across. */
.data-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: var(--space-2xs);
  padding-block: 0.45rem;
  font-size: 0.88rem;
}

.data-row + .data-row {
  border-block-start: 1px solid var(--color-hairline);
}

.data-row__term {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  font-size: 0.68rem;
  font-weight: 500;
}

/* The leader: the middle grid column filled with a dotted rule, sitting on
   the text baseline so the eye tracks from the term across to the figure.
   It is decoration, so it carries no contrast obligation and stays faint. */
.data-row__leader {
  align-self: end;
  margin-block-end: 0.3em;
  border-block-end: 1px dotted var(--color-hairline);
  min-width: var(--space-s);
}

.data-row__value {
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: var(--tracking-data);
  text-align: end;
}

/* ---------------------------------------------------------------- media */

.media {
  position: relative;
  overflow: hidden;
  background-color: var(--color-surface);
  border-radius: var(--radius);
}

.media img,
.media svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media--portrait { aspect-ratio: 4 / 5; }
.media--square { aspect-ratio: 1 / 1; }
.media--bottle { aspect-ratio: 2 / 3; }
.media--wide { aspect-ratio: 16 / 9; }

/* --------------------------------------------------------------- motion */

/**
 * Reveal on scroll. Starts visible: if the JS never runs, or the merchant
 * turns motion off, the content is still there. Nothing is hidden by CSS
 * that JavaScript is responsible for showing.
 */
[data-reveal] {
  opacity: 1;
}

html[data-motion='on'] [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--motion-slow) var(--ease), transform var(--motion-slow) var(--ease);
}

html[data-motion='on'] [data-reveal][data-revealed] {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html[data-motion='on'] [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
