/* ==========================================================================
   TGBS v4 — November 2026 upgrade layer
   Loaded after tgbs.css and release.css. Re-uses their tokens only.
   1  Hero: paint the headline immediately (LCP), motion without hiding
   2  Story chapters (Looks / Works / One team)
   3  Work index → phone rail
   4  Phone app shell: bottom tab bar, auto-hiding header, safe areas
   5  Reduced motion
   ========================================================================== */

/* 1 ---------------------------------------------------------------- HERO */
/* The headline used to start invisible and wait for a JS line-split, which
   delayed Largest Contentful Paint on phones. It now paints at once and only
   moves (transform), so it counts for LCP from the first frame. */
.hero__title {
  animation: v4-rise 900ms var(--ease) both;
  text-wrap: balance;
}
.js .hero [data-reveal] {
  opacity: 1;
  transform: none;
  animation: v4-rise 900ms var(--ease) both;
  animation-delay: var(--reveal-d, 0ms);
}
@keyframes v4-rise {
  from { transform: translate3d(0, 18px, 0); }
  to { transform: none; }
}
.hero__title .serif,
.st__title .serif {
  color: var(--gold);
}

/* 2 --------------------------------------------------------------- STORY */
.st__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
.st__stage {
  position: sticky;
  top: calc(var(--header-h, 72px) + 4vh);
  height: calc(100vh - var(--header-h, 72px) - 8vh);
  min-height: 460px;
}
.st__stage-inner {
  position: relative;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 80% at 80% 100%, rgba(208, 176, 86, 0.14), transparent 60%),
    linear-gradient(180deg, var(--ink-2), var(--ink));
  padding: clamp(24px, 3vw, 40px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.st__words {
  position: relative;
  height: clamp(5.2rem, 9vw, 8.4rem);
  overflow: hidden;
}
.st__word {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  font-size: clamp(3rem, 1rem + 5.4vw, 6.4rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--fg);
  transform: translate3d(0, 110%, 0);
  transition: transform 700ms var(--ease), opacity 500ms var(--ease);
  opacity: 0;
  white-space: nowrap;
}
.st__word em {
  font-style: normal;
  font-size: 0.22em;
  letter-spacing: 0.12em;
  color: var(--gold);
  transform: translateY(-1.6em);
}
.st__word.is-on { transform: none; opacity: 1; }
.st__word.is-past { transform: translate3d(0, -110%, 0); opacity: 0; }

.st__meter {
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.st__meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gold-metal);
  transform-origin: left;
  transform: scaleX(var(--st-p, 0));
}

/* The orb: three rings that tighten as the chapters progress — the two
   halves ("looks", "works") pulled into one team. */
.st__orb {
  position: relative;
  flex: 1;
  min-height: 180px;
  display: grid;
  place-items: center;
}
.st__ring {
  position: absolute;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(208, 176, 86, 0.5);
  transition: transform 900ms var(--ease), border-color 600ms var(--ease);
}
.st__ring--a { width: min(46%, 230px); transform: translateX(calc(-38% * (1 - var(--st-join, 0)))); }
.st__ring--b { width: min(46%, 230px); transform: translateX(calc(38% * (1 - var(--st-join, 0)))); }
.st__ring--c {
  width: min(64%, 320px);
  border-style: dashed;
  border-color: rgba(208, 176, 86, 0.22);
  animation: v4-spin 40s linear infinite;
}
.st__core {
  position: relative;
  font-size: var(--fs-eyebrow, 0.75rem);
  letter-spacing: 0.3em;
  color: var(--gold);
  padding: 10px 14px;
  border-radius: var(--r-pill);
  background: rgba(32, 32, 32, 0.8);
  border: 1px solid var(--line-2);
}
[data-story][data-step="2"] .st__ring--a,
[data-story][data-step="2"] .st__ring--b { border-color: var(--gold); }
@keyframes v4-spin { to { transform: rotate(1turn); } }

.st__title { margin-bottom: clamp(24px, 4vw, 48px); max-width: 16ch; }
.st__chapter {
  min-height: 78vh;
  padding-block: 4vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  opacity: 0.38;
  transition: opacity 500ms var(--ease);
}
.st__chapter.is-on { opacity: 1; }
.no-js .st__chapter, html:not(.js) .st__chapter { opacity: 1; }
.st__num {
  font-size: var(--fs-sm);
  letter-spacing: 0.18em;
  color: var(--gold);
}
.st__num span { color: var(--fg-3); }
.st__svcs, .st__trust { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.st-svc {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--fill);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.st-svc:hover, .st-svc:focus-visible {
  border-color: rgba(208, 176, 86, 0.55);
  background: var(--fill-2);
  transform: translateX(4px);
}
.st-svc__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(208, 176, 86, 0.1);
  color: var(--gold);
}
.st-svc__icon svg { width: 22px; height: 22px; }
.st-svc__text { display: grid; gap: 3px; }
.st-svc__text strong { font-weight: 600; }
.st-svc__text span { color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.45; }
.st-svc__price {
  font-size: var(--fs-sm);
  color: var(--gold-lite);
  white-space: nowrap;
  text-align: right;
}
.st-svc__price small { display: block; color: var(--fg-3); font-size: var(--fs-xs); }
.st__trust li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.st__trust li > span { color: var(--gold); }
.st__trust li > span svg { width: 22px; height: 22px; }
.st__trust p { margin: 4px 0 0; font-size: var(--fs-sm); }

@media (max-width: 940px) {
  .st__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  /* On a phone the stage becomes a slim sticky chapter bar. */
  .st__stage {
    top: calc(var(--header-h, 64px) + 6px);
    height: auto;
    min-height: 0;
    z-index: 3;
    order: 0;
  }
  .st__stage-inner {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--r-pill);
    background: rgba(32, 32, 32, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    gap: 14px;
  }
  .st__stage .eyebrow, .st__orb { display: none; }
  .st__words { height: 1.6rem; flex: 0 0 9.5rem; }
  .st__word { font-size: 1.15rem; letter-spacing: -0.01em; }
  .st__word em { font-size: 0.7em; transform: none; }
  .st__meter { flex: 1; }
  .st__flow { margin-top: 24px; }
  .st__chapter { min-height: 0; padding-block: 28px; opacity: 1; }
  .st-svc { grid-template-columns: 40px minmax(0, 1fr); padding: 14px; }
  .st-svc__icon { width: 40px; height: 40px; }
  .st-svc__price { grid-column: 2; text-align: left; }
  .st-svc__price small { display: inline; }
}

/* 3 ---------------------------------------------------------- WORK INDEX */
.wi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
}
.wi__list { list-style: none; margin: 0; padding: 0; counter-reset: wi; }
.wi__row {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto 3rem 1.4rem;
  gap: 14px;
  align-items: baseline;
  padding: 18px 4px;
  border-top: 1px solid var(--line);
  color: var(--fg-2);
  text-decoration: none;
  transition: color var(--t) var(--ease), padding var(--t) var(--ease);
}
.wi__list li:last-child .wi__row { border-bottom: 1px solid var(--line); }
.wi__n { font-size: var(--fs-xs); color: var(--fg-4); letter-spacing: 0.1em; }
.wi__t {
  font-size: clamp(1.15rem, 0.8rem + 1vw, 1.6rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.wi__c, .wi__y { font-size: var(--fs-sm); color: var(--fg-3); }
.wi__a { color: var(--gold); opacity: 0; transform: translate(-6px, 6px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.wi__a svg { width: 18px; height: 18px; }
.wi__row[aria-current="true"], .wi__row:hover, .wi__row:focus-visible {
  padding-left: 14px;
}
.wi__row[aria-current="true"] .wi__t { color: var(--gold); }
.wi__row[aria-current="true"] .wi__a, .wi__row:hover .wi__a, .wi__row:focus-visible .wi__a { opacity: 1; transform: none; }

.wi__stage {
  position: sticky;
  top: calc(var(--header-h, 72px) + 24px);
  display: grid;
}
.wi__card {
  grid-area: 1 / 1;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--ink-2);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.985);
  transition: opacity 420ms var(--ease), transform 600ms var(--ease), visibility 0s linear 420ms;
}
.wi__card.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 420ms var(--ease), transform 600ms var(--ease), visibility 0s;
}
.wi__media { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--ink-3); }
.wi__media img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 1.2s var(--ease); }
.wi__card.is-on .wi__media img { transform: scale(1.02); }
.wi__body { padding: clamp(18px, 2.4vw, 28px); display: grid; gap: 8px; }
.wi__body h3 { font-size: var(--fs-h4, 1.4rem); letter-spacing: -0.02em; margin: 0; }
.wi__body p { margin: 0; }
.wi__meta { font-size: var(--fs-xs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.wi__links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 6px; }
.wi__hint { display: none; }

@media (max-width: 860px) {
  .wi { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .wi__list { display: none; }
  /* Phone: every project is a card in a swipeable, snapping rail. */
  .wi__stage {
    position: static;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 84%;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }
  .wi__stage::-webkit-scrollbar { display: none; }
  .wi__card,
  .wi__card.is-on {
    grid-area: auto;
    opacity: 1;
    visibility: visible;
    transform: none;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
  }
  .wi__media { aspect-ratio: 4 / 3; }
  .wi__body { flex: 1; align-content: start; }
  .wi__body .muted { font-size: var(--fs-sm); }
  .wi__hint {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    font-size: var(--fs-xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg-3);
    margin: 4px 0 0;
  }
  .wi__hint svg { width: 14px; height: 14px; }
}

/* 4 ----------------------------------------------------------- APP SHELL */
.appbar { display: none; }

@media (max-width: 860px) {
  .appbar {
    position: fixed;
    z-index: 90;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px;
    border-radius: 22px;
    border: 1px solid var(--line-2);
    background: rgba(26, 26, 26, 0.86);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
    transition: transform 380ms var(--ease);
  }
  .appbar__tab {
    display: grid;
    justify-items: center;
    gap: 3px;
    min-height: 52px;
    align-content: center;
    border-radius: 16px;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    color: var(--fg-3);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
  }
  .appbar__tab svg { width: 21px; height: 21px; }
  .appbar__tab:active { transform: scale(0.94); }
  .appbar__tab[aria-current="page"] { color: var(--gold); background: rgba(208, 176, 86, 0.1); }
  .appbar__tab--wa { color: #141414; background: var(--gold-metal); background-size: 200% 100%; }
  .appbar__tab--wa span { font-weight: 600; }

  /* The floating WhatsApp button duplicates the Chat tab on phones. */
  .fabs .fab--wa { display: none; }
  .fabs { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  /* Header gets out of the way while reading, returns on scroll up. */
  .header { transition: transform 380ms var(--ease), background-color var(--t) var(--ease); }
  .v4-hide-header .header { transform: translateY(-110%); }
  .v4-hide-header .st__stage { top: 10px; }

  /* Tap targets: at least 44px for primary controls. */
  .btn { min-height: 46px; }
}

/* 5 ------------------------------------------------------ REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  .hero__title, .js .hero [data-reveal] { animation: none; }
  .st__word, .st__ring, .wi__card, .wi__media img, .appbar, .header { transition: none; }
  .st__ring--c { animation: none; }
}
