/* =============================================================================
   Chester Paws — core.css  (MECHANICS LAYER)
   -----------------------------------------------------------------------------
   Owns: design tokens, reset, overflow guards, z-index stacking, and the
   functional CSS that main.js depends on (states set via data-* attributes).
   Visual design (textures, typography scale, section looks) lives in styles.css.
   Safe to retune token VALUES; do not delete the functional rules marked ⚙.
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens -- */
:root {
  /* Environment palette (from plan: "Hertfordshire Trail & Cedar Studio") */
  --c-chalk: #F6F4EC;      /* page background */
  --c-vellum: #EAE6D7;     /* alternate section surface */
  --c-pine: #182C21;       /* primary text / deep surfaces */
  --c-cedar: #C26333;      /* primary accent */
  --c-moss: #2A6B46;       /* open / trust accent */
  --c-stone: #D5CFC0;      /* borders */
  --c-white: #FFFFFF;

  /* Brand palette sampled from the real Chester Paws logo */
  --c-logo-ink: #161616;
  --c-logo-slate: #A9A8B6;  /* grey-lavender greyhound */
  --c-logo-peach: #F9D7B6;  /* poodle body */
  --c-logo-curl: #9A6B47;   /* curly ears */
  --c-logo-curl-dk: #78543C;

  /* Status */
  --c-open: var(--c-moss);
  --c-soon: #B7791F;
  --c-closed: #A23B2A;
  --c-error: #A23B2A;
  --c-success: var(--c-moss);

  /* Type */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* Layout */
  --container: 1200px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 72px;           /* overwritten live by main.js */
  --section-pad: clamp(4rem, 9vw, 7.5rem);

  /* Motion */
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --dur: .45s;

  /* Z-index scale — header must sit above Leaflet panes/controls */
  --z-map: 0;
  --z-header: 1100;
  --z-nav: 1150;
  --z-lightbox: 2000;
  --z-skip: 3000;
}

/* ----------------------------------------------------------------- Reset -- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--c-pine);
  background: var(--c-chalk);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }
blockquote, figure { margin: 0; }
address { font-style: normal; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

/* ⚙ Horizontal-overflow guard (QA target: scrollWidth <= innerWidth on 390px) */
html, body { overflow-x: clip; }
@supports not (overflow: clip) { html, body { overflow-x: hidden; } }

/* ⚙ Anchor targets land below the sticky header */
section[id], [id="top"] { scroll-margin-top: var(--header-h); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------- Utilities -- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 1rem; top: -100px; z-index: var(--z-skip);
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  background: var(--c-pine); color: var(--c-white); text-decoration: none;
}
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid var(--c-cedar); outline-offset: 3px; }

/* ------------------------------------------------------ ⚙ Header + nav -- */
.site-header { position: sticky; top: 0; z-index: var(--z-header); }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; }
.nav-toggle { display: none; }

@media (max-width: 959.98px) {
  .nav-toggle {
    display: inline-grid; place-items: center;
    width: 44px; height: 44px; border: 0; background: transparent; padding: 0;
    position: relative; z-index: calc(var(--z-nav) + 1);
  }
  .nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
    content: ''; display: block; width: 22px; height: 2px; border-radius: 2px;
    background: currentColor; transition: transform var(--dur) var(--ease-out), opacity .2s;
  }
  .nav-toggle__bars { position: relative; }
  .nav-toggle__bars::before { position: absolute; top: -7px; }
  .nav-toggle__bars::after { position: absolute; top: 7px; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-7px) rotate(-45deg); }

  .site-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; z-index: var(--z-nav);
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
    visibility: hidden; opacity: 0; transform: translate3d(0, -8px, 0);
    transition: opacity .25s var(--ease-out), transform .25s var(--ease-out), visibility 0s .25s;
  }
  .nav-open .site-nav {
    visibility: visible; opacity: 1; transform: none;
    transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
  }
  .nav-open body { overflow: hidden; }
}

/* --------------------------------------------- ⚙ Live hours status pill -- */
.status-pill { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.status-pill__dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--c-stone); flex: none; }
.status-pill[data-state="open"] .status-pill__dot { background: var(--c-open); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-open) 25%, transparent); }
.status-pill[data-state="soon"] .status-pill__dot { background: var(--c-soon); }
.status-pill[data-state="closed"] .status-pill__dot { background: var(--c-closed); }
.hours tr[data-today] { font-weight: 700; }

/* ------------------------------------------------------------ ⚙ Tabs -- */
.tabs__list { display: flex; flex-wrap: wrap; gap: .5rem; }
.tabs__tab[aria-selected="true"] { /* visual style in styles.css */ }

/* ------------------------------------------------ ⚙ Gallery + lightbox -- */
.gallery__item > button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.filter[aria-pressed="true"] { /* visual style in styles.css */ }

.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--c-white);
  z-index: var(--z-lightbox);
}
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: rgb(12 18 14 / .92); }
.lightbox:not([open]) { display: none; }
.lightbox__inner {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: .5rem; width: min(100%, 1200px); height: 100%; padding: 3.5rem .75rem 1rem;
}
.lightbox__figure { display: grid; justify-items: center; gap: .75rem; min-width: 0; max-height: 100%; }
.lightbox__figure img {
  max-width: 100%; max-height: calc(100dvh - 8rem); width: auto; height: auto; object-fit: contain;
  border-radius: var(--radius-sm); opacity: 0; transition: opacity .3s var(--ease-out);
}
.lightbox__figure img.is-loaded { opacity: 1; }
.lightbox__figure figcaption { font-size: .95rem; text-align: center; }
.lightbox__counter { font-family: var(--font-mono); opacity: .7; margin-left: .5rem; }
.lightbox__close, .lightbox__nav {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid rgb(255 255 255 / .3); background: rgb(255 255 255 / .08); color: inherit;
  font-size: 1.6rem; line-height: 1;
}
.lightbox__close { position: absolute; top: .75rem; right: .75rem; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgb(255 255 255 / .18); }
.lightbox-open body { overflow: hidden; }
@media (max-width: 600px) {
  .lightbox__inner { grid-template-columns: 1fr; padding-inline: .5rem; }
  .lightbox__nav { position: absolute; bottom: 1rem; }
  .lightbox__nav--prev { left: 1rem; }
  .lightbox__nav--next { right: 1rem; }
  .lightbox__figure img { max-height: calc(100dvh - 10rem); }
}

/* --------------------------------------------------- ⚙ Review deck track -- */
/* JS drives transform on .reviews__track. NEVER add overflow-x:auto or scroll-snap here. */
.reviews__viewport {
  overflow: hidden;
  touch-action: pan-y;          /* vertical page scroll stays native; horizontal drag → JS */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  padding-inline: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
}
[data-dragging] .reviews__viewport { cursor: grabbing; }
.reviews__track {
  display: flex; gap: 1.25rem; width: max-content;
  will-change: transform; transform: translate3d(0, 0, 0); backface-visibility: hidden;
}
.review { flex: 0 0 clamp(280px, 82vw, 400px); }
.reviews__track img { pointer-events: none; -webkit-user-drag: none; }
.reviews__progress { position: relative; height: 3px; overflow: hidden; flex: 1; border-radius: 3px; background: var(--c-stone); }
.reviews__progress > span {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0);
  background: var(--c-cedar); will-change: transform;
}
.round-btn:disabled { opacity: .35; cursor: default; }
[data-review-deck][data-static] .reviews__viewport { cursor: default; }
.rating__bars dd > span { display: inline-block; width: var(--w, 0%); }

/* --------------------------------------------------------- ⚙ Map card -- */
.map-card { position: relative; border-radius: var(--radius); overflow: hidden; isolation: isolate; }
.map-card__map {
  position: relative; z-index: var(--z-map); isolation: isolate;  /* contains Leaflet z-indexes */
  width: 100%; height: clamp(320px, 52vh, 480px); background: var(--c-vellum); cursor: pointer;
}
.map-card__map .leaflet-control-container .leaflet-control { cursor: auto; }
.map-card__map[data-map-failed]::after {
  content: 'Map unavailable — use the link below to open Google Maps.';
  position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center;
}
.map-card__bar { display: block; text-align: center; text-decoration: none; padding: .9rem 1rem; font-weight: 600; }
.leaflet-container { font-family: var(--font-body); }
.leaflet-container a { color: inherit; }
/* Custom paw pin (divIcon) */
.cp-marker { background: none; border: 0; }
.cp-marker svg { overflow: visible; filter: drop-shadow(0 4px 6px rgb(0 0 0 / .25)); }
.cp-marker__pin { fill: var(--c-cedar); stroke: var(--c-white); stroke-width: 2; }
.cp-marker__paw { fill: var(--c-white); }

/* ------------------------------------------------------------ ⚙ Form -- */
.field { display: grid; gap: .35rem; min-width: 0; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; }
.field [aria-invalid="true"] { border-color: var(--c-error) !important; }
.field__error { margin: 0; min-height: 0; font-size: .85rem; color: var(--c-error); }
.field__error:empty { display: none; }
.form__status:empty { display: none; }
.form__status[data-state="success"] { color: var(--c-success); }
.form__status[data-state="error"] { color: var(--c-error); }
.form[data-state="sending"] .form__submit { opacity: .7; cursor: progress; }
.consent { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.consent input { flex: none; width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--c-moss); }

/* ------------------------------------------------- ⚙ Copy button state -- */
.copy-btn[data-state="done"] { color: var(--c-success); }

/* ------------------------------------------------------- ⚙ Scroll reveal -- */
/* Only hides content when JS is running, so no-JS visitors still see everything. */
.js [data-reveal] {
  opacity: 0; transform: translate3d(0, 12px, 0);
  transition: opacity .42s var(--ease-out), transform .42s var(--ease-out);
}
.js [data-reveal][data-revealed] { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; transform: none; }
}
