/* =========================================================================
   base.css — reset, typography, layout containers, shared primitives.
   Uses tokens only. No section-specific styling belongs in this file.
   ========================================================================= */

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

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

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-4);
  font-family: var(--font-head);
  font-weight: var(--fw-bold);
  line-height: var(--lh-head);
  letter-spacing: var(--ls-tight);
  color: var(--c-ink);
  /* Fraunces is variable: soften the terminals slightly and let the optical
     size axis follow the rendered size. This is what stops it reading as a
     stiff newspaper serif. */
  font-variation-settings: "SOFT" 30, "WONK" 1;
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p, ul, ol { margin: 0 0 var(--sp-4); }
ul, ol { padding-left: var(--sp-5); }
li { margin-bottom: var(--sp-2); }

a {
  color: var(--c-brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--c-brand) 35%, transparent);
  transition: color var(--dur) var(--ease),
              text-decoration-color var(--dur) var(--ease);
}
a:hover {
  color: var(--c-brand-dark);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: var(--focus-width) solid var(--c-focus);
  outline-offset: var(--focus-width);
}

small, .u-small { font-size: var(--fs-small); }

.u-eyebrow {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--c-accent-deep);
}

.u-lede {
  font-size: var(--fs-lede);
  line-height: 1.45;
  color: var(--c-ink-soft);
  text-wrap: pretty;
}

/* ---- Layout ------------------------------------------------------------ */

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

/* Keeps the same left edge as a full-width .container instead of centring
   its own narrower column — mixing the two gave the page two different left
   margins, which is what made it look unaligned rather than designed. */
.container--text > * { max-width: var(--container-text); }

/* …except where the block stands on its own rather than running alongside
   full-width grids: an accordion, a form panel, the closing band. Those
   have nothing to line up with, so hanging them on the left just leaves a
   third of the screen empty beside them. Centre the column instead.

   Doubled up on .container deliberately. Plenty of section rules set a
   margin SHORTHAND — .lesson-meta and .chord-set both do — which resets
   margin-inline to 0. At a single class those rules tie on specificity and
   win on source order, because sections.css loads after this file, so the
   block silently stayed left while everything around it centred. */
.container.container--center > * { margin-inline: auto; }

.section {
  padding-block: var(--section-y);
}

/* Anything an anchor or a TOC link can jump to has to clear the sticky
   header, or it lands underneath it and the visitor sees the wrong
   heading at the top of the screen. */
.section[id],
h2[id],
h3[id] { scroll-margin-top: calc(var(--sp-8) + var(--sp-4)); }

.section--alt  { background: var(--c-bg-alt); }
.section--warm { background: var(--c-bg-warm); }
.section--dark { background: var(--c-bg-dark); color: var(--c-on-dark); }
.section--dark h1,
.section--dark h2,
.section--dark h3 { color: var(--c-on-dark); }

.section__head {
  margin-bottom: var(--sp-6);
  max-width: var(--container-text);
}
.section__head > :last-child { margin-bottom: 0; }

/* Simple responsive grid used by most sections.
   Columns collapse to one on mobile, as set by the modifiers below. */
.grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) { .grid { gap: var(--sp-6); } }

@media (min-width: 480px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  .grid--split { grid-template-columns: 1fr 1fr; align-items: center; gap: var(--sp-7); }
}

/* ---- Buttons ----------------------------------------------------------- */

/* .btn is the live site's red money CTA (.btn-red on zagerguitar.com).
   .btn--secondary is the live site's blue WooCommerce button, which carries
   dark text, not white. Both sets of values come from tokens.css. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border: 0;
  border-radius: var(--radius-cta);
  background: var(--c-cta);
  color: var(--c-btn-text);
  font-family: var(--font-body);
  font-size: var(--btn-fs);
  font-weight: var(--btn-fw);
  line-height: var(--btn-lh);
  letter-spacing: 0.005em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-cta);
  transition: background var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

@media (hover: hover) {
  .btn:hover {
    background: var(--c-cta-dark);
    color: var(--c-btn-text);
    transform: translateY(-2px);
  }
}

.btn:active { transform: translateY(0); }

/* Secondary: outlined, so there is never any doubt which button is the
   primary action. Two solid buttons side by side is the fastest way to
   halve a click-through rate. */
.btn--secondary {
  background: transparent;
  color: var(--c-ink);
  box-shadow: inset 0 0 0 1.5px var(--c-line-strong);
}

@media (hover: hover) {
  .btn--secondary:hover {
    background: var(--c-bg-alt);
    color: var(--c-ink);
    box-shadow: inset 0 0 0 1.5px var(--c-brand);
  }
}

/* On a dark band the outline needs to come from the light side. */
.section--dark .btn--secondary {
  color: var(--c-on-dark);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.34);
}

@media (hover: hover) {
  .section--dark .btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--c-on-dark);
    box-shadow: inset 0 0 0 1.5px var(--c-on-dark);
  }
}

.btn--block { display: flex; width: 100%; }

@media (min-width: 480px) {
  .btn--block { display: inline-flex; width: auto; }
}

/* ---- Card -------------------------------------------------------------- */
/* Shared primitive. Used by related-content, product-row and collection-grid,
   so it lives here rather than in any one section block.
   Pattern: the media + kicker + title are one link, and everything after it
   sits outside that link — otherwise a screen reader reads the whole excerpt
   and price out as the link's name. */

.card {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

/* Lift on hover, but only where hover is a real pointer — on touch this
   would fire on tap and look like a glitch. */
@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
  }
}

.card__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* The card already clips its own corners, so the media must not round its. */
.card__media {
  border-radius: 0;
  margin-bottom: var(--sp-5);
  /* Product shots are on white. On the dark theme they cannot sit on the
     card surface — you get a glaring white rectangle inside a dark card.
     The panel keeps a light background of its own so the cut-out edge of
     the photograph never shows. */
  background: var(--c-media-bg);
  border-bottom: var(--border);
}

/* Guitar photography is roughly 2.3:1 — cropping it to fill a 16:9 box cuts
   the instrument in half. Contain it on the warm panel instead so the whole
   guitar is visible. This is a product grid; people need to see the product. */
.card__media img {
  object-fit: contain;
  padding: var(--sp-5) var(--sp-4);
  transition: transform 600ms var(--ease);
}

@media (hover: hover) {
  .card:hover .card__media img { transform: scale(1.04); }
}

/* For a photograph rather than a cut-out product shot. The light panel and
   the padding above exist so a guitar shot on white does not show its own
   edges; a lifestyle photo has no edges to hide, so it fills the frame. */
.card__media--cover { background: none; }
.card__media--cover img { object-fit: cover; padding: 0; }

.card__kicker {
  padding-inline: var(--sp-5);
  margin-bottom: var(--sp-2);
  color: var(--c-accent-deep);
}

.card__title {
  margin: 0;
  padding-inline: var(--sp-5);
  font-size: var(--fs-h3);
  line-height: var(--lh-head);
  letter-spacing: var(--ls-tight);
  color: var(--c-ink);
  text-wrap: balance;
}

.card__link:hover .card__title,
.card__link:focus-visible .card__title { color: var(--c-brand-dark); }

/* margin-top:auto pins the body to the bottom, so buttons and prices line up
   across a row of cards even when titles run to different lengths. */
.card__body {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
}

.card__excerpt {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--c-ink-soft);
}

/* ---- Media ------------------------------------------------------------- */

.ratio {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--c-bg-alt);
}
.ratio > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ratio--square  { aspect-ratio: 1 / 1; }
.ratio--portrait{ aspect-ratio: 3 / 4; }

/* ---- Scroll reveal ------------------------------------------------------
   Progressive enhancement only: elements are fully visible by default. Only
   once site.js has run and added .has-js to <html> do .reveal elements start
   hidden, waiting for site.js's IntersectionObserver to add .is-visible. So
   JS-off, or JS that errors before it runs, never hides real content. */

.has-js .reveal {
  opacity: 0;
  transform: translateY(var(--sp-4));
  transition: opacity var(--dur-reveal) var(--ease),
              transform var(--dur-reveal) var(--ease);
}

.has-js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Gentle stagger so a row of cards doesn't pop in as one flat block. */
.has-js .grid > .reveal:nth-child(2) { transition-delay: var(--stagger-1); }
.has-js .grid > .reveal:nth-child(3) { transition-delay: var(--stagger-2); }
.has-js .grid > .reveal:nth-child(4) { transition-delay: var(--stagger-3); }

/* ---- Visually hidden (screen readers only) -----------------------------
   The 1px box and -1px margin are the fixed visually-hidden idiom, not design
   values, so they stay as literals. Changing them breaks the technique. */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
