/* ============================================================
   Cortex Engineering: site extras (cortex-fx.js builds the markup)
   1. Station scroll tracker   2. Blueprint-to-photo design views
   3. Live design scenes       4. Plan-sheet mode
   Nothing here shows without JS, and motion stops for visitors
   who ask for reduced motion.
   ============================================================ */

:root { --fx-line: #F0793F; --fx-ink: #0E1D2C; }

/* ============ 1. STATION SCROLL TRACKER ============ */
.sta {
  position: fixed; right: 20px; top: 50%; z-index: 150;
  width: 24px; height: min(56vh, 520px);
  transform: translateY(-50%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s var(--ease);
  font-family: var(--font-display);
}
.sta.on { opacity: 1; pointer-events: auto; }
.sta::before {
  content: ""; position: absolute; inset: -18px -7px -54px;
  background: rgba(14,29,44,0.88);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 19px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}
/* Centerline linetype: long dash, short dash, as on a plan sheet. */
.sta-line {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: repeating-linear-gradient(to bottom,
    rgba(255,255,255,0.5) 0 14px, transparent 14px 18px,
    rgba(255,255,255,0.5) 18px 21px, transparent 21px 25px);
}
.sta-fill { position: absolute; left: 50%; top: 0; width: 2px; margin-left: -1px; height: 0; background: var(--fx-line); }
.sta-tick {
  position: absolute; left: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  display: block; color: #fff;
}
.sta-tick::before {
  content: ""; position: absolute; left: 5px; right: 5px; top: 11px; height: 2px;
  background: rgba(255,255,255,0.75);
  transition: background 0.2s var(--ease), left 0.2s var(--ease), right 0.2s var(--ease);
}
.sta-tick.past::before { background: var(--fx-line); }
.sta-tick:hover::before, .sta-tick:focus-visible::before { left: 1px; right: 1px; background: #fff; }
.sta-tick:focus-visible { outline: 2px solid #fff; outline-offset: 1px; border-radius: 3px; }
.sta-tick span, .sta-now {
  position: absolute; right: 36px; top: 50%;
  white-space: nowrap;
  background: rgba(14,29,44,0.94);
  border-left: 2px solid var(--fx-line);
  color: #fff;
  font-weight: 500; font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase;
  line-height: 1.5; padding: 5px 11px;
}
.sta-tick span {
  transform: translate(6px, -50%); opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.sta:hover .sta-tick span, .sta:focus-within .sta-tick span { opacity: 1; transform: translate(0, -50%); }
.sta-tick span b { font-weight: 400; color: rgba(255,255,255,0.72); margin-right: 9px; }
/* The moving "you are here" marker with a live station readout. */
.sta-now {
  top: 0; right: 36px; transform: translateY(-50%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
/* The readout chip rides along only while the page is moving, so it never
   parks on top of the copy. The dot and the reading under the rail stay. */
.sta.moving .sta-now { opacity: 1; }
.sta-now b { display: block; font-weight: 600; font-size: 0.78rem; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.sta-now i { display: block; font-style: normal; font-weight: 400; color: rgba(255,255,255,0.78); }
.sta-dot {
  position: absolute; left: 50%; top: 0;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: var(--fx-line); border: 2px solid #fff; border-radius: 50%;
  box-sizing: border-box; pointer-events: none;
}
.sta-read {
  position: absolute; left: -7px; right: -7px; bottom: -47px;
  text-align: center; color: #fff; line-height: 1.25;
  font-weight: 500; font-size: 0.6rem; letter-spacing: 0.03em; font-variant-numeric: tabular-nums;
  border-top: 1px solid rgba(255,255,255,0.2); padding-top: 6px;
}
.sta-read small { display: block; font-size: 0.56rem; font-weight: 400; letter-spacing: 0.18em; color: rgba(255,255,255,0.78); }
.sta:hover .sta-now, .sta:focus-within .sta-now { opacity: 0; }
/* Narrow screens: no rail, just a progress line across the top. */
.sta-bar { position: fixed; left: 0; top: 0; z-index: 210; height: 3px; width: 0; background: var(--fx-line); display: none; }
@media (max-width: 1339px) {
  .sta { display: none; }
  .sta-bar { display: block; }
}

/* ============ 2 + 3. DESIGN VIEWS OVER THE SERVICE PHOTOS ============ */
/* A real <button>: full-bleed blueprint that settles into a corner inset once
   the photo is revealed. Press it to bring the design view back. */
.bp {
  -webkit-appearance: none; appearance: none;
  position: absolute; top: 0; right: 0; width: 100%; height: 100%; z-index: 1;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  overflow: hidden; cursor: pointer; text-align: left;
  color: #fff; font: inherit;
  background-color: var(--fx-ink);
  background-image:
    linear-gradient(rgba(255,255,255,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.10) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  box-shadow: 0 0 0 0 rgba(255,255,255,0);
  transition: top 0.9s var(--ease-out), right 0.9s var(--ease-out), width 0.9s var(--ease-out),
    height 0.9s var(--ease-out), border-radius 0.9s var(--ease-out), box-shadow 0.9s var(--ease-out);
}
.bp:not(.full) {
  top: 22px; right: 22px; width: 36%; height: 36%;
  border-radius: 4px;
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.45), 0 16px 36px rgba(0,0,0,0.45);
}
.bp:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.bp:not(.full):hover { box-shadow: 0 0 0 2px var(--fx-line), 0 16px 36px rgba(0,0,0,0.45); }
.bp svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.bp-cap {
  position: absolute; left: 8px; bottom: 8px;
  font-family: var(--font-display); font-weight: 500; font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase; line-height: 1.4; white-space: nowrap;
  color: #fff; background: rgba(14,29,44,0.9);
  border-left: 2px solid var(--fx-line); padding: 4px 9px;
}
.bp.full .bp-cap { left: auto; right: 22px; bottom: 26px; font-size: 0.74rem; padding: 9px 15px; }
@media (max-width: 720px) { .bp:not(.full) { top: 14px; right: 14px; width: 44%; height: 40%; } }

/* ---- linework ---- */
.bp .sc { transition: opacity 0.45s var(--ease); }
.bp.out .sc { opacity: 0; }
.bp .ln { fill: none; stroke: var(--fx-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bp .ln2 { fill: none; stroke: rgba(255,255,255,0.6); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.bp .cl { fill: none; stroke: rgba(255,255,255,0.6); stroke-width: 1; stroke-dasharray: 14 4 3 4; }
.bp .dsh { stroke-dasharray: 5 5; }
.bp .grn { stroke: #7FCB8B; }
.bp .veh { fill: #fff; stroke: none; }
.bp .solid { fill: var(--fx-line); stroke: none; }
.bp .t {
  fill: rgba(255,255,255,0.86); stroke: none;
  font-family: var(--font-display); font-weight: 500; font-size: 11px; letter-spacing: 0.18em;
  transition: opacity 0.4s var(--ease);
}
.bp .t.big { font-size: 12.5px; fill: #fff; }
.bp:not(.full) .t { visibility: hidden; }
/* d = draws on, f = fades in, g = grows up from its base. --i staggers. */
.bp .d { stroke-dasharray: 1; stroke-dashoffset: 1; }
.bp .f { opacity: 0; }
.bp .g { transform: scaleY(0); transform-box: fill-box; transform-origin: 50% 100%; }
.bp.play .d { animation: bpDraw 1.1s var(--ease-out) calc(var(--i, 0) * 0.12s) forwards; }
.bp.play .f { animation: bpFade 0.6s var(--ease) calc(var(--i, 0) * 0.12s) forwards; }
.bp.play .g { animation: bpGrow 0.6s var(--ease-out) calc(var(--i, 0) * 0.12s) forwards; }
@keyframes bpDraw { to { stroke-dashoffset: 0; } }
@keyframes bpFade { to { opacity: 1; } }
@keyframes bpGrow { to { transform: scaleY(1); } }

/* ---- drainage: rain, rising water, hydrograph ---- */
.bp .water { fill: rgba(125,165,210,0.42); transform: translateY(40px); }
.bp.play .water { animation: bpRise 4.6s cubic-bezier(0.3, 0, 0.3, 1) 1.4s forwards; }
@keyframes bpRise { to { transform: translateY(0); } }
.bp .rain line { stroke: rgba(170,200,235,0.8); stroke-width: 1.3; stroke-linecap: round; opacity: 0; }
.bp.play .rain line { animation: bpRain 0.9s linear calc(0.6s + var(--i, 0) * 0.11s) 6; }
@keyframes bpRain { 0% { opacity: 0; transform: translate(6px, -22px); } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-6px, 22px); } }
.bp .hyd { stroke-width: 2.4; }
.bp.play .hyd { animation-duration: 4.4s; animation-timing-function: linear; }

/* ---- structures: truck crossing the finished deck ---- */
.bp .truck { opacity: 0; }
.bp.play .truck { animation: bpTruck 5.2s linear 4.4s forwards; }
@keyframes bpTruck { 0% { opacity: 1; transform: translateX(0); } 97% { opacity: 1; } 100% { opacity: 0; transform: translateX(900px); } }

@media (prefers-reduced-motion: reduce) {
  .bp, .bp .sc, .bp .t { transition: none; }
  .bp .d { stroke-dashoffset: 0; animation: none !important; }
  .bp .f { opacity: 1; animation: none !important; }
  .bp .g { transform: none; animation: none !important; }
  .bp .water { transform: none; animation: none !important; }
  .bp .rain line, .bp .truck { animation: none !important; }
}

/* ============ 4. PLAN-SHEET MODE ============ */
.sheet-btn {
  -webkit-appearance: none; appearance: none;
  position: fixed; left: 20px; bottom: 20px; z-index: 150;
  width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14,29,44,0.9); color: #fff;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.sheet-btn:hover { background: var(--orange-2); border-color: var(--orange-2); transform: rotate(-8deg); }
.sheet-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--navy); }
.sheet-btn[aria-pressed="true"] { background: var(--orange-2); border-color: #fff; }
.sheet-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.sheet-btn span {
  position: absolute; left: 54px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; pointer-events: none; opacity: 0;
  font-family: var(--font-display); font-weight: 500; font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: #fff; background: rgba(14,29,44,0.94); border-left: 2px solid var(--fx-line); padding: 6px 11px;
  transition: opacity 0.2s var(--ease);
}
.sheet-btn:hover span, .sheet-btn:focus-visible span { opacity: 1; }
@media (max-width: 720px) { .sheet-btn { display: none; } }

.sheet-frame, .sheet-tb { display: none; }
.sheet-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 220;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  font-family: var(--font-display); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: #fff; background: var(--navy-3); border-left: 3px solid var(--fx-line); padding: 13px 22px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.35);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.sheet-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Border that reads on light and dark sections alike. */
html.sheet .sheet-frame {
  display: block; position: fixed; inset: 10px; z-index: 190; pointer-events: none;
  border: 2px solid #fff; outline: 1px solid #fff; outline-offset: -8px;
  mix-blend-mode: difference;
}
/* Title block, bottom right, the way it sits on a plan sheet. */
html.sheet .sheet-tb {
  display: grid; grid-template-columns: 1fr 1fr;
  position: fixed; right: 26px; bottom: 26px; z-index: 191; width: 316px;
  background: var(--paper); color: var(--navy);
  border: 2px solid var(--navy);
  box-shadow: 0 14px 36px rgba(0,0,0,0.3);
  font-family: var(--font-display);
}
.sheet-tb div { padding: 7px 11px 8px; border-top: 1px solid var(--navy); min-width: 0; }
.sheet-tb div:nth-child(even) { border-right: 1px solid var(--navy); }
.sheet-tb .tb-firm { grid-column: 1 / -1; border-top: 0; border-right: 0 !important; padding: 10px 11px 10px; }
.sheet-tb .tb-firm b { display: block; font-weight: 600; font-size: 1.02rem; letter-spacing: 0.12em; text-transform: uppercase; line-height: 1.2; }
.sheet-tb .tb-firm i { display: block; font-style: normal; font-weight: 400; font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.sheet-tb small { display: block; font-size: 0.58rem; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); line-height: 1.4; }
.sheet-tb span { display: block; font-size: 0.86rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
@media (min-width: 1340px) { html.sheet .sheet-tb { right: 74px; } }
@media (max-width: 720px) { html.sheet .sheet-tb { right: 18px; bottom: 18px; width: 250px; } }

/* Grid paper under the light sections. */
html.sheet body {
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(20,40,60,0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,40,60,0.13) 1px, transparent 1px),
    linear-gradient(rgba(20,40,60,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,40,60,0.06) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
}
html.sheet .principles { background: transparent; }
html.sheet .pcard, html.sheet form.cform, html.sheet .cform-ok {
  background: rgba(255,255,255,0.78);
  border: 1px dashed rgba(20,40,60,0.5);
  border-top: 3px solid var(--orange);
  box-shadow: none;
}
html.sheet .svc-photo .ph { filter: grayscale(1) contrast(1.05); }
/* Every design view opens while the sheet is up. */
html.sheet .bp { top: 0; right: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none;
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px; }
html.sheet .bp .t { visibility: visible; }
html.sheet .bp .bp-cap { display: none; }

/* Sheet tab in the corner of each numbered section. */
html.sheet [data-sheet] { position: relative; }
html.sheet [data-sheet]::before {
  content: "Sheet " attr(data-sheet) " \00B7  " attr(data-screen-label);
  position: absolute; left: 30px; top: 26px;
  font-family: var(--font-display); font-weight: 500; font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--navy); background: var(--paper);
  border: 1px solid var(--navy); padding: 4px 11px;
}
html.sheet .sbe[data-sheet]::before { color: #fff; background: transparent; border-color: rgba(255,255,255,0.75); top: 18px; }

/* Dimension lines: measured live, one inch to the pixel. */
html.sheet .stat, html.sheet .prequal { position: relative; }
.dimw { display: none; }
html.sheet .dimw {
  display: block; position: absolute; left: 0; right: 0; top: -19px; height: 11px;
  border-left: 1px solid var(--orange-2); border-right: 1px solid var(--orange-2);
  pointer-events: none;
}
html.sheet .dimw::before { content: ""; position: absolute; left: 0; right: 0; top: 5px; border-top: 1px solid var(--orange-2); }
html.sheet .dimw i {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-style: normal; font-weight: 500; font-size: 0.66rem; letter-spacing: 0.14em;
  line-height: 1; white-space: nowrap; padding: 2px 8px;
  color: var(--navy); background: var(--paper);
}
html.sheet .stat .dimw, html.sheet .prequal .dimw { border-color: rgba(255,255,255,0.8); }
html.sheet .stat .dimw::before, html.sheet .prequal .dimw::before { border-color: rgba(255,255,255,0.8); }
html.sheet .stat .dimw i { color: #fff; background: var(--navy-3); }
html.sheet .prequal .dimw i { color: #fff; background: var(--green); }
html.sheet .stat .dimw { left: -2px; }
