/* ============================================================
   custom.css — additions on top of the Webflow export
   Loaded AFTER webflow-style.css so equal-specificity rules win.
   ============================================================ */

/* ── Theming ──────────────────────────────────────────────
   The Webflow export already drives every colour through
   --background-* / --text-* tokens defined on :root (dark).
   We add a light palette + a system-follow rule + an explicit
   override driven by [data-theme] on <html>.
   ------------------------------------------------------------ */

/* Default (dark): smiley SVG ships white, so no inversion needed. */
:root {
  --smiley-invert: 0;
}

/* Light palette — used when the user explicitly picks light. */
:root[data-theme="light"] {
  --background-1: #ffffff;
  --background-2: #f3f3f4;
  --background-3: #e4e4e7;
  --background-4: #d6d6da;
  --text-1: #0a0a0a;
  --text-2: #1f1f1f;
  --text-3: #3f3f46;
  --text-4: #71717a;
  --smiley-invert: 1;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --background-1: #ffffff;
    --background-2: #f3f3f4;
    --background-3: #e4e4e7;
    --background-4: #d6d6da;
    --text-1: #0a0a0a;
    --text-2: #1f1f1f;
    --text-3: #3f3f46;
    --text-4: #71717a;
    --smiley-invert: 1;
  }
}

/* The smiley.svg has a hard-coded white stroke; invert it in light mode
   so it stays visible. Also kill the stray Webflow logo-wrapper shadow
   that shows up as a box artefact on a light background. */
.logo img {
  filter: invert(var(--smiley-invert, 0));
  transition: filter .35s ease;
}

.logo-wrapper {
  box-shadow: none;
}

/* ── Header shares the background ──────────────────────────────────
   A frosted, translucent nav so the background reveal (and the blob
   peeking from the logo) shows through the header instead of being
   covered. Falls back to a solid-ish tint where backdrop-filter is
   unsupported. */
.nav {
  background-color: color-mix(in srgb, var(--background-1) 55%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

/* ── Unified nav buttons — links and the icon toggle share every state ── */
.nav-link,
.theme-toggle {
  color: var(--text-3);
  background-color: transparent;
  border: none;
  border-radius: 8px;
  transition: color .2s ease, background-color .2s ease, transform .12s ease;
}

.nav-link:hover,
.theme-toggle:hover {
  color: var(--text-1);
  background-color: color-mix(in srgb, var(--text-1) 10%, transparent);
  opacity: 1;
}

.nav-link:active,
.theme-toggle:active {
  transform: scale(.94);
}

.nav-link.w--current {
  color: var(--text-1);
  background-color: color-mix(in srgb, var(--text-1) 14%, transparent);
}

.nav-link:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--text-4);
  outline-offset: 2px;
}

/* Smooth the flip between themes */
body,
.nav,
.nav-link,
.work-item {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}

/* ── Theme toggle button ──────────────────────────────────── */
.theme-toggle {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0;
  cursor: pointer;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Show the icon for the mode you'll switch TO:
   sun while in dark mode, moon while in light mode. */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle[data-mode="light"] .icon-sun { display: none; }
.theme-toggle[data-mode="light"] .icon-moon { display: block; }

/* ── Unified grid: header + pill filter ───────────────────── */
.grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  appearance: none;
  border: 1px solid var(--background-3);
  background-color: transparent;
  color: var(--text-4);
  font-family: Inter, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .15s ease;
}

.pill:hover {
  color: var(--text-1);
  border-color: var(--text-4);
}

.pill:active { transform: scale(.96); }

.pill:focus-visible {
  outline: 2px solid var(--text-4);
  outline-offset: 2px;
}

.pill.is-active {
  background-color: var(--text-1);
  border-color: var(--text-1);
  color: var(--background-1);
}

/* ── Responsive masonry: 1 / 2 / 3 / 4 columns ────────────── */
.work-grid {
  column-count: 1;
  column-gap: 24px;
}

@media (min-width: 641px)  { .work-grid { column-count: 2; } }
@media (min-width: 992px)  { .work-grid { column-count: 3; } }
@media (min-width: 1600px) { .work-grid { column-count: 4; } }

/* Experiment tiles without an actual link are placeholders — kill the fake-clickable hover. */
.work-item[data-category="experiment"]:not(:has(a)):hover {
  transform: none;
  box-shadow: none;
  cursor: default;
}

/* Keep cards intact across column breaks */
.work-item {
  -webkit-column-break-inside: avoid;
  break-inside: avoid;
  /* Allow the item to shrink below the intrinsic width of its content,
     so a large image can't push the column wider than its share. */
  min-width: 0;
}

/* Make tile images proper block-level responsive images. Webflow's base
   sets `width:100%; height:100%`, which combined with the default
   inline-block display lets a large natural-size image leak its intrinsic
   width into the column track and blow the grid out. */
.work-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* ── Filter show/hide with a soft fade-in ─────────────────── */
.work-item.is-hidden { display: none; }

/* No fill-mode: after the intro finishes the transform reverts to base,
   so it never lingers and override the :hover transform. */
.work-item.is-shown {
  animation: tile-in .5s cubic-bezier(.34, 1.4, .5, 1);
}

@keyframes tile-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .work-item.is-shown { animation: none; }
}

@media screen and (max-width: 479px) {
  .grid-header { flex-direction: column; align-items: flex-start; }
}

/* ── Blur the page content while the nav panel is open ─────── */
.section {
  transition: filter .35s ease;
}

body.nav-open .section {
  filter: blur(7px);
}

@media (prefers-reduced-motion: reduce) {
  .section { transition: none; }
}

/* ── Cross-document view transition: tile image → case-study hero ───
   Opt the page into same-origin nav transitions. The clicked tile's
   image is tagged `tile-media` (in JS) to pair with the hero image on
   the destination, so it morphs into place. Only fires on navigation,
   never on a direct URL load. Degrades to a normal load when unsupported. */
@view-transition { navigation: auto; }

::view-transition-group(tile-media) {
  animation-duration: .55s;
  animation-timing-function: cubic-bezier(.34, 1.15, .35, 1);
}

/* A soft, quick cross-fade for the rest of the page. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .4s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* ── Anchor scrolling ──────────────────────────────────────────────
   In-page smooth scrolling is handled in JS (single, offset-aware pass),
   so neutralise the CSS smooth-scroll to avoid a competing animation and
   a janky smooth jump on hash page-loads. scroll-margin-top keeps a
   section's heading clear of the sticky nav when landed on via #hash. */
html { scroll-behavior: auto; }

.section[id] { scroll-margin-top: 80px; }

/* ── Skip link (visually hidden until focused) ───────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: var(--background-2);
  color: var(--text-1);
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  outline: 2px solid var(--text-4);
  outline-offset: 2px;
}

/* The skip-link target shouldn't show a focus ring when it receives focus
   programmatically (it's not a real interactive element). */
[id="main"]:focus { outline: none; }

/* ── Screen-reader-only utility ──────────────────────────────── */
.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;
}

/* ── Reduced-motion safeguard ───────────────────────────────────
   Anyone with prefers-reduced-motion gets a near-still interface:
   no animations, no transitions, no smooth scroll. */
@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;
  }
}

/* The hamburger trigger is a real <button>, which gets OS-default
   appearance in some browsers (a light filled rectangle). Strip it back
   so the menu icon lines sit on a transparent surface in every theme. */
.menu-button {
  -webkit-appearance: none;
          appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-1);
}

/* ── Mobile nav drawer (vanilla replacement for Webflow's nav JS) ─── */
@media (max-width: 767px) {
  /* Override Webflow's default-hidden nav-menu and position it as a
     fixed off-canvas drawer that slides in when body.nav-open. */
  .nav-menu {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(80vw, 320px);
    /* Top + left match the .nav-container padding so the drawer's smiley
       lands exactly where the header smiley sits — making the drawer
       slide in *under* it visually rather than re-introducing a second
       logo at a different position. */
    padding: 21px 24px 32px 40px;
    background: var(--background-1);
    transform: translateX(-101%);  /* parked just off-screen */
    transition: transform .35s cubic-bezier(.4, 0, .2, 1);
    z-index: 50;
    gap: 4px;
    border-right: 1px solid var(--background-3);
  }

  body.nav-open .nav-menu {
    transform: translateX(0);
  }

  /* The duplicate header logo lives inside .nav-menu (Webflow's
     "mobile menu" brand slot). Its wrapper has flex:1 which, inside the
     drawer's column flexbox, balloons the smiley to fill the panel.
     Pin it to the SVG's native size so it matches the desktop logo. */
  .nav-menu .logo-wrapper.mobile-menu {
    flex: 0 0 auto;
    box-shadow: none;
    margin-bottom: 24px;
  }
  .nav-menu .logo.w-nav-brand img {
    width: 34px;
    height: 34px;
  }

  /* Suppress the slide animation while the viewport is crossing the
     mobile/desktop breakpoint — otherwise the drawer briefly animates
     from its desktop position (on-screen) out to its parked position
     (off-screen), reading as "menu opens then closes". A JS handler
     sets/clears `nav-resizing` around the matchMedia change event. */
  body.nav-resizing .nav-menu {
    transition: none !important;
  }

  /* Tablet/phone nav links stack with breathing room.
     Each link is sized to its own label (not 100% wide) so the hover
     pill hugs the text with equal horizontal/vertical padding rather
     than stretching across the drawer. The −14px left margin offsets
     the 14px left padding so the text glyph still left-aligns with the
     drawer's smiley above. */
  .nav-menu .nav-link {
    width: -moz-fit-content;
    width: fit-content;
    max-width: 100%;
    font-size: 24px;
    padding: 10px 14px;
    margin: 0 0 0 -14px;
    border-radius: 8px;
  }

  /* Tighten the gap between the smiley and the first link. */
  .nav-menu .logo-wrapper.mobile-menu {
    margin-bottom: 48px;
  }
}

/* ── Pull quote — theme-aware, card-style ─────────────────────────
   Replaces the original blockquote (which baked a purple gradient bg
   into the CSS) with a clean card that uses theme tokens, a faint
   decorative quote mark, and editorial-small attribution. */
blockquote {
  background: var(--background-2);
  background-image: none;
  border: none;
  border-radius: 14px;
  margin: 40px 0;
  padding: 36px 40px;
  color: var(--text-1);
  font-family: Inter, sans-serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.005em;
  position: relative;
  overflow: hidden;
  transition: background-color .35s ease, color .35s ease;
}

blockquote::before {
  content: "\201C";                /* left double curly quote */
  position: absolute;
  top: 6px;
  left: 22px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 110px;
  line-height: 1;
  color: var(--text-1);
  opacity: 0.08;
  pointer-events: none;
  user-select: none;
}

blockquote small {
  display: block;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The Webflow markup includes a <br/> between the quote and <small>;
   we replace that visual break with our own margin-top above. */
blockquote br { display: none; }

@media screen and (max-width: 767px) {
  blockquote {
    padding: 28px 28px;
    font-size: 20px;
    border-radius: 12px;
  }
  blockquote::before {
    font-size: 84px;
    top: 4px;
    left: 16px;
  }
}

/* ── Draft content gate ──────────────────────────────────────────
   Draft tiles + the "Experiments" filter pill stay hidden on the public
   site. Anything with data-draft="true" (or the whole `experiment`
   category) is considered draft and only shows when:
     • we're on localhost / 127.0.0.1 / *.local, OR
     • the URL has ?preview, OR
     • localStorage.experiments === 'show'.
   The inline <head> script adds `show-experiments` to <html> in those
   cases. To preview the public view locally, open DevTools and run:
     document.documentElement.classList.remove('show-experiments')
   (refresh restores the gate.) */
.work-item[data-category="experiment"],
.work-item[data-draft="true"],
.pill[data-filter="experiment"] {
  display: none;
}

html.show-experiments .work-item[data-category="experiment"],
html.show-experiments .work-item[data-draft="true"] {
  display: block;
}

html.show-experiments .pill[data-filter="experiment"] {
  display: inline-flex;
}

/* ── Password gate (Atlassian case studies) ─────────────────────
   Pages opted in with <body data-gated> hide their .gate-content
   until the shared password is entered. The pre-paint inline script
   adds `case-unlocked` to <html> when the session is already unlocked,
   so a refreshed unlocked tab renders without a flash. The form lives
   in .gate-prompt. */
.gate-prompt { display: none; }

body[data-gated] .gate-content { display: none; }
body[data-gated] .gate-prompt  { display: block; }

html.case-unlocked body[data-gated] .gate-content,
body[data-gated].is-unlocked .gate-content {
  display: revert;
}
html.case-unlocked body[data-gated] .gate-prompt,
body[data-gated].is-unlocked .gate-prompt {
  display: none;
}

/* Outer container becomes a single-cell grid so the card overlays the
   blurred lorem block underneath. */
body[data-gated] .gate-prompt {
  display: grid;
  grid-template-areas: "stack";
  margin: 24px 0 0;
  position: relative;
  isolation: isolate;
}
body[data-gated] .gate-prompt > .gate-lorem,
body[data-gated] .gate-prompt > .gate-card {
  grid-area: stack;
}

/* Decorative lorem-ipsum behind the card — mirrors the real case-study
   section layout (heading left, body right; stacks on mobile) so the
   blurred silhouette reads like the actual content underneath.
   Bleeds beyond .container on left/right so the blur halo doesn't clip
   at a hard edge — its own bottom + horizontal mask handles the fade. */
.gate-lorem {
  pointer-events: none;
  user-select: none;
  color: var(--text-2);
  font-family: Inter, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  filter: blur(14px) saturate(0.85);
  /* Two-axis mask: bottom fade + symmetric side fade. Composited so
     both apply — only where both are opaque does content render. This
     softens every edge so the blur halo never terminates at a hard line. */
  -webkit-mask-image:
    linear-gradient(to bottom, #000 0%, #000 30%, transparent 96%),
    linear-gradient(to right, transparent 0%, #000 6%, #000 94%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, #000 0%, #000 30%, transparent 96%),
    linear-gradient(to right, transparent 0%, #000 6%, #000 94%, transparent 100%);
          mask-composite: intersect;
  margin: 0 -48px;
  padding: 0 48px 100px;
  z-index: 0;
}

.gate-lorem .lorem-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px 56px;
  padding: 32px 0;
}
.gate-lorem .lorem-row + .lorem-row { padding-top: 40px; }

.gate-lorem h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.gate-lorem .lorem-body { margin: 0; }
.gate-lorem .lorem-body p { margin: 0 0 14px; }
.gate-lorem .lorem-body p:last-child { margin-bottom: 0; }
.gate-lorem .lorem-body ul {
  margin: 0 0 14px;
  padding-left: 20px;
  list-style: disc;
}
.gate-lorem .lorem-body li { margin: 0 0 6px; }

@media (max-width: 767px) {
  .gate-lorem .lorem-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 0;
  }
  .gate-lorem { margin: 0 -24px; padding: 0 24px 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .gate-lorem { filter: blur(10px); }
}

/* The actual password card sits on top of the lorem block. */
.gate-card {
  align-self: start;
  justify-self: center;
  margin-top: 64px;
  width: 100%;
  max-width: 460px;
  background: var(--background-2);
  border-radius: 14px;
  padding: 44px 36px;
  text-align: center;
  /* Layered: hairline ring for crisp edge definition, two soft drops
     for depth — reads on light AND dark without feeling heavy. */
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--text-1) 8%, transparent),
    0 2px 6px rgba(0, 0, 0, 0.08),
    0 14px 32px -10px rgba(0, 0, 0, 0.22),
    0 40px 80px -28px rgba(0, 0, 0, 0.45);
  transition: background-color .35s ease, box-shadow .35s ease;
  z-index: 1;
}

.gate-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

.gate-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.gate-card input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--background-3);
  border-radius: 8px;
  background: var(--background-1);
  color: var(--text-1);
  font-size: 16px;
  font-family: Inter, sans-serif;
  transition: border-color .2s ease, background-color .2s ease;
}

.gate-card input[type="password"]:focus {
  outline: 2px solid var(--text-4);
  outline-offset: 2px;
  border-color: transparent;
}

.gate-card button {
  appearance: none;
  border: none;
  background: var(--text-1);
  color: var(--background-1);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: opacity .15s ease, transform .12s ease;
}

.gate-card button:hover  { opacity: .92; }
.gate-card button:active { transform: scale(.97); }

.gate-card button:focus-visible {
  outline: 2px solid var(--text-4);
  outline-offset: 2px;
}

.gate-card .gate-error {
  color: #e85a5a;
  font-size: 14px;
  margin: 4px 0 0;
  min-height: 1.2em;
}

.gate-contact {
  margin: 22px 0 0;
  font-size: 14px;
  color: var(--text-3);
}
.gate-contact a {
  color: var(--text-1);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.gate-contact a:hover { opacity: .8; }

/* External-link arrow next to nav links — inline SVG using currentColor
   so it follows whatever colour the surrounding link text is. */
.ext-arrow {
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.25em;
  vertical-align: -0.1em;
  flex-shrink: 0;
}
