/* ==========================================================================
   TruthSA Hair — shared page chrome.
   Reset, layout, type, buttons, header, footer, form controls, photo
   placeholders and the product card. Page sections live in site.css.
   Every value comes from tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset and base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

/* Phones: no font inflation in landscape, no grey flash on tap. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--cw-bg);
  color: var(--cw-text);
  font-family: var(--cw-font-body);
  font-size: var(--cw-size-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:hover { opacity: 0.8; }

img { display: block; max-width: 100%; }

/* hidden means hidden, even on elements given a display (buttons, flex rows). */
[hidden] { display: none !important; }

h1, h2, h3, p, dl, dd, figure { margin: 0; }

::selection { background: var(--cw-tone-mauve); }

:focus-visible { outline: 2px solid var(--cw-accent); outline-offset: 3px; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 12px 18px; background: var(--cw-ink); color: var(--cw-text-on-dark);
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------------------
   2. Layout and type primitives
   -------------------------------------------------------------------------- */
.shell {
  max-width: var(--cw-max-width);
  margin: 0 auto;
  padding-left: var(--cw-gutter);
  padding-right: var(--cw-gutter);
}
.shell--narrow { max-width: var(--cw-max-width-narrow); }

.display {
  font-family: var(--cw-font-display);
  font-weight: 600;
  letter-spacing: var(--cw-tracking-display);
  text-wrap: balance;
}

.eyebrow {
  font-size: var(--cw-size-label);
  font-weight: 600;
  letter-spacing: var(--cw-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--cw-accent);
}

.label-caps {
  font-size: var(--cw-size-label);
  font-weight: 600;
  letter-spacing: var(--cw-tracking-label);
  text-transform: uppercase;
  color: var(--cw-text-muted);
}

.muted { color: var(--cw-text-muted); }

.section-title {
  font-family: var(--cw-font-display);
  font-weight: 600;
  font-size: var(--cw-size-h2);
  line-height: 1.1;
  letter-spacing: var(--cw-tracking-h2);
}

.page-title {
  font-family: var(--cw-font-display);
  font-weight: 600;
  font-size: var(--cw-size-page-title);
  line-height: 1.05;
  letter-spacing: var(--cw-tracking-display);
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--cw-touch);
  font-weight: 600;
  color: var(--cw-text);
  text-decoration: underline;
  text-underline-offset: 5px;
}

/* --------------------------------------------------------------------------
   3. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 32px;
  border: 0;
  border-radius: var(--cw-radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--cw-transition);
}
.btn:hover { opacity: 1; }
.btn--primary { background: var(--cw-accent); color: var(--cw-text-on-dark); }
.btn--primary:hover { background: var(--cw-accent-hover); }
.btn--dark { background: var(--cw-ink); color: var(--cw-text-on-dark); min-height: 48px; padding: 0 24px; }
.btn--dark:hover { background: var(--cw-ink-hover); }
.btn--outline {
  min-height: var(--cw-field-height);
  padding: 0 20px;
  border: 1px solid var(--cw-ink);
  background: transparent;
  color: var(--cw-text);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn--block { width: 100%; }
.btn--lg { min-height: 58px; font-size: 17px; }
.btn--xl { min-height: 60px; font-size: 18px; }
/* A label that wraps on a narrow screen stays readable inside the button. */
.btn { padding-top: 8px; padding-bottom: 8px; line-height: 1.25; text-align: center; }

/* --------------------------------------------------------------------------
   4. Announcement bar and header
   -------------------------------------------------------------------------- */
.announcement {
  background: var(--cw-ink);
  color: var(--cw-text-on-dark);
  font-size: var(--cw-size-label);
  line-height: 20px;
  padding: 10px 24px;
  text-align: center;
}

/* The header stays reachable: it slides away while scrolling down and comes
   back on the way up (site.js sets data-hidden). */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--cw-line);
  background: var(--cw-bg);
  transition: transform 220ms ease;
}
.site-header[data-hidden="true"] { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) { .site-header { transition: none; } }

.site-header__inner {
  min-height: 84px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
}

.logo {
  font-family: var(--cw-font-display);
  font-size: var(--cw-size-logo);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--cw-text);
  text-decoration: none;
}

.main-nav { display: flex; flex-wrap: wrap; gap: 0 8px; }

.main-nav__link {
  display: flex;
  align-items: center;
  min-height: var(--cw-touch);
  padding: 0 14px;
  font-size: var(--cw-size-small);
  font-weight: 500;
  color: var(--cw-text);
  text-decoration: none;
}
.main-nav__link[aria-current="page"] {
  font-weight: 600;
  color: var(--cw-accent);
  text-decoration: underline;
  text-underline-offset: 8px;
}

.header-tools { display: flex; gap: 4px; }

.icon-btn {
  min-width: var(--cw-touch);
  height: var(--cw-touch);
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--cw-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn__count { font-size: var(--cw-size-meta); font-weight: 600; }

/* Search: a disclosure under the header. Works without JS through :target. */
.search-panel { display: none; border-top: 1px solid var(--cw-line); background: var(--cw-bg); }
.search-panel:target,
.search-panel[data-open="true"] { display: block; }
.search-panel__form { display: flex; gap: 8px; padding-top: 16px; padding-bottom: 16px; }
.search-panel__form .field__input { flex: 1; }

/* Phones: logo and tools share the top row; the categories scroll sideways
   underneath, fading out at the edge so it's clear there are more. */
@media (max-width: 760px) {
  .site-header__inner { min-height: 0; padding-top: 6px; gap: 0 8px; }
  .logo { font-size: 23px; }
  .header-tools { gap: 0; margin-right: -8px; }
  .header-tools .icon-btn { min-width: 40px; padding: 0 8px; }
  .main-nav {
    order: 3;
    flex: 0 0 auto;
    width: calc(100% + 2 * var(--cw-gutter));
    margin: 0 calc(-1 * var(--cw-gutter));
    padding: 0 28px 0 calc(var(--cw-gutter) - 14px);
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav__link { white-space: nowrap; }
  .search-panel__form .btn { padding-left: 18px; padding-right: 18px; }
}

/* --------------------------------------------------------------------------
   5. Footer
   -------------------------------------------------------------------------- */
.site-footer { background: var(--cw-band); border-top: 1px solid var(--cw-line); }

.site-footer__grid {
  padding-top: 64px;
  padding-bottom: 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 40px;
}

.site-footer__brand { display: flex; flex-direction: column; gap: 12px; }
.site-footer__logo { font-family: var(--cw-font-display); font-size: 26px; font-weight: 600; }
.site-footer__tagline { color: var(--cw-text-muted); font-size: var(--cw-size-small); max-width: 260px; }

.site-footer__col { display: flex; flex-direction: column; gap: 2px; }
.site-footer__col .label-caps { margin-bottom: 6px; }
.site-footer__link {
  display: flex;
  align-items: center;
  min-height: 36px;
  color: var(--cw-text);
  text-decoration: none;
}
.site-footer__accepts { font-size: var(--cw-size-small); }

.site-footer__legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 24px;
  font-size: 13px;
}
.site-footer__legal-links a { display: inline-flex; align-items: center; min-height: 32px; color: var(--cw-text-muted); }
.site-footer__legal-links a:hover { color: var(--cw-text); }
.site-footer__legal {
  padding-top: 8px;
  padding-bottom: 40px;
  color: var(--cw-text-muted);
  font-size: var(--cw-size-label);
}

/* Phones: shop and help links side by side, so the footer is half as long. */
@media (max-width: 640px) {
  .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 20px; padding-top: 48px; padding-bottom: 32px; }
  .site-footer__brand,
  .site-footer__col:last-child { grid-column: 1 / -1; }
  .site-footer__tagline { max-width: none; }
  .site-footer__link { min-height: 40px; }
  .site-footer__legal-links { gap: 0 20px; padding-top: 16px; border-top: 1px solid var(--cw-line-panel); }
}

/* --------------------------------------------------------------------------
   6. Messages
   -------------------------------------------------------------------------- */
.flash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 14px 18px;
  border-radius: var(--cw-radius-md);
  background: var(--cw-band);
  font-size: var(--cw-size-small);
}
.flash--error { background: #f8e3e8; color: var(--cw-error); font-weight: 500; }
.flash-region { padding-top: 24px; }

/* --------------------------------------------------------------------------
   7. Photos and placeholders
   A hatched tone with a caption stands in until a real photo is uploaded.
   -------------------------------------------------------------------------- */
.photo {
  position: relative;
  border-radius: var(--cw-radius-md);
  overflow: hidden;
  background-color: var(--tone, var(--cw-tone-orchid));
}
.photo--placeholder {
  background-image: var(--cw-hatch);
  display: flex;
  align-items: flex-end;
  padding: 12px;
}
.photo--portrait { aspect-ratio: 4 / 5; }
.photo img { width: 100%; height: 100%; object-fit: cover; }

.photo__tag {
  font-size: var(--cw-size-tag-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cw-tag-text);
  background: var(--cw-bg);
  padding: 5px 8px;
  border-radius: var(--cw-radius-sm);
}
.photo--lg.photo--placeholder { padding: 16px; }
.photo--lg .photo__tag { font-size: var(--cw-size-tag); padding: 6px 10px; }

/* --------------------------------------------------------------------------
   8. Product card and grid
   -------------------------------------------------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 40px 24px;
}
.product-grid--home { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 24px; }

.product-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--cw-text);
  text-decoration: none;
}
.product-card:hover { opacity: 1; }
.product-card:hover .product-card__name { text-decoration: underline; text-underline-offset: 4px; }
.product-card__body { display: flex; flex-direction: column; gap: 2px; }
.product-card__name { font-weight: 600; font-size: var(--cw-size-card-title); line-height: 1.3; }
.product-card__meta { font-size: var(--cw-size-meta); color: var(--cw-text-muted); }
.product-card__price { font-size: var(--cw-size-body); font-weight: 600; margin-top: 4px; }

/* --------------------------------------------------------------------------
   9. Form controls
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--cw-size-meta); font-weight: 500; }

.field__input {
  min-height: var(--cw-field-height);
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--cw-line-strong);
  border-radius: var(--cw-radius);
  background: var(--cw-white);
  color: var(--cw-text);
  font: inherit;
  font-size: var(--cw-size-body);
  font-weight: 400;
}
.field__input:focus-visible { outline: 2px solid var(--cw-accent); outline-offset: 1px; border-color: var(--cw-accent); }
.field__input[aria-invalid="true"] { border-color: var(--cw-error); }
.field__error { color: var(--cw-error); font-size: var(--cw-size-label); font-weight: 500; }

select.field__input {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2322102B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.field-grid { display: grid; gap: 16px; }
.field-grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.field-grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  cursor: pointer;
}
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--cw-accent); flex: none; }
.check__swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--cw-line);
  background: var(--swatch);
  flex: none;
}

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field--error .field__input { border-color: var(--cw-error); }

/* Language list in the header: the current flag and code, opening onto every language. */
.lang-menu { position: relative; }
.lang-menu__toggle { list-style: none; font-size: var(--cw-size-label); font-weight: 600; letter-spacing: 0.04em; }
.lang-menu__toggle::-webkit-details-marker { display: none; }
.lang-menu__toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.lang-menu[open] .lang-menu__toggle::after { transform: translateY(2px) rotate(-135deg); }
.lang-menu__list {
  position: absolute;
  max-width: calc(100vw - 2 * var(--cw-gutter));
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 104px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--cw-bg);
  border: 1px solid var(--cw-line);
  border-radius: var(--cw-radius-lg);
  box-shadow: 0 12px 32px rgb(34 16 43 / 0.12);
}
.lang-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--cw-radius-md);
  color: var(--cw-text);
  font-size: var(--cw-size-small);
  text-decoration: none;
}
a.lang-menu__item:hover { background: var(--cw-band); }
.lang-menu__item.is-current { font-weight: 600; background: var(--cw-band); }
.lang-menu__code { font-weight: 600; letter-spacing: 0.04em; }
.lang-menu__item .lang-menu__code { min-width: 2ch; }
.icon-btn .flag, .flag { width: 20px; height: 14px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgb(34 16 43 / 0.12); }
