/* ============================================================
   Kgosi Mabowa — portfolio
   Tokens first; components reference only semantic tokens.
   ============================================================ */

:root {
  /* --- previous palette, kept for reference ---
     --cobalt:   oklch(0.47 0.25 264);   ≈ #2532e4
     --cobalt-deep: oklch(0.38 0.22 266);
     --chalk:    oklch(0.97 0.02 95);    ≈ #fffbef
     --ink:      oklch(0.22 0.05 280);   ≈ #1a1a2e
     --marigold: oklch(0.85 0.17 85);    ≈ #ffc93c
     --coral:    oklch(0.70 0.19 35);
     --mint:     oklch(0.87 0.12 165);
  ------------------------------------------------ */

  /* primitives (OKLCH) — earthly palette */
  --cream:      oklch(0.96 0.02 85);    /* ≈ #f7f1e6 — the field */
  --umber:      oklch(0.34 0.045 62);   /* ≈ #4a3b2c — type on cream */
  --umber-deep: oklch(0.26 0.04 60);    /* ≈ #33291d — dark section */
  --brick:      oklch(0.55 0.19 30);    /* ≈ #c0402a — the loud accent */
  --moss:       oklch(0.52 0.08 145);   /* ≈ #5c7052 — earthly green */
  --chalk:      oklch(0.97 0.015 85);   /* near-white type on dark/red */

  /* semantic */
  --color-bg: var(--cream);
  --color-fg: var(--umber);
  --color-accent: var(--brick);
  --color-accent-fg: var(--chalk);
  --color-muted: oklch(0.50 0.03 62);
  --color-focus: var(--brick);

  /* type scale — fluid, ratio ~1.333 */
  --step-0: clamp(1rem, 0.92rem + 0.4vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.1rem + 0.75vw, 1.625rem);
  --step-2: clamp(1.6rem, 1.3rem + 1.5vw, 2.4rem);
  --step-3: clamp(2.2rem, 1.6rem + 3vw, 3.75rem);
  --step-giant: clamp(3.5rem, 0.5rem + 14.5vw, 15rem);

  /* space — 8pt scale */
  --space-1: 8px;  --space-2: 16px; --space-3: 24px;
  --space-4: 32px; --space-5: 48px; --space-6: 64px;
  --space-7: 96px; --space-8: 128px;

  --radius-md: 12px;
  --radius-pill: 999px;

  --font-display: "Clash Display", "Arial Black", sans-serif;
  --font-body: "General Sans", -apple-system, "Segoe UI", Roboto, sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: clamp(16px, 5vw, 64px);
}

/* ---------- a11y ---------- */
.skip-link {
  position: absolute;
  top: -100px; left: var(--space-2);
  z-index: 100;
  padding: var(--space-1) var(--space-2);
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus-visible { top: var(--space-2); }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}
.work :focus-visible { outline-color: var(--chalk); }
.about :focus-visible { outline-color: var(--umber); }

/* ---------- header ---------- */
.site-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) clamp(16px, 5vw, 64px);
}

.logotype {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--color-fg);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.logotype-dot { color: var(--color-accent); }

.nav-list {
  display: flex;
  gap: var(--space-3);
  list-style: none;
  margin: 0; padding: 0;
}
.nav-list a {
  position: relative;
  color: var(--color-fg);
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-1) 4px;
}
.nav-list a::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px; bottom: 0;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms var(--ease-out);
}
.nav-list a:hover::after,
.nav-list a:focus-visible::after { transform: scaleX(1); }
.nav-list a:hover { color: var(--color-accent); }
.nav-list a:active { opacity: 0.8; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 14px 28px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--step-0);
  text-decoration: none;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-fg);
  box-shadow: 0 2px 0 0 oklch(0 0 0 / 0.25), 0 8px 24px oklch(0 0 0 / 0.18);
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 0 0 oklch(0 0 0 / 0.25); }
.btn-big { font-size: var(--step-1); padding: 18px 40px; }

/* ---------- lighter toggle ---------- */
.lighter {
  position: fixed;
  left: clamp(14px, 4vw, 40px);
  bottom: clamp(14px, 4vw, 40px);
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 10px;
  background: var(--umber-deep);
  color: var(--chalk);
  border: 2px solid var(--brick);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 8px 24px oklch(0 0 0 / 0.25);
  transition: transform 200ms var(--ease-out), box-shadow 250ms var(--ease-out), border-color 250ms var(--ease-out);
}
.lighter[hidden] { display: none; }
.lighter:hover { transform: translateY(-2px); }
.lighter:active { transform: translateY(0); }
.lighter-svg { width: 24px; height: 33px; overflow: visible; flex: none; }
.lighter-box { fill: var(--brick); }
.lighter-cap { fill: oklch(0.82 0.02 82); }
.lighter-spark { fill: var(--chalk); opacity: 0.7; }
.lighter-flame { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.flame-outer { fill: #ff7a18; }
.flame-inner { fill: #ffd24a; }

.lighter.is-lit {
  border-color: #ff9d2a;
  box-shadow: 0 0 10px #ff9d2a, 0 0 28px oklch(0.70 0.20 45 / 0.55), 0 8px 24px oklch(0 0 0 / 0.25);
}
.lighter.is-lit .lighter-flame {
  opacity: 1;
  animation: flicker 0.28s ease-in-out infinite alternate;
}
@keyframes flicker {
  from { transform: scaleY(0.92) scaleX(1.03) translateY(1px); opacity: 0.9; }
  to   { transform: scaleY(1.10) scaleX(0.95); opacity: 1; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 100svh;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding-top: clamp(72px, 14vh, 128px);
}

.hero-eyebrow {
  position: absolute;
  top: clamp(72px, 12vh, 120px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 3;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
  text-align: center;
  padding-inline: var(--space-2);
}

.hero-stage {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 0;
}

/* Giant name — the sole hero focal point. Sits on its own layer so a
   cursor-driven tilt (see main.js) can move it independently. */
.hero-name {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-giant);
  line-height: 0.86;
  letter-spacing: -0.015em;
  color: var(--color-fg);
  user-select: none;
  will-change: transform;
  transition: transform 300ms var(--ease-out);
}
.hero-name-line { display: block; overflow: hidden; }
.hero-name-line .w {
  display: inline-block;
  transform: translateY(110%);
  animation: rise 700ms var(--ease-out) forwards;
}
.hero-name-line:last-child .w { animation-delay: 120ms; }

@keyframes rise { to { transform: translateY(0); } }

/* per-letter melt targets — transforms driven by the lit cursor in main.js */
.hero-name .mc {
  display: inline-block;
  transform-origin: top center;
  will-change: transform, filter;
}
/* once the rise finishes, let drips spill below the line box */
.hero-name.can-melt .hero-name-line { overflow: visible; }

.hero-foot {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) clamp(16px, 5vw, 64px);
}
.hero-tagline {
  margin: 0;
  max-width: 26ch;
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.3;
  text-wrap: balance;
}

/* ---------- work ---------- */
.work {
  background: var(--umber-deep);
  color: var(--chalk);
  padding-block: clamp(48px, 8vw, 128px);
}

.section-heading {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-3);
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.section-note {
  margin: 0 0 var(--space-5);
  color: oklch(0.80 0.02 82);
  max-width: 45ch;
}

.work-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}
/* stagger the cards as they reveal on scroll */
.work-grid .work-card:nth-child(2) { transition-delay: 90ms; }
.work-grid .work-card:nth-child(3) { transition-delay: 180ms; }

.work-card-btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  min-height: 300px;
  margin: 0;
  padding: var(--space-3);
  text-align: left;
  font: inherit;
  color: var(--chalk);
  background: transparent;
  border: 2px solid var(--card-accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 250ms var(--ease-out), box-shadow 250ms var(--ease-out);
}
.work-card-btn:hover,
.work-card-btn:focus-visible { transform: translateY(-6px); }
.work-card-btn:active { transform: translateY(-2px); }

/* revealed media layer — hidden until hover/focus */
.work-card-media {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 350ms var(--ease-out);
}
.work-card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.14);
  transition: transform 6s var(--ease-out);
}
/* slow Ken Burns drift out as the photo is revealed */
.work-card-btn:hover .work-card-media img,
.work-card-btn:focus-visible .work-card-media img,
.work-card-btn:focus-within .work-card-media img { transform: scale(1); }
/* legibility scrim over the photo */
.work-card-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    oklch(0.26 0.04 60 / 0.35) 0%,
    oklch(0.26 0.04 60 / 0.82) 100%);
}
.work-card-btn:hover .work-card-media,
.work-card-btn:focus-visible .work-card-media,
.work-card-btn:focus-within .work-card-media { opacity: 1; }

.work-card-body {
  position: relative;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.work-card-tag {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--card-accent);
}
.work-card-btn:hover .work-card-tag,
.work-card-btn:focus-visible .work-card-tag { color: var(--chalk); }

.work-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1.05;
  max-width: 14ch;
}
.work-card-desc {
  font-size: 0.95rem;
  line-height: 1.4;
  color: oklch(0.82 0.02 82);
  max-width: 28ch;
}
.work-card-more {
  font-weight: 600;
  color: var(--card-accent);
}
.work-card-btn:hover .work-card-more,
.work-card-btn:focus-visible .work-card-more { color: var(--chalk); }

/* open/close label swap driven by aria-expanded */
.work-card-more .more-close { display: none; }
.work-card-btn[aria-expanded="true"] .more-open { display: none; }
.work-card-btn[aria-expanded="true"] .more-close { display: inline; }
/* mark the card whose gallery is open */
.work-card-btn[aria-expanded="true"] {
  transform: translateY(-6px);
  box-shadow: inset 0 -6px 0 0 var(--card-accent);
}

/* ---------- about ---------- */
.about {
  background: var(--cream);
  color: var(--umber);
  padding-block: clamp(48px, 8vw, 128px);
  border-top: 2px solid var(--umber);
}
.about-grid {
  display: grid;
  gap: var(--space-5);
  align-items: start;
}
@media (min-width: 768px) {
  .about-grid { grid-template-columns: 4fr 7fr; }
}

.about-lede {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1.1;
  margin: 0;
  color: var(--moss);
  text-wrap: balance;
}

.about-copy p { max-width: 58ch; }

.about-facts {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}
.about-facts li {
  padding: var(--space-2) 0;
  border-top: 2px solid var(--umber);
}
.about-facts strong {
  display: inline-block;
  min-width: 9ch;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.1em;
}
.about-facts a { color: var(--moss); font-weight: 600; }

/* ---------- contact ---------- */
.contact {
  background: var(--moss);
  color: var(--chalk);
  padding-block: clamp(64px, 10vw, 160px);
  text-align: center;
}
.contact-heading {
  margin: 0 0 var(--space-5);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 1.5rem + 6vw, 6rem);
  line-height: 0.95;
}
/* button sits on red — invert to cream field, umber ink */
.contact .btn-primary {
  background: var(--chalk);
  color: var(--umber);
}
.contact :focus-visible { outline-color: var(--chalk); }

/* ---------- footer ---------- */
.site-footer {
  background: var(--umber-deep);
  border-top: 1px solid oklch(1 0 0 / 0.15);
  padding-block: var(--space-3);
  font-size: 0.875rem;
  color: oklch(0.80 0.02 82);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  justify-content: space-between;
}
.footer-row p { margin: 0; }

/* ---------- scroll reveals ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 450ms var(--ease-out), transform 450ms var(--ease-out);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- inline expanding galleries ---------- */
.work-gallery { margin-top: var(--space-3); }
.work-gallery[hidden] { display: none; }
.work-gallery:not([hidden]) { animation: galleryIn 400ms var(--ease-out) both; }
@keyframes galleryIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

/* each brand / shoot lives on its own row; items share the row evenly,
   so the layout stays symmetric whatever the photo count is */
.gallery-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.gallery-row + .gallery-row { margin-top: var(--space-2); }

.gallery-item {
  flex: 1 1 200px;
  position: relative;
  padding: 0;
  margin: 0;
  border: none;
  background: var(--umber);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms var(--ease-out);
}
.gallery-item:hover img,
.gallery-item:focus-visible img { transform: scale(1.04); }

/* enlarge in place — takes the whole row, image shown whole */
.gallery-item.is-open {
  flex-basis: 100%;
  aspect-ratio: auto;
  cursor: zoom-out;
  background: var(--umber-deep);
}
.gallery-item.is-open img {
  height: auto;
  max-height: 84vh;
  object-fit: contain;
  margin-inline: auto;
}
.gallery-item.is-open:hover img { transform: none; }
.gallery-item.is-open img { animation: zoomIn 420ms var(--ease-out) both; }
@keyframes zoomIn { from { opacity: 0.35; transform: scale(0.985); } to { opacity: 1; transform: none; } }

.work :focus-visible.gallery-item { outline-color: var(--chalk); }

/* staggered entrance when a gallery expands */
.work-gallery:not([hidden]) .gallery-item {
  animation: itemIn 520ms var(--ease-out) both;
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.gallery-row:nth-child(1) .gallery-item:nth-child(1) { animation-delay: 0.04s; }
.gallery-row:nth-child(1) .gallery-item:nth-child(2) { animation-delay: 0.10s; }
.gallery-row:nth-child(1) .gallery-item:nth-child(3) { animation-delay: 0.16s; }
.gallery-row:nth-child(2) .gallery-item:nth-child(1) { animation-delay: 0.14s; }
.gallery-row:nth-child(2) .gallery-item:nth-child(2) { animation-delay: 0.20s; }
.gallery-row:nth-child(2) .gallery-item:nth-child(3) { animation-delay: 0.26s; }
.gallery-row:nth-child(3) .gallery-item:nth-child(1) { animation-delay: 0.24s; }
.gallery-row:nth-child(3) .gallery-item:nth-child(2) { animation-delay: 0.30s; }
.gallery-row:nth-child(3) .gallery-item:nth-child(3) { animation-delay: 0.36s; }

/* caption slides up on hover / focus, and stays while enlarged */
.gallery-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  padding: var(--space-4) var(--space-2) var(--space-2);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--chalk);
  background: linear-gradient(transparent, oklch(0.18 0.03 60 / 0.9));
  transform: translateY(101%);
  transition: transform 320ms var(--ease-out);
  pointer-events: none;
}
.gallery-item:hover .gallery-cap,
.gallery-item:focus-visible .gallery-cap,
.gallery-item.is-open .gallery-cap { transform: translateY(0); }

/* ---------- reduced motion ---------- */
@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;
  }
  .reveal { opacity: 1; transform: none; }
}
