/* ============================================================
   SCREEN SYNC — /how-it-works
   Same system as the homepage: charcoal/beige sections, cherry
   accents, pixel-outlined panels, Silkscreen pixel titles in the
   red gradient. Loaded after styles.css.
   ============================================================ */

/* pixel outline: 4px border with notched corners + hard drop shadow */
.px {
  --o: #1d1b19;
  box-shadow:
    0 -4px 0 0 var(--o), 0 4px 0 0 var(--o),
    -4px 0 0 0 var(--o), 4px 0 0 0 var(--o),
    8px 10px 0 0 rgba(29, 27, 25, 0.16);
}
.section--charcoal .px {
  --o: #3a352f;
  box-shadow:
    0 -4px 0 0 var(--o), 0 4px 0 0 var(--o),
    -4px 0 0 0 var(--o), 4px 0 0 0 var(--o),
    8px 10px 0 0 rgba(0, 0, 0, 0.35);
}

/* pixel title in the red gradient (same as the hero word + homepage devices) */
.hiw-pixtitle {
  font-family: "Silkscreen", var(--font-mono);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #ff7a8c 0%, #e0435d 50%, #9e1f37 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.hiw-lead {
  max-width: 62ch;
  margin: -0.4rem 0 3rem;
  color: var(--beige-dim);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
}
.hiw-lead--dark { color: #5b544a; }

/* the page now opens on the big picture, so its heading is the page h1 */
.hiw-system { padding-top: calc(var(--section-pad) + 2rem); }
.hiw-h1 { font-size: clamp(2.4rem, 5.6vw, 4.4rem); }

/* ---------- system layers ---------- */
.hiw-scrolly { position: relative; max-width: 940px; padding-left: 40px; }
.hiw-layers { list-style: none; display: grid; gap: 0; }
.hiw-layer {
  position: relative;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.6rem;
  padding: 1.6rem 1.4rem;
  border: 1px solid rgba(234, 227, 211, 0.12);
  border-radius: 12px;
  background-color: rgba(234, 227, 211, 0.03);
}
.hiw-layer + .hiw-layer { margin-top: 2.4rem; }
.hiw-layer + .hiw-layer::before {     /* pixel connector between layers */
  content: "";
  position: absolute;
  left: 60px; top: calc(-2.4rem - 1px);
  width: 4px; height: 2.4rem;
  background: repeating-linear-gradient(180deg, var(--cherry-bright) 0 4px, transparent 4px 8px);
}
.hiw-layer--chain { border-color: rgba(194, 58, 82, 0.55); background-color: rgba(142, 31, 51, 0.12); box-shadow: 0 0 40px rgba(142, 31, 51, 0.2); }
.hiw-layer__tag {
  align-self: start;
  justify-self: start;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: rgba(234, 227, 211, 0.08);
  color: var(--beige);
  font-family: "Silkscreen", var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}
.hiw-layer--chain .hiw-layer__tag { background: var(--cherry); color: #fff; }
.hiw-layer h3 { margin-bottom: 0.35rem; font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.hiw-layer p { color: var(--beige-dim); font-size: 0.98rem; }
.hiw-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.hiw-chips span {
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(234, 227, 211, 0.16);
  border-radius: 6px;
  color: var(--beige-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ---------- scroll-lit layers (enabled by hiw.js adding .is-scrolly) ----------
   Layers start dimmed and light up one by one as the reader scrolls past them;
   a red progress rail fills alongside. Scrolling back up dims them again. */
.hiw-rail {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(180deg, rgba(234, 227, 211, 0.16) 0 4px, transparent 4px 8px);
}
.hiw-rail i {
  position: absolute;
  left: 0; top: 0;
  width: 4px; height: 0;
  background: linear-gradient(180deg, #ff7a8c, #e0435d 50%, #9e1f37);
  box-shadow: 0 0 12px rgba(224, 67, 93, 0.7);
}
.hiw-rail i::after {                  /* glowing pixel at the tip of the progress */
  content: "";
  position: absolute;
  left: -4px; bottom: -6px;
  width: 12px; height: 12px;
  background: #ff7a8c;
  box-shadow: 0 0 14px rgba(255, 122, 140, 0.9);
}
.hiw-scrolly:not(.is-scrolly) .hiw-rail { display: none; }

.is-scrolly .hiw-layer {
  opacity: 0.3;
  filter: grayscale(0.75);
  border-color: rgba(234, 227, 211, 0.1);
  background-color: rgba(234, 227, 211, 0.02);
  box-shadow: none;
  transition: opacity 0.45s ease, filter 0.45s ease, border-color 0.45s ease,
              background-color 0.45s ease, box-shadow 0.45s ease, transform 0.45s var(--ease-out);
}
.is-scrolly .hiw-layer .hiw-layer__tag { background: rgba(234, 227, 211, 0.08); color: var(--beige); transition: background 0.45s, color 0.45s; }
.is-scrolly .hiw-layer + .hiw-layer::before {
  background: repeating-linear-gradient(180deg, rgba(234, 227, 211, 0.2) 0 4px, transparent 4px 8px);
  transition: box-shadow 0.45s;
}
.is-scrolly .hiw-layer.is-lit {
  opacity: 1;
  filter: none;
  border-color: rgba(194, 58, 82, 0.55);
  background-color: rgba(142, 31, 51, 0.12);
  box-shadow: 0 0 40px rgba(142, 31, 51, 0.18);
}
.is-scrolly .hiw-layer.is-lit .hiw-layer__tag { background: var(--cherry); color: #fff; }
.is-scrolly .hiw-layer.is-lit + .hiw-layer.is-lit::before,
.is-scrolly .hiw-layer + .hiw-layer.is-lit::before {
  background: var(--cherry-bright);
  box-shadow: 0 0 10px rgba(224, 67, 93, 0.7);
}
.is-scrolly .hiw-layer.is-current {
  transform: translateX(10px);
  box-shadow: 0 0 60px rgba(194, 58, 82, 0.3);
}
.is-scrolly .hiw-layer.is-lit::after {   /* one-shot light sweep as a layer powers on */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 122, 140, 0.16) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%;
  animation: hiwSweep 0.9s ease-out both;
}
@keyframes hiwSweep {
  from { background-position: 120% 0; opacity: 1; }
  to   { background-position: -40% 0; opacity: 0; }
}

/* ---------- escrow flow ---------- */
.hiw-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px minmax(0, 1fr) 90px minmax(0, 1fr);
  align-items: center;
  margin: 1rem 0 3rem;
}
.hiw-node {
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 1.3rem 1.2rem;
  background: #2f2b27;
  color: var(--beige);
}
.hiw-node--vault { background: var(--cherry-deep); }
.hiw-node__k { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.14em; color: var(--cherry-bright); }
.hiw-node--vault .hiw-node__k { color: #ff9aa9; }
.hiw-node b { font-family: "Silkscreen", var(--font-mono); font-size: 1.1rem; font-weight: 700; }
.hiw-node small { color: #cfc6b2; font-size: 0.84rem; line-height: 1.4; }
.hiw-track {
  position: relative;
  height: 4px;
  margin: 0 10px;
  background: repeating-linear-gradient(90deg, var(--charcoal) 0 6px, transparent 6px 10px);
}
.hiw-coin {                            /* a pixel coin that hops along the track */
  position: absolute;
  top: -10px; left: 0;
  width: 12px; height: 12px;
  background: #ffcf5a;
  box-shadow: inset -3px -3px 0 #d99a1e, 0 0 0 2px var(--charcoal);
  animation: hiwCoin 3.2s steps(10, end) infinite;
}
.hiw-coin--late { animation-delay: 1.6s; }
@keyframes hiwCoin {
  0%   { left: 0; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: calc(100% - 12px); opacity: 0; }
}
.hiw-rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; }
.hiw-rule {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 1.1rem 1.2rem;
  border-left: 4px solid var(--cherry);
  background: rgba(29, 27, 25, 0.05);
}
.hiw-rule b { font-family: var(--font-display); font-size: 1.05rem; }
.hiw-rule span { color: #5b544a; font-size: 0.94rem; }

/* ---------- trust split ---------- */
.hiw-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
.hiw-panel { padding: 1.7rem 1.6rem; background: #151311; }
.hiw-panel--on { background: #200d12; }
.hiw-panel ul { list-style: none; margin-top: 1rem; }
.hiw-panel li { display: flex; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px dashed rgba(234, 227, 211, 0.12); color: #d9d0bd; font-size: 0.95rem; }
.hiw-panel li:last-child { border-bottom: none; }
.hiw-panel li::before { content: "▸"; color: var(--cherry-bright); }

/* ---------- day ledger ---------- */
.hiw-ledger__inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3.5rem; align-items: center; }
.hiw-bitwrap { position: relative; padding: 1.6rem; background: #1d1b19; color: var(--beige); }
.hiw-bitwrap::after {                 /* faint CRT scanlines */
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px);
}
.hiw-bitwrap__head { margin-bottom: 1rem; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; color: var(--beige-dim); }
.hiw-week { display: grid; grid-template-columns: 34px repeat(8, minmax(0, 1fr)); gap: 6px; align-items: center; }
.hiw-week .d { font-family: var(--font-mono); font-size: 0.66rem; color: var(--beige-dim); }
.hiw-week .b { aspect-ratio: 1; background: #3a352f; }
.hiw-week .b.on { background: linear-gradient(135deg, #ff7a8c, #e0435d 50%, #9e1f37); box-shadow: 0 0 10px rgba(224, 67, 93, 0.45); }
.hiw-week .byte { grid-column: 2 / -1; margin-top: -2px; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.3em; color: #6f6759; }
.hiw-bitwrap__legend { display: flex; gap: 1.4rem; margin-top: 1rem; font-family: var(--font-mono); font-size: 0.7rem; color: var(--beige-dim); }
.hiw-bitwrap__legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.hiw-bitwrap__legend i { width: 11px; height: 11px; background: #3a352f; }
.hiw-bitwrap__legend i.on { background: #e0435d; }

/* ---------- roadmap + stack (charcoal) ---------- */
.hiw-phases { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2rem; margin: 2.4rem 0 2.6rem; }
.hiw-phases li { position: relative; padding: 1.2rem 1.1rem; border-top: 4px solid rgba(234, 227, 211, 0.14); }
.hiw-phases li.is-now { border-top-color: var(--cherry-bright); box-shadow: 0 -10px 24px -14px rgba(224, 67, 93, 0.8); }
.hiw-phases span { display: block; margin-bottom: 0.4rem; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.14em; color: var(--cherry-bright); }
.hiw-phases b { display: block; margin-bottom: 0.3rem; font-family: var(--font-display); font-size: 1.1rem; }
.hiw-phases p { color: var(--beige-dim); font-size: 0.92rem; }
.hiw-stack { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.hiw-stack span { padding: 0.55rem 1rem; border: 1px solid rgba(234, 227, 211, 0.16); border-radius: 999px; background: rgba(234, 227, 211, 0.04); color: var(--beige-dim); font-size: 0.9rem; }
.hiw-stack b { color: var(--cherry-bright); }

/* roadmap and CTA are both charcoal now — a hairline keeps them distinct */
.hiw-road + .cta { border-top: 1px solid rgba(234, 227, 211, 0.08); }
.hiw-cta { justify-content: center; margin-bottom: 0; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hiw-ledger__inner, .hiw-split { grid-template-columns: 1fr; }
  .hiw-phases { grid-template-columns: 1fr 1fr; }
  .hiw-flow { grid-template-columns: 1fr; gap: 0; }
  .hiw-track { width: 4px; height: 56px; margin: 0 auto; background: repeating-linear-gradient(180deg, var(--charcoal) 0 6px, transparent 6px 10px); }
  .hiw-coin { left: -4px; top: 0; animation-name: hiwCoinDown; }
  .hiw-rules { grid-template-columns: 1fr; }
}
@keyframes hiwCoinDown {
  0%   { top: 0; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 12px); opacity: 0; }
}
@media (max-width: 640px) {
  .hiw-phases { grid-template-columns: 1fr; }
  .hiw-scrolly { padding-left: 22px; }
  .hiw-layer { grid-template-columns: 1fr; gap: 0.8rem; }
  .hiw-layer + .hiw-layer::before { left: 30px; }
  .is-scrolly .hiw-layer.is-current { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .hiw-coin { animation: none; opacity: 0; }
  .is-scrolly .hiw-layer.is-lit::after { animation: none; display: none; }
  .is-scrolly .hiw-layer.is-current { transform: none; }
}
