/* =========================================================
   How We Work page (how-we-work.html)
   Builds on the co-* primitives in company.css; only hw-* lives here.
   company.js runs the chrome (nav, reveals, counters, data-brief);
   how-we-work.js runs the phase explorer and the two step animations.
   ========================================================= */

/* ---------- Hero: change pipeline card ---------- */
.hw-run {
  position: relative; margin: 0; width: 100%; max-width: 480px; justify-self: center;
  border-radius: 24px; border: 1px solid var(--line-2); background: var(--panel), rgba(11, 16, 29, 0.92);
  box-shadow: 0 40px 90px -50px rgba(124, 156, 255, 0.55); overflow: hidden;
}
.hw-run__bar {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); font: 500 12px var(--font-mono); color: var(--dim);
}
.hw-run__dots { display: inline-flex; gap: 6px; }
.hw-run__dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); }
.hw-run__file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #C9D1E6; }
.hw-run__live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); }
.hw-run__live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: ping 2s ease-out infinite; }

.hw-run__list { list-style: none; margin: 0; padding: 10px; display: grid; gap: 4px; counter-reset: run; }
.hw-run__list li {
  position: relative; display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 14px;
  padding: 13px 14px; border-radius: 14px; border: 1px solid transparent;
  transition: background 0.45s, border-color 0.45s, opacity 0.45s;
}
.hw-run__list li + li::before {
  content: ""; position: absolute; left: 50px; top: -6px; width: 1px; height: 8px; background: var(--line-2);
}
.hw-run__list b { display: block; font: 600 15.5px var(--font-display); letter-spacing: -0.01em; color: #fff; }
.hw-run__list small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.hw-run__who {
  justify-self: start; padding: 5px 9px; border-radius: 8px;
  font: 600 11px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.hw-run__who--you { color: var(--gold); background: rgba(255, 200, 87, 0.12); }
.hw-run__who--lead { color: #A9BBFF; background: rgba(124, 156, 255, 0.14); }
.hw-run__who--ai { color: #D0C2FF; background: rgba(177, 151, 252, 0.16); }
.hw-run__cap { margin: 0; padding: 14px 20px 18px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.55; color: var(--dim); }

/* Animated state (JS adds .is-anim): upcoming rows dim, current row lit */
.hw-run.is-anim li { opacity: 0.42; }
.hw-run.is-anim li.is-done { opacity: 0.85; }
.hw-run.is-anim li.is-on { opacity: 1; background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 200, 87, 0.4); }
.hw-run.is-anim li.is-done::after,
.hw-run.is-anim li.is-on::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
}
.hw-run.is-anim li.is-done::after {
  background: rgba(61, 220, 151, 0.16) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233DDC97' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 10px no-repeat;
}
.hw-run.is-anim li.is-on::after { border: 2px solid rgba(255, 200, 87, 0.35); border-top-color: var(--gold); animation: hwSpin 0.9s linear infinite; }
@keyframes hwSpin { to { transform: rotate(360deg); } }

/* ---------- Principles ---------- */
.hw-prin__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.hw-card {
  position: relative; display: flex; flex-direction: column; padding: 28px 24px 30px; border-radius: 24px;
  border: 1px solid var(--line-2); background: var(--bg); transition: border-color 0.3s, transform 0.3s var(--ease);
}
.hw-card:hover { border-color: rgba(255, 200, 87, 0.4); transform: translateY(-3px); }
.hw-card__n { position: absolute; top: 26px; right: 24px; font: 500 12px var(--font-mono); color: var(--dim); }
.hw-card__icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: rgba(255, 200, 87, 0.12); margin-bottom: 26px; }
.hw-card__icon svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hw-card h3 { margin: 0 0 10px; font: 600 1.22rem/1.25 var(--font-display); letter-spacing: -0.02em; }
.hw-card p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--muted); }

/* ---------- Process: phase explorer ----------
   Without JS every phase is listed. how-we-work.js adds .is-tabs to switch to tabs. */
.hw-phases__tabs { display: none; }
.hw-phases__panels { display: grid; gap: 16px; }
.hw-phases.is-tabs { display: grid; grid-template-columns: minmax(0, 0.42fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.hw-phases.is-tabs .hw-phases__tabs { display: grid; gap: 6px; position: sticky; top: calc(var(--nav-h) + 24px); }
.hw-phases.is-tabs .hw-phase:not(.is-active) { display: none; }

.hw-phases__tabs button {
  position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 2px 12px; align-items: center;
  padding: 16px 18px; border-radius: 16px; border: 1px solid transparent; background: none; color: var(--muted);
  text-align: left; cursor: pointer; transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.hw-phases__tabs button:hover { color: #fff; background: rgba(255, 255, 255, 0.03); }
.hw-phases__tabs button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hw-phases__tabs button[aria-selected="true"] { color: #fff; background: var(--bg-2); border-color: rgba(255, 200, 87, 0.45); }
.hw-tab__n {
  grid-row: 1 / 3; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line-2); font: 600 12px var(--font-mono); color: var(--dim); transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.hw-phases__tabs button[aria-selected="true"] .hw-tab__n { background: var(--gold-grad); border-color: transparent; color: #1B1305; }
.hw-phases__tabs button.is-past .hw-tab__n { border-color: rgba(255, 200, 87, 0.5); color: var(--gold); }
.hw-tab__t { font: 600 1.05rem var(--font-display); letter-spacing: -0.01em; }
.hw-tab__w { font: 500 11.5px var(--font-mono); color: var(--agent); }
/* rail joining the numbers */
.hw-phases__tabs button + button::before {
  content: ""; position: absolute; left: 35px; top: -9px; width: 1px; height: 12px; background: var(--line-2);
}

.hw-phase {
  padding: clamp(26px, 3.5vw, 44px); border-radius: 28px; border: 1px solid var(--line-2);
  background: radial-gradient(90% 60% at 100% 0%, rgba(124, 156, 255, 0.08), transparent 60%), var(--bg-2);
}
.hw-phases.is-tabs .hw-phase.is-active { animation: hwIn 0.45s var(--ease); }
@keyframes hwIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hw-phase__head { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.hw-phase__n { font: 600 clamp(2.6rem, 5vw, 4rem)/1 var(--font-display); letter-spacing: -0.05em; color: transparent; -webkit-text-stroke: 1px rgba(255, 200, 87, 0.6); }
.hw-phase__w { margin: 0 0 4px; font: 500 12px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--agent); }
.hw-phase h3 { margin: 0; font: 600 clamp(1.6rem, 2.6vw, 2.2rem) var(--font-display); letter-spacing: -0.03em; }
.hw-phase__lede { margin: 0 0 28px; max-width: 40em; font-size: clamp(1rem, 1.2vw, 1.12rem); line-height: 1.65; color: #C9D1E6; }
.hw-phase__grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hw-phase__grid > div { padding: 18px 20px; border-radius: 18px; border: 1px solid var(--line); background: rgba(7, 11, 20, 0.55); }
.hw-phase__grid dt { margin-bottom: 6px; font: 500 11.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.hw-phase__grid dd { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--muted); }

/* ---------- Workflow: ticket to merge ---------- */
.hw-flow {
  position: relative; display: grid; grid-template-columns: 1fr 1fr 1.45fr 1fr 1.1fr 1fr 1fr; gap: 26px;
  align-items: stretch; padding: 34px 28px 58px; border-radius: 28px; border: 1px solid var(--line-2); background: var(--bg);
}
.hw-flow > * {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 14px; border-radius: 16px;
  border: 1px solid var(--line-2); background: var(--bg-2); transition: border-color 0.4s, box-shadow 0.4s, background 0.4s;
}
/* arrow to the next step */
.hw-flow > *:not(:last-child)::after {
  content: ""; position: absolute; right: -22px; top: 50%; width: 18px; height: 10px; margin-top: -5px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 10' fill='none' stroke='%237C9CFF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 5h15M12 1l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.7;
}
.hw-flow b { font: 600 1.12rem var(--font-display); letter-spacing: -0.015em; color: #fff; }
.hw-flow small { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.hw-flow__tag {
  align-self: flex-start; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.05);
  font: 500 10.5px var(--font-mono); letter-spacing: 0.04em; color: var(--dim);
}
.hw-flow__tag--lead { color: #A9BBFF; background: rgba(124, 156, 255, 0.14); }
.hw-flow__tag--ai { color: #D0C2FF; background: rgba(177, 151, 252, 0.16); }
.hw-flow__tag--you { color: var(--gold); background: rgba(255, 200, 87, 0.12); }
.hw-flow__group { border-style: dashed; border-color: rgba(177, 151, 252, 0.45); background: rgba(177, 151, 252, 0.05); }
.hw-flow__lanes { display: grid; gap: 6px; margin-top: 4px; }
.hw-flow__lanes span {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px;
  background: rgba(7, 11, 20, 0.6); border: 1px solid var(--line); font-size: 13px; color: #C9D1E6;
}
.hw-flow__lanes i { width: 7px; height: 7px; border-radius: 50%; background: var(--agent-2); flex: none; }
.hw-flow__step--gate { border-color: rgba(255, 200, 87, 0.5); background: linear-gradient(160deg, rgba(255, 200, 87, 0.1), transparent 70%), var(--bg-2); }
.hw-flow__loop {
  position: absolute; left: 50%; bottom: -38px; transform: translateX(-50%); white-space: nowrap;
  font: 500 11px var(--font-mono); color: var(--dim);
}
.hw-flow__loop::before { content: "\21BA  "; color: var(--gold); }

/* animated state: the current step glows (JS adds .is-anim and .is-on) */
.hw-flow.is-anim > .is-on { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255, 200, 87, 0.12), 0 18px 40px -24px rgba(255, 170, 60, 0.7); }
.hw-flow.is-anim > .is-on .hw-flow__lanes i { animation: hwBlink 0.9s ease-in-out infinite alternate; }
.hw-flow.is-anim > .is-on .hw-flow__lanes span:nth-child(2) i { animation-delay: 0.3s; }
.hw-flow.is-anim > .is-on .hw-flow__lanes span:nth-child(3) i { animation-delay: 0.6s; }
@keyframes hwBlink { from { opacity: 0.3; } to { opacity: 1; box-shadow: 0 0 8px var(--agent-2); } }

.hw-flow__notes { list-style: none; margin: 28px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.hw-flow__notes li { padding: 20px 22px; border-radius: 18px; border: 1px solid var(--line); font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.hw-flow__notes b { display: block; margin-bottom: 4px; color: #fff; font: 600 1.02rem var(--font-display); }

/* ---------- Engagement models ---------- */
.hw-models__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.hw-model {
  position: relative; display: flex; flex-direction: column; padding: 32px 28px; border-radius: 26px;
  border: 1px solid var(--line-2); background: var(--bg-2); transition: border-color 0.3s, transform 0.3s var(--ease);
}
.hw-model:hover { border-color: rgba(255, 200, 87, 0.4); transform: translateY(-3px); }
.hw-model--hot {
  border-color: rgba(255, 200, 87, 0.55);
  background: radial-gradient(120% 70% at 100% 0%, rgba(255, 200, 87, 0.1), transparent 60%), var(--bg-2);
  box-shadow: 0 30px 70px -40px rgba(255, 170, 60, 0.55);
}
.hw-model__badge {
  position: absolute; top: 26px; right: 24px; padding: 5px 10px; border-radius: 999px;
  background: var(--gold-grad); color: #1B1305; font: 600 11px var(--font-body); letter-spacing: 0.02em;
}
.hw-model__k { margin: 0 0 22px; font: 500 12px var(--font-mono); color: var(--dim); }
.hw-model h3 { margin: 0 0 12px; font: 600 clamp(1.35rem, 2vw, 1.7rem) var(--font-display); letter-spacing: -0.025em; }
.hw-model__best { margin: 0; color: #C9D1E6; line-height: 1.55; }
.hw-model__best b, .hw-model__get b { display: block; margin-bottom: 4px; font: 500 11.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.hw-model__h { margin: 24px 0 0; font: 500 11.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.hw-model .co-ticks { margin-top: 12px; }
.hw-model__get { margin: 22px 0 28px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.hw-model .btn-ghost, .hw-model .cta { margin-top: auto; align-self: flex-start; }

/* ---------- Rhythm + quality gates ---------- */
.hw-rhythm__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(40px, 6vw, 96px); align-items: start; }
.hw-h2--sm { font-size: clamp(1.7rem, 3vw, 2.5rem); }
.hw-cadence, .hw-gates { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 10px; }
.hw-cadence li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 16px; padding: 18px 20px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--bg); }
.hw-cadence__when { font: 500 12px var(--font-mono); color: var(--agent); padding-top: 3px; }
.hw-cadence b, .hw-gates b { font: 600 1.05rem var(--font-display); color: #fff; }
.hw-cadence p, .hw-gates p { margin: 4px 0 0; font-size: 14px; line-height: 1.55; color: var(--muted); }
.hw-rhythm .co-link { margin-top: 24px; }

.hw-gates { counter-reset: gate; position: relative; }
.hw-gates::before { content: ""; position: absolute; left: 19px; top: 24px; bottom: 24px; width: 1px; background: linear-gradient(var(--gold), var(--line-2)); }
.hw-gates li { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; padding: 10px 0; }
.hw-gates__n {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-2); border: 1px solid rgba(255, 200, 87, 0.55); color: var(--gold); font: 600 13px var(--font-mono);
}
.hw-gates li:nth-child(4) .hw-gates__n { background: var(--gold-grad); color: #1B1305; border-color: transparent; }
.hw-gates__foot { margin: 26px 0 0; padding: 20px 22px; border-radius: 18px; border: 1px solid var(--line); font-size: 14.5px; line-height: 1.65; color: var(--muted); }

/* ---------- Flexibility ---------- */
.hw-flex { padding-top: clamp(48px, 5.5vw, 76px); padding-bottom: clamp(48px, 5.5vw, 76px); }
.hw-scale { margin-top: 0; }
.hw-scale__title { margin: 0 0 10px; font: 600 clamp(1.5rem, 2.6vw, 2.1rem) var(--font-display); letter-spacing: -0.03em; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .hw-prin__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* workflow becomes a vertical list with down arrows */
  .hw-flow { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 24px; max-width: 560px; margin-inline: auto; }
  .hw-flow > *:not(:last-child)::after { right: auto; left: 50%; top: auto; bottom: -18px; margin: 0 0 0 -5px; width: 10px; height: 14px; transform: rotate(90deg); transform-origin: center; }
  .hw-flow > * { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 2px 14px; align-items: center; }
  .hw-flow__tag { grid-row: 1 / 3; align-self: center; }
  .hw-flow__lanes { grid-column: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hw-flow__lanes span { font-size: 12px; padding: 6px 8px; }
  .hw-flow__loop { position: static; transform: none; grid-column: 2; }
  .hw-flow__notes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .hw-phases.is-tabs { grid-template-columns: minmax(0, 1fr); }
  .hw-phases.is-tabs .hw-phases__tabs {
    position: static; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
    margin-inline: -16px; padding: 2px 16px 6px; scrollbar-width: none;
  }
  .hw-phases__tabs::-webkit-scrollbar { display: none; }
  .hw-phases__tabs button { flex: none; scroll-snap-align: start; border-color: var(--line-2); padding: 12px 14px; }
  .hw-phases__tabs button + button::before { display: none; }
  .hw-models__grid, .hw-rhythm__grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hw-prin__grid, .hw-phase__grid { grid-template-columns: minmax(0, 1fr); }
  .hw-run__list li { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; padding: 12px 10px; }
  .hw-run__list li + li::before { left: 40px; }
  .hw-run.is-anim li.is-done::after, .hw-run.is-anim li.is-on::after { right: 10px; }
  .hw-flow > * { grid-template-columns: minmax(0, 1fr); }
  .hw-flow__tag { grid-row: auto; align-self: flex-start; justify-self: start; }
  .hw-flow__lanes, .hw-flow__loop { grid-column: auto; }
  .hw-cadence li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .hw-phase__head { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .hw-run.is-anim li.is-on::after, .hw-flow.is-anim > .is-on .hw-flow__lanes i, .hw-run__live::before { animation: none; }
  .hw-phases.is-tabs .hw-phase.is-active { animation: none; }
}
