/* ==========================================================================
   Public homepage — v1.3
   Hero and process are one section: the untangling is the hero.
   ========================================================================== */

/* Masthead -------------------------------------------------------------- */
.masthead {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--gutter);
  background: transparent; border-bottom: 1px solid transparent;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), padding var(--dur-2) var(--ease-out);
}
.masthead.is-scrolled { background: var(--paper); border-bottom-color: var(--rule); padding-top: var(--s-3); padding-bottom: var(--s-3); }
.masthead__nav a.is-active { border-color: var(--teal); color: var(--teal); }
html { scroll-behavior: smooth; }
#work, #contact { scroll-margin-top: 4.5rem; }
.masthead__nav { display: flex; gap: var(--s-2); }
.masthead__nav a {
  font-family: var(--mono); font-size: var(--step--2); letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; color: var(--ink-2);
  padding: 0.45em 0.95em; border: 1px solid transparent; border-radius: var(--radius-pill);
  transition: border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.masthead__nav a:hover, .masthead__nav a:focus-visible { border-color: var(--teal); color: var(--teal); }

/* 1 · Hero + untangling -------------------------------------------------- */
.untangle { position: relative; height: 320vh; }
.untangle__sticky {
  position: sticky; top: 0;
  height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: var(--s-6) var(--s-8);
  align-items: center;
  padding: clamp(4.5rem, 13svh, 7rem) var(--gutter) clamp(2.5rem, 7svh, 4rem);
  overflow: hidden;
}
.untangle__text { align-self: center; }

.hero__title {
  margin-top: var(--s-4);
  font-family: var(--sans); font-weight: 400;
  /* scales with width and height so the whole column fits the window */
  font-size: clamp(2.2rem, min(var(--step-4), (100svh - 36rem) / 3), var(--step-4));
  line-height: 1; letter-spacing: var(--display-track);
}
.hero__line { display: block; opacity: 0; transform: translateY(0.25em); animation: rise 0.9s var(--ease-out) forwards; }
.hero__line:nth-child(2) { animation-delay: 0.1s; }
.hero__line:nth-child(3) { animation-delay: 0.2s; }
.hero__title em { font-style: normal; }
@keyframes rise { to { opacity: 1; transform: none; } }

.tangle-word { position: relative; display: inline-block; white-space: nowrap; }
.squiggle { position: absolute; left: 0; bottom: -0.12em; width: 100%; height: 0.32em; overflow: visible; }
.squiggle path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.squiggle__mess { stroke: var(--ink); stroke-width: 1.6; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease-in-out) 0.5s forwards, fade-out 0.5s ease 1.9s forwards; }
.squiggle__line { stroke: var(--coral); stroke-width: 2.4; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.8s var(--ease-out) 2.05s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.hero__lede { margin-top: clamp(0.75rem, 2.5svh, 1.5rem); max-width: 30rem; font-size: var(--step-1); line-height: 1.45; color: var(--ink-2); }

/* Stages */
.stages { list-style: none; padding: 0; margin-top: clamp(1rem, 4svh, 2rem); position: relative; max-width: 26rem; }
.stages::before { content: ""; position: absolute; left: 0.9rem; top: 0.6rem; bottom: 0.6rem; width: 1px; background: var(--rule); }
.stage {
  position: relative;
  display: grid; grid-template-columns: 2.6rem 1fr; column-gap: var(--s-3);
  padding: 0.4rem 0; color: var(--ink-3);
  transition: color var(--dur-2) var(--ease-out);
}
.stage__n {
  grid-row: span 2;
  font-family: var(--mono); font-size: var(--step--2);
  width: 1.8rem; height: 1.8rem; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 50%;
  position: relative; z-index: 1;
  transition: background var(--dur-2), color var(--dur-2), border-color var(--dur-2);
}
.stage__name { font-size: var(--step-1); line-height: 1.6; letter-spacing: -0.015em; }
.stage__desc {
  font-size: var(--step--1); line-height: 1.45;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height var(--dur-3) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.stage.is-done { color: var(--ink-2); }
.stage.is-done .stage__n { border-color: var(--ink); }
.stage.is-active { color: var(--ink); }
.stage.is-active .stage__n { background: var(--ink); color: #fff; border-color: var(--ink); }
.stage.is-active .stage__desc { max-height: 4em; opacity: 1; color: var(--ink-2); }
.stage[data-stage="3"].is-active .stage__n { background: var(--signal); border-color: var(--signal); }

/* Figure */
.untangle__figure { min-width: 0; align-self: center; }
.untangle__svg { width: 100%; height: auto; max-height: calc(100svh - 12rem); overflow: visible; }

.untangle__caption {
  display: flex; gap: var(--s-4); align-items: baseline;
  margin-top: var(--s-4); padding-top: var(--s-3); border-top: var(--hair);
  font-size: var(--step--1); color: var(--ink-3);
}
.untangle__fig { font-family: var(--mono); font-size: var(--step--2); letter-spacing: 0.08em; text-transform: uppercase; }
.untangle__fig::after { content: " ↓"; }

.untangle__progress { position: absolute; left: var(--gutter); right: var(--gutter); bottom: var(--s-5); height: 1px; background: var(--rule); }
.untangle__progress span { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); }

/* Reduced motion / no JS: finished drawing, every stage readable */
.untangle.is-static { height: auto; }
.untangle.is-static .untangle__sticky { position: relative; height: auto; min-height: 100svh; }
.untangle.is-static .stage { color: var(--ink); }
.untangle.is-static .stage__desc { max-height: none; opacity: 1; color: var(--ink-2); }
.untangle.is-static .untangle__progress, .untangle.is-static .untangle__fig { display: none; }

/* C · Work: the case-study cards live in cards.css ----------------------- */

/* Contact ---------------------------------------------------------------- */
.contact { background: var(--ink); color: #fff; padding: var(--s-9) var(--gutter) var(--s-6); }
.contact :focus-visible { outline-color: var(--teal-on-dark); }
.contact__grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: var(--s-7) var(--s-9); align-items: start; }
.contact__title {
  font-weight: 400; font-size: var(--step-3); line-height: 1.05; letter-spacing: var(--display-track);
  max-width: 14ch;
}
.contact__title em { font-style: normal; color: var(--night-text-2); }
.contact__lede { margin-top: var(--s-5); color: var(--night-text-2); font-size: var(--step-1); line-height: 1.45; max-width: 26rem; }

/* Form */
.cform { display: grid; gap: var(--s-5); }
.cform__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.cform__field { display: grid; gap: var(--s-2); }
.cform label { font-family: var(--mono); font-size: var(--step--2); letter-spacing: 0.08em; text-transform: uppercase; color: var(--night-text-2); }
.cform label span { text-transform: none; letter-spacing: 0; }
.cform input, .cform textarea {
  width: 100%; background: transparent; color: #fff;
  border: 0; border-bottom: 1px solid var(--night-rule); border-radius: 0;
  padding: var(--s-2) 0; font-size: var(--step-1); line-height: 1.4;
  transition: border-color var(--dur-2);
}
.cform textarea { resize: vertical; min-height: 6.5rem; }
.cform input:hover, .cform textarea:hover { border-bottom-color: #666; }
.cform input:focus, .cform textarea:focus { outline: none; border-bottom-color: var(--teal-on-dark); box-shadow: 0 1px 0 var(--teal-on-dark); }
.cform [aria-invalid="true"] { border-bottom-color: var(--coral); }
.cform__err { min-height: 1.2em; font-size: var(--step--1); color: #F29A82; }
.cform__err:empty { min-height: 0; }
.cform__hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cform__captcha:empty { display: none; }
.cform__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4) var(--s-5); }
.cform__btn {
  display: inline-flex; align-items: center; gap: var(--s-3);
  background: #fff; color: var(--ink); border: 0; border-radius: var(--radius-pill);
  padding: 0.9rem 1.6rem; min-height: 48px; cursor: pointer;
  font-family: var(--mono); font-size: var(--step--1); letter-spacing: 0.06em; text-transform: uppercase;
  transition: background var(--dur-2), color var(--dur-2);
}
.cform__btn:hover { background: var(--teal-on-dark); }
.cform__btn[disabled] { opacity: 0.6; cursor: progress; }
.cform__status { font-size: var(--step--1); color: var(--night-text-2); }
.cform__status.is-error { color: #F29A82; }

.cform-done { padding: var(--s-6) 0; border-top: 1px solid var(--night-rule); }
.cform-done h3 { font-weight: 400; font-size: var(--step-2); letter-spacing: -0.02em; }
.cform-done h3::after { content: ""; display: block; width: 3rem; margin-top: var(--s-3); border-bottom: 3px solid var(--mustard); }
.cform-done p { margin-top: var(--s-3); color: var(--night-text-2); }

.contact__foot {
  display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6);
  margin-top: var(--s-9); padding-top: var(--s-4); border-top: 1px solid var(--night-rule);
  font-family: var(--mono); font-size: var(--step--2); color: var(--night-text-2);
}
.contact__foot a { color: #fff; text-decoration: none; border-bottom: 1px solid var(--night-rule); }
.contact__foot a:hover { border-color: #fff; }
.contact__foot span:last-child { margin-left: auto; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
}

@media (max-width: 900px) {
  .untangle { height: 300vh; }
  .untangle__sticky {
    grid-template-columns: 1fr; grid-template-rows: auto 1fr;
    align-content: start; gap: var(--s-4);
    padding-top: var(--s-8); padding-bottom: var(--s-6);
  }
  .hero__title { font-size: clamp(2.4rem, 1.6rem + 4vw, 3.4rem); }
  .hero__lede { font-size: var(--step-0); margin-top: var(--s-3); }
  .stages { margin-top: var(--s-4); }
  .stages::before { display: none; }
  .stage { display: none; padding: 0; }
  .stage.is-active { display: grid; }
  .untangle__figure { align-self: start; margin-top: var(--s-5); }
  .untangle__svg { max-height: 36svh; }
  .untangle__caption { display: none; }

  .untangle.is-static .stages { display: block; }
  .untangle.is-static .stage { display: grid; padding: 0.4rem 0; }
  .untangle.is-static .untangle__svg { max-height: none; }

  .contact__grid { grid-template-columns: 1fr; }
  .cform__row { grid-template-columns: 1fr; }
  .contact__foot span:last-child { margin-left: 0; }
}

@media (min-width: 901px) and (max-height: 820px) {
  .hero__lede { font-size: var(--step-0); max-width: 26rem; }
  .stage { padding: 0.15rem 0; }
  .stage__name { font-size: var(--step-0); }
  .untangle__caption { margin-top: var(--s-2); }
}
@media (min-width: 901px) and (max-height: 700px) {
  .hero__lede { display: none; }
}
@media (max-width: 900px) and (max-height: 720px) {
  .hero__lede { display: none; }
  .untangle__svg { max-height: 30svh; }
}

@media (prefers-reduced-motion: reduce) {
  .hero__line { opacity: 1; transform: none; animation: none; }
  .squiggle__mess { display: none; }
  .squiggle__line { stroke-dashoffset: 0; animation: none; }
}

/* ==========================================================================
   v1.6 — Hero variant B: "the story"
   ========================================================================== */
.story-svg { overflow: hidden; }
.story .s-ink { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.story .s-fill { fill: var(--paper); }
.story .s-thick { stroke-width: 2.4; }
.story .s-draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
.story .s-soft { stroke: var(--rule-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.story .s-journey { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-dasharray: 6 8; vector-effect: non-scaling-stroke; opacity: 0; }
.story .s-q { font-family: var(--sans); fill: var(--ink-3); }
.story .s-quote { font-family: var(--sans); font-size: 21px; letter-spacing: -0.01em; fill: var(--ink); }
.story .s-label { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; fill: var(--ink-3); opacity: 0; }
.story .s-tail { stroke-linejoin: round; }
.story .s-pain { fill: var(--coral); opacity: 0; }
.story .s-details, .story .s-labels { opacity: 0; }
.story .s-labels text { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; fill: var(--ink-3); }
.story .s-dot { fill: none; stroke: var(--ink-3); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.story .s-dot--flag { fill: var(--coral); stroke: var(--coral); }
.story .s-btn { fill: var(--signal); opacity: 0; }
.story .s-btn-text { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; fill: #fff; opacity: 0; }
.story .s-tick { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; vector-effect: non-scaling-stroke; }
.story .s-tap { opacity: 0; }
.story .s-tap-dot { fill: var(--ink); }
.story .s-tap-ring { fill: none; stroke: var(--ink); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.story .story__side { opacity: 0; }

.story .s-head { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; fill: var(--ink-3); opacity: 0; }
.story .s-emotion { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; vector-effect: non-scaling-stroke; opacity: 0; }
.story .s-iterate { opacity: 0; }
.story .s-iterate .s-head { opacity: 1; }
.story .s-loop { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 1; stroke-dashoffset: 1; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.story .s-loop-head { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: 0; }

/* ==========================================================================
   v1.7 — Concept 3.0: Leaf theme + "Leaf & sky" sketches
   ========================================================================== */
/* Leaf theme tokens live in tokens.css */

/* Headline always fits its column (three lines) */
.untangle__text { container-type: inline-size; }
.hero__title { font-size: min(clamp(2.2rem, min(var(--step-4), (100svh - 36rem) / 3), var(--step-4)), 15.2cqi); }

/* Sketches: hidden unless the leaf theme is on */
.deco { display: none; position: absolute; pointer-events: none; overflow: visible; }
html[data-theme="leaf"] .deco { display: block; }
.deco path, .deco circle { fill: none; stroke: #9A9A9A; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.deco .is-soft { stroke: #C9C9C9; }
.deco .is-accent path, .deco path.is-accent { stroke: var(--coral); }
.deco .is-tip { fill: #9A9A9A; }

.untangle__sticky > .deco { z-index: 0; }
.untangle__text, .untangle__figure { position: relative; z-index: 1; }

.deco-pencil { left: calc(var(--gutter) - 186px); bottom: calc(var(--s-5) - 12px); width: 190px; will-change: transform; }


.contact__intro { position: relative; }
.deco-plane { position: relative; margin-top: var(--s-6); width: min(100%, 300px); }
.deco-plane path { stroke: #6F6F6F; }
.deco-plane .is-soft { stroke: #555; }
.deco-plane__trail { stroke-dasharray: 2 7 !important; }
.deco-plane__reveal { fill: none; stroke: #fff !important; stroke-width: 8 !important; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.6s var(--ease-in-out); }
.deco-plane__plane { opacity: 0; transform: translate(-24px, 14px); transition: opacity 0.5s ease 1.3s, transform 0.9s var(--ease-out) 1.3s; }
.deco-plane.is-in .deco-plane__reveal { stroke-dashoffset: 0; }
.deco-plane.is-in .deco-plane__plane { opacity: 1; transform: none; animation: deco-float 5s ease-in-out 2.4s infinite; }

@keyframes deco-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.untangle.is-static .deco-pencil { display: none; }
@media (max-width: 900px) {
  .deco-pencil { display: none !important; }
  }
@media (prefers-reduced-motion: reduce) {
  .deco { animation: none !important; }
  .deco-plane__reveal { stroke-dashoffset: 0; transition: none; }
  .deco-plane__plane { opacity: 1; transform: none; transition: none; }
}
