/* Shared, theme-agnostic components (loaded before every theme.css).
   Cross-cutting widgets that should look/behave the same in every theme:
   accessibility helpers, the contact form, lightbox and WhatsApp button.
   Everything consumes design tokens, so colours still vary per tenant.
   Visual identity (typography, layout, sections) lives in each theme.css. */

*, *::before, *::after { box-sizing: border-box; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--color-primary); color: var(--color-primary-contrast);
  padding: 0.6rem 1rem;
}
.skip-link:focus { left: 0; }

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

/* --- Contact form --------------------------------------------------------- */

.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.contact-form { max-width: 34rem; }
.form-field { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label { font-weight: 600; font-size: 0.95rem; }
.form-field input, .form-field textarea {
  font: inherit; color: inherit; padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); width: 100%;
}
.form-field textarea { resize: vertical; }
.form-hint { color: var(--color-muted); font-size: 0.9rem; }
.field-error { color: #b91c1c; font-size: 0.85rem; }
.form-error { color: #b91c1c; font-weight: 600; }
.contact-success { background: #dcfce7; color: #166534; padding: 1.25rem 1.5rem; border-radius: var(--radius); }
.contact-success h3 { margin: 0 0 0.25rem; }

/* --- WhatsApp floating button --------------------------------------------- */

.wa-float {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 30;
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: #25d366; color: #fff; text-decoration: none; font-weight: 600;
  padding: 0.7rem 1rem; border-radius: 999px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.wa-float:hover { filter: brightness(0.96); }
@media (max-width: 30rem) { .wa-float span { display: none; } .wa-float { padding: 0.8rem; } }

/* --- Lightbox (enhanced by site.js; thumbnails are plain links without JS) -- */

.lightbox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(15, 15, 15, 0.9); padding: 1.5rem; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox__img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); }
.lightbox__close {
  position: absolute; top: 1rem; right: 1rem; font-size: 2rem; line-height: 1;
  background: none; border: none; color: #fff; cursor: pointer;
}

/* --- Stock catalogue (theme-agnostic; themes may override) ----------------- */

.shop-filter ul { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.shop-filter a {
  display: inline-block; padding: 0.4rem 0.9rem; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--color-border); color: inherit; font-size: 0.95rem;
}
.shop-filter a[aria-current="true"] { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }
.shop-group { margin: 0 0 2rem; }
.shop-group__heading { margin: 0 0 1rem; }
.product-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
.product-card {
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); overflow: hidden; display: flex; flex-direction: column;
}
.product-card__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.product-card__body { padding: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.product-card__name { margin: 0; font-size: 1.05rem; }
.product-card__price { margin: 0; font-weight: 700; }
.product-card__desc { margin: 0; color: var(--color-muted); font-size: 0.95rem; }
.avail {
  align-self: flex-start; margin-top: 0.25rem; padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.avail--in_stock { background: #dcfce7; color: #166534; }
.avail--low { background: #fef3c7; color: #92400e; }
.avail--out { background: #f1f5f9; color: #475569; }
.shop-empty { color: var(--color-muted); }
.product-card__buy { margin-top: 0.6rem; }
.product-card__buy-btn { width: 100%; }

/* --- Next free times (section kind next_free) ------------------------------
   Live availability rows. Token-driven so every theme gets a readable version;
   a theme restyles it to suit (the barber theme makes it the chair ticket). */
.next-free { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.6rem; }
.next-free__row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.5rem 1rem;
  padding: 0.85rem 1rem; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.next-free__service { font-weight: 600; min-width: 0; }
.next-free__price { font-weight: 400; color: var(--color-muted); white-space: nowrap; }
.next-free__deposit { display: block; font-weight: 400; font-size: 0.875rem; color: var(--color-muted); }
.next-free__when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.next-free__day { color: var(--color-muted); }
.next-free__none { color: var(--color-muted); }
@media (max-width: 34rem) {
  .next-free__row { grid-template-columns: 1fr auto; }
  .next-free__book { grid-column: 1 / -1; justify-self: start; }
}

/* --- Style settings (docs/demo-factory-spec.md §B3.3) ---------------------
   Token-driven decoration every theme gets for free: base.html puts
   `divider--<name>` and `texture--<name>` on <body>; `--type-scale` comes from
   the :root tokens and themes multiply their display sizes by it. The
   defaults (`none`) add nothing. Pure CSS, no requests: motifs are inline SVG
   masks filled with the tenant's own colours. */

/* Dividers: a small motif centred in the gap between consecutive sections. */
:is(.divider--line, .divider--wave, .divider--zigzag, .divider--dots) main .section + .section { position: relative; }
:is(.divider--line, .divider--wave, .divider--zigzag, .divider--dots) main .section + .section::before {
  content: ""; position: absolute; left: 50%; top: calc(var(--space, 4rem) / -2);
  transform: translate(-50%, -50%); pointer-events: none;
  background: color-mix(in srgb, var(--color-primary) 55%, transparent);
  -webkit-mask: var(--divider-mask) center / contain no-repeat; mask: var(--divider-mask) center / contain no-repeat;
}
.divider--line main .section + .section::before { width: 4.5rem; height: 1px; --divider-mask: linear-gradient(#000, #000); }
.divider--wave main .section + .section::before {
  width: 7.5rem; height: 0.75rem;
  --divider-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12'%3E%3Cpath d='M0 6q7.5-6 15 0t15 0 15 0 15 0 15 0 15 0 15 0 15 0' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E");
}
.divider--zigzag main .section + .section::before {
  width: 7.5rem; height: 0.75rem;
  --divider-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12'%3E%3Cpath d='M0 10l10-8 10 8 10-8 10 8 10-8 10 8 10-8 10 8 10-8 10 8 10-8 10 8' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='miter'/%3E%3C/svg%3E");
}
.divider--dots main .section + .section::before {
  width: 3.25rem; height: 0.5rem;
  --divider-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 8'%3E%3Ccircle cx='4' cy='4' r='4'/%3E%3Ccircle cx='26' cy='4' r='4'/%3E%3Ccircle cx='48' cy='4' r='4'/%3E%3C/svg%3E");
}

/* Type scale: phones keep each theme's own sizes, already tuned to 390px, so
   a long word in a "bold" headline can never overflow. Same specificity as
   the inline :root block in base.html, and later, so this wins. */
@media (max-width: 40rem) { :root { --type-scale: 1; } }

/* Textures: a faint fixed layer over the page background, behind content. */
:is(.texture--grain, .texture--dots, .texture--lines)::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
}
.texture--grain::before {
  opacity: 0.09; mix-blend-mode: multiply;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.texture--dots::before {
  background: var(--color-text); opacity: 0.07;
  -webkit-mask: radial-gradient(circle, #000 1px, transparent 1.6px) 0 0 / 1.25rem 1.25rem;
  mask: radial-gradient(circle, #000 1px, transparent 1.6px) 0 0 / 1.25rem 1.25rem;
}
.texture--lines::before {
  background: var(--color-text); opacity: 0.05;
  -webkit-mask: repeating-linear-gradient(-45deg, #000 0 1px, transparent 1px 0.75rem);
  mask: repeating-linear-gradient(-45deg, #000 0 1px, transparent 1px 0.75rem);
}

/* Mobile nav toggle is hidden until site.js reveals it. Each theme shows it
   below its breakpoint and collapses its nav only under `.js` (base.html). */
.nav-toggle { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* --- Two-speed site (signature sections item 2) ----------------------------
   The hero's "right now" line and its buttons, plus the closure banner. Token
   driven; signature themes restyle them. */
.hero-now { margin: 1rem 0 0; font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.hero-actions:empty { display: none; }
.closure-banner {
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
  padding: 0.7rem 0; font-weight: 600;
}
.closure-banner p { margin: 0; }

/* --- This week's free times (section kind week_slots) ----------------------
   Days stack on a phone and sit in a 7-column week on wide screens. Taken
   times are struck through; free ones are links. Wellness restyles it as the
   trainer's whiteboard. */
.week-slots__intro { max-width: 40rem; }
.week-slots__deposit { color: var(--color-muted); font-size: 0.95rem; }
.week-slots { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.week-slots__day {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); align-items: baseline; gap: 0.5rem 1rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--color-border);
}
.week-slots__date { margin: 0; font-size: 1rem; }
.week-slots__date span { color: var(--color-muted); font-weight: 400; }
.week-slots__times { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.week-slots__free, .week-slots__taken {
  display: inline-block; min-width: 4rem; padding: 0.45rem 0.6rem; text-align: center;
  font-variant-numeric: tabular-nums; border-radius: var(--radius);
}
.week-slots__free { border: 2px solid var(--color-primary); color: var(--color-primary); font-weight: 600; text-decoration: none; }
.week-slots__free:hover, .week-slots__free:focus-visible { background: var(--color-primary); color: var(--color-surface); }
.week-slots__taken { color: var(--color-muted); text-decoration-thickness: 2px; }
.week-slots__rest { margin: 0; color: var(--color-muted); font-style: italic; }
.week-slots__key { margin-top: 1rem; font-size: 0.9rem; color: var(--color-muted); }
.week-slots__key-free { color: var(--color-primary); font-weight: 600; }
/* A long day (an early-till-late trainer) packs its times tighter. */
.week-slots__day--busy .week-slots__times { gap: 0.35rem; }
.week-slots__day--busy :is(.week-slots__free, .week-slots__taken) { min-width: 3.5rem; padding: 0.3rem 0.4rem; }
@media (min-width: 60rem) {
  .week-slots { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1rem; }
  .week-slots__day--busy .week-slots__times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-slots__day { grid-template-columns: 1fr; align-content: start; border-bottom: 0; border-top: 2px solid var(--color-text); }
  .week-slots__times { flex-direction: column; }
}

/* menu_list items that name a booking service, and the section's note
   (signature sections item 7; the salon draws them as a shade ring). */
.menu-item__book { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--color-muted); }
.menu-note { margin-top: 1.5rem; padding: 1rem 1.15rem; border: 1px solid var(--color-border); border-radius: var(--radius); }
.menu-note h3 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.menu-note p { margin: 0; }
