/* =============================================================
   Juicy Braidz — landing page
   Editorial-luxe aesthetic. Mobile-first.
   Modern CSS only: custom properties, nesting, grid, color-mix.
   ============================================================= */

/* Self-hosted fonts — Latin subset of the same files Google Fonts serves.
   font-display: swap shows fallback text immediately so LCP fires on first paint.
   Variable axes (opsz, SOFT, WONK on Fraunces) are baked into the woff2 file
   and stay accessible via font-variation-settings on individual elements. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/assets/fonts/dmsans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Color — warm cream, espresso, terracotta */
  --cream: #f5ebd9;
  --cream-deep: #ecdfc7;
  --espresso: #1f1612;
  --espresso-soft: #2e221c;
  --terracotta: #c26644;       /* decorative only — 3.4:1 on cream, OK for large text & icons */
  /* WCAG 1.4.3: 5.4:1 on cream, 5.1:1 on cream-deep card mix, 4.9:1 on pure cream-deep
     (Lighthouse flagged earlier #a4502f at 4.45:1 on the service-card hover bg) */
  --terracotta-deep: #9c4423;
  --line: color-mix(in srgb, var(--espresso) 14%, transparent);
  /* WCAG 1.4.3 Contrast (Minimum): bumped from 60% to 70% so muted text reaches ~5.9:1 on cream */
  --muted: color-mix(in srgb, var(--espresso) 70%, transparent);
  /* WCAG 2.4.11 Focus Not Obscured: sticky header height; used by html scroll-padding-top */
  --header-offset: 5rem;

  /* Type */
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;

  /* Spacing scale */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4.5rem;
  --space-7: 7rem;
  --space-8: 10rem;

  /* Layout */
  --container: 76rem;
  --container-tight: 56rem;
  --radius: 2px;
  --radius-lg: 6px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light dark;
}

/* ============ Dark mode ============
   Applied when EITHER:
   - User has explicitly toggled to dark (html[data-theme="dark"]), OR
   - OS prefers dark AND user has not toggled to light (no [data-theme="light"]).
   Light is the default in :root and stays default if neither matches.
   Same variable names so every existing rule adapts automatically; terracotta
   accents brighten to keep ≥4.5:1 contrast on the new dark surfaces. */

:root[data-theme="dark"] {
  --cream: #1a120e;
  --cream-deep: #251a14;
  --espresso: #f5ebd9;
  --espresso-soft: #d9cdb5;
  --terracotta: #e57a52;
  --terracotta-deep: #f29464;
  --line: color-mix(in srgb, var(--espresso) 18%, transparent);
  --muted: color-mix(in srgb, var(--espresso) 65%, transparent);
}
:root[data-theme="dark"] .gallery img,
:root[data-theme="dark"] .service-image img,
:root[data-theme="dark"] .about-photo img {
  filter: brightness(0.92);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #1a120e;
    --cream-deep: #251a14;
    --espresso: #f5ebd9;
    --espresso-soft: #d9cdb5;
    --terracotta: #e57a52;
    --terracotta-deep: #f29464;
    --line: color-mix(in srgb, var(--espresso) 18%, transparent);
    --muted: color-mix(in srgb, var(--espresso) 65%, transparent);
  }
  :root:not([data-theme="light"]) .gallery img,
  :root:not([data-theme="light"]) .service-image img,
  :root:not([data-theme="light"]) .about-photo img {
    filter: brightness(0.92);
  }
}

/* ============ Theme toggle button ============ */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--espresso);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.theme-toggle:hover {
  background: color-mix(in srgb, var(--espresso) 8%, transparent);
  border-color: var(--espresso-soft);
}
/* WCAG 2.4.7 Focus Visible — same treatment as other focusable elements */
.theme-toggle:focus-visible {
  outline: 2px solid var(--terracotta-deep);
  outline-offset: 3px;
}
.theme-toggle .theme-icon { width: 18px; height: 18px; }
/* Show moon in light mode (clicking goes dark); sun in dark (clicking goes light) */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
/* WCAG 2.4.11 Focus Not Obscured: keep anchor targets clear of the sticky header */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: var(--header-offset); }
body {
  background: var(--cream);
  color: var(--espresso);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, picture, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input, textarea { font: inherit; }
ul, ol { padding: 0; list-style: none; }

/* WCAG 2.4.7 Focus Visible / 2.4.11 Focus Not Obscured / 2.4.13 Focus Appearance:
   Global focus ring for all interactive elements that aren't styled buttons.
   2px solid outline + 3px offset gives ≥3:1 against adjacent cream/espresso surfaces. */
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--terracotta-deep);
  outline-offset: 3px;
  border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ Utilities ============ */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-3);
}
@media (min-width: 56rem) {
  .container { padding-inline: var(--space-5); }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--espresso);
  color: var(--cream);
  padding: var(--space-2) var(--space-3);
  z-index: 100;

  &:focus {
    left: var(--space-2);
    top: var(--space-2);
  }
}

/* ============ Typography ============ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variation-settings: "opsz" 100, "SOFT" 30, "WONK" 0;
  text-wrap: balance;
}
h1 {
  font-size: clamp(2.75rem, 8vw, 5.5rem);
  font-weight: 350;
}
h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 350;
}
h3 {
  font-size: clamp(1.25rem, 2vw, 1.625rem);
  line-height: 1.2;
}
em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
  color: var(--terracotta);
}
p { text-wrap: pretty; }

.eyebrow,
.section-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label {
  display: inline-block;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--line);
}

.lede {
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 300;
  line-height: 1.5;
  max-width: 38ch;
  font-variation-settings: "opsz" 24, "SOFT" 40;
}

.section-intro {
  max-width: 52ch;
  margin-block: var(--space-3) var(--space-5);
  color: var(--espresso-soft);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
  cursor: pointer;

  &:focus-visible {
    outline: 2px solid var(--terracotta);
    outline-offset: 3px;
  }
}
.btn-lg {
  padding: 1rem 1.75rem;
  font-size: 1rem;
}
.btn-primary {
  background: var(--espresso);
  color: var(--cream);

  &:hover {
    background: var(--terracotta-deep);
    transform: translateY(-1px);
  }
}
.btn-ghost {
  background: transparent;
  color: var(--espresso);
  border-color: var(--espresso);

  &:hover {
    background: var(--espresso);
    color: var(--cream);
  }
}

/* ============ Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-2);
}
.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  line-height: 1.1;
}
.brand-mark {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 400;
  font-variation-settings: "opsz" 14, "SOFT" 30;
}
.brand-tag {
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.nav-list {
  display: none;
}
@media (min-width: 48rem) {
  .nav-list {
    display: flex;
    gap: var(--space-4);
  }
  .nav-list a {
    text-decoration: none;
    font-size: 0.9375rem;
    color: var(--espresso-soft);
    position: relative;
    transition: color 0.2s var(--ease);
    /* WCAG 2.5.8 Target Size (Minimum): ≥24px height by adding vertical padding */
    padding-block: 0.5rem;
    display: inline-block;

    &::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: -4px;
      width: 100%;
      height: 1px;
      background: currentColor;
      transform: scaleX(0);
      transform-origin: right;
      transition: transform 0.3s var(--ease);
    }
    /* WCAG 1.4.3: nav links are 15px regular — terracotta fails 4.5:1; use deep.
       WCAG 1.4.1: hover state also adds underline animation, not color-only */
    &:hover {
      color: var(--terracotta-deep);

      &::after {
        transform: scaleX(1);
        transform-origin: left;
      }
    }
  }
}

.header-cta {
  padding: 0.5rem 1.125rem;
  font-size: 0.875rem;
}

/* ============ Hero ============ */
.hero {
  position: relative;
  padding-top: var(--space-5);
  padding-bottom: var(--space-6);
  overflow: hidden;
}
.hero-inner {
  position: relative;
  z-index: 2;
}
.hero .eyebrow {
  margin-bottom: var(--space-3);
}
.hero h1 {
  max-width: 18ch;
  margin-bottom: var(--space-3);
}
.hero .lede {
  margin-bottom: var(--space-4);
}
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  font-size: 0.9rem;
  color: var(--espresso-soft);
}
.hero-meta span {
  color: var(--terracotta);
  margin-right: 0.4em;
}
.hero-figure {
  position: relative;
  margin-top: var(--space-5);
  margin-inline: calc(-1 * var(--space-3));

  & img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: var(--radius-lg);
  }
}

@media (min-width: 64rem) {
  .hero {
    padding-top: var(--space-7);
    padding-bottom: var(--space-7);
  }
  .hero-inner {
    max-width: 62%;
  }
  .hero-figure {
    position: absolute;
    top: var(--space-7);
    right: var(--space-5);
    width: 32%;
    max-width: 26rem;
    margin: 0;

    & img {
      aspect-ratio: 3 / 4;
    }
  }
}

/* ============ Sections — shared spacing ============ */
section:not(.hero) {
  padding-block: var(--space-6);
  border-top: 1px solid var(--line);
}
@media (min-width: 56rem) {
  section:not(.hero) {
    padding-block: var(--space-7);
  }
}

/* ============ About ============ */
.about-grid {
  display: grid;
  gap: var(--space-5);
}
@media (min-width: 56rem) {
  .about-grid {
    grid-template-columns: 5fr 7fr;
    align-items: center;
    gap: var(--space-6);
  }
}
.about-photo img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius-lg);
}
.about-copy h2 {
  margin-bottom: var(--space-3);
  max-width: 14ch;
}
.about-copy p + p {
  margin-top: var(--space-2);
}

/* ============ Services ============ */
.services-list {
  display: grid;
  gap: var(--space-3);
}
@media (min-width: 56rem) {
  .services-list {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
  }
}
.service {
  background: color-mix(in srgb, var(--cream-deep) 60%, var(--cream));
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);

  &:hover {
    transform: translateY(-3px);
    background: var(--cream-deep);
  }
}
.service-image {
  position: relative;
  background: var(--cream-deep);
}
.service-image img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.service-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  flex: 1;
}
.service-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-2);
}
.service-head h3 {
  font-size: clamp(1.375rem, 2vw, 1.75rem);
  font-weight: 400;
}
.service-price {
  font-family: var(--font-display);
  font-size: 1.125rem;
  /* WCAG 1.4.3: 18px regular is not "large text" (needs 24px or 18.66px bold); use deep terracotta for 4.7:1 */
  color: var(--terracotta-deep);
  white-space: nowrap;
}
.service-desc {
  color: var(--espresso-soft);
}
.service-meta {
  margin-top: var(--space-2);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.service-cta {
  /* margin-top: auto pushes the CTA to the bottom of the card so buttons align
     across rows even when descriptions differ in length. */
  margin-top: auto;
  align-self: stretch;
  text-align: center;
}
/* Gap above the CTA — applied via the meta's bottom margin so it doesn't fight margin-top: auto */
.service-meta {
  margin-bottom: var(--space-3);
}

/* ============ Gallery ============ */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
@media (min-width: 56rem) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 18rem;
    gap: var(--space-3);
  }
}
.gallery-item {
  overflow: hidden;
  border-radius: var(--radius-lg);

  & img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1;
    transition: transform 0.6s var(--ease);
  }
  &:hover img {
    transform: scale(1.04);
  }
}
@media (min-width: 56rem) {
  .gallery-item img {
    aspect-ratio: auto;
  }
  .gallery-item--tall {
    grid-row: span 2;
  }
}

/* ============ Process ============ */
.process-steps {
  display: grid;
  gap: var(--space-4);
  counter-reset: step;
}
@media (min-width: 56rem) {
  .process-steps {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5) var(--space-6);
  }
}
.process-steps li {
  position: relative;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
.step-num {
  position: absolute;
  top: -1px;
  right: 0;
  font-family: var(--font-display);
  font-size: 0.875rem;
  /* WCAG 1.4.3: small text needs 4.5:1 — terracotta-deep instead of terracotta */
  color: var(--terracotta-deep);
  padding: var(--space-1) var(--space-2);
  background: var(--cream);
  letter-spacing: 0.1em;
}
.process-steps h3 {
  font-size: 1.5rem;
  margin-bottom: var(--space-2);
}
.process-steps p {
  color: var(--espresso-soft);
  max-width: 42ch;
}

/* ============ FAQ ============ */
.faq-list {
  display: grid;
  gap: 0;
  max-width: 50rem;
  margin: 0 auto;
}
.faq-list details {
  border-top: 1px solid var(--line);
  padding: var(--space-3) 0;

  &:last-child {
    border-bottom: 1px solid var(--line);
  }
  /* WCAG 1.4.3: summary text is 18-22px regular — not large text, use deep terracotta.
     WCAG 1.4.1: open state is not signalled by color alone; the "+" icon also rotates to "×". */
  &[open] summary {
    color: var(--terracotta-deep);
  }
}
.faq-list summary {
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 400;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  transition: color 0.2s var(--ease);

  &::-webkit-details-marker { display: none; }
  &::after {
    content: "+";
    font-family: var(--font-body);
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s var(--ease);
    flex-shrink: 0;
  }
}
.faq-list details[open] summary::after {
  transform: rotate(45deg);
}
.faq-list details p {
  margin-top: var(--space-2);
  color: var(--espresso-soft);
  max-width: 60ch;
}

/* ============ Visit ============ */
.visit-grid {
  display: grid;
  gap: var(--space-5);
}
@media (min-width: 56rem) {
  .visit-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: start;
  }
}
.visit h2 { margin-bottom: var(--space-4); }
.visit address {
  font-style: normal;
  margin-bottom: var(--space-3);
}
.visit .hours {
  margin-bottom: var(--space-3);
  color: var(--espresso-soft);
}
.visit a {
  /* WCAG 1.4.3: contact links are normal body size — terracotta-deep gives 4.7:1.
     WCAG 1.4.1: link state isn't color-only; underline is preserved via border-bottom. */
  color: var(--terracotta-deep);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.visit-cta {
  padding: var(--space-5);
  background: var(--espresso);
  color: var(--cream);
  border-radius: var(--radius-lg);
}
.visit-cta h3 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: var(--space-2);
}
.visit-cta p {
  margin-bottom: var(--space-4);
  color: color-mix(in srgb, var(--cream) 80%, transparent);
}
.visit-cta .btn-primary {
  /* WCAG 1.4.3: previously used --terracotta (#c26644) which gave only 3.4:1 with cream text.
     --terracotta-deep gives 5.4:1 — passes for normal-size body text. */
  background: var(--terracotta-deep);
  color: var(--cream);

  &:hover {
    background: var(--cream);
    color: var(--espresso);
  }
}
.visit-cta-fallback {
  margin-top: var(--space-3);
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--cream) 80%, transparent);
}
/* WCAG 1.4.3: on espresso bg, terracotta-deep only reaches ~3:1 — use cream (≈13:1)
   for the fallback contact links inside the dark CTA card */
.visit-cta-fallback a {
  color: var(--cream);
  border-bottom-color: var(--terracotta);

  &:hover {
    color: var(--terracotta);
  }
  /* WCAG 1.4.11 / 2.4.13: on the dark espresso card, --terracotta-deep (now darker) only
     reaches ~2.4:1 against the bg; override the global focus ring to cream for ≥13:1. */
  &:focus-visible {
    outline-color: var(--cream);
  }
}

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: var(--space-5);
  background: var(--cream-deep);
}
.footer-inner {
  display: grid;
  gap: var(--space-3);
}
@media (min-width: 56rem) {
  .footer-inner {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
}
.footer-brand {
  line-height: 1.2;
}
.footer-nav,
.social {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.footer-nav a,
.social a {
  text-decoration: none;
  font-size: 0.9rem;
  /* WCAG 2.5.8 Target Size (Minimum): pad to ≥24px hit area on small text links */
  display: inline-block;
  padding-block: 0.375rem;

  /* WCAG 1.4.3: hover state needs to remain readable — terracotta-deep at 4.7:1 */
  &:hover { color: var(--terracotta-deep); }
}
.copy {
  grid-column: 1 / -1;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ============ Page-load reveal (subtle, optional) ============ */
@media (prefers-reduced-motion: no-preference) {
  .hero h1,
  .hero .lede,
  .hero-ctas,
  .hero-meta,
  .hero-figure {
    animation: fade-up 0.8s var(--ease) backwards;
  }
  .hero h1 { animation-delay: 0.05s; }
  .hero .lede { animation-delay: 0.15s; }
  .hero-ctas { animation-delay: 0.25s; }
  .hero-meta { animation-delay: 0.35s; }
  .hero-figure { animation-delay: 0.2s; }

  @keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
