/* ============================================================
   ChicaneFlow — Installation Guide
   Extends the Telemetry Noir design system (style.css)
   ============================================================ */

/* --- Page Head --- */
.page-head {
  padding: calc(var(--nav-height) + 5rem) 2rem 3.5rem;
  position: relative;
  overflow: hidden;
  border-bottom: var(--border-subtle);
}

.page-head::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 80% at 30% 50%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 30% 50%, black 20%, transparent 75%);
}

.page-head-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  position: relative;
}

.page-head h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  margin-bottom: 1rem;
}

.page-head h1 .accent {
  color: var(--cyan);
  text-shadow: 0 0 24px var(--cyan-glow);
}

.page-intro {
  max-width: 60ch;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Breadcrumb */
.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--cyan);
}

.breadcrumb-sep {
  opacity: 0.5;
}

/* --- Safety Banner --- */
.safety-banner {
  max-width: var(--content-max);
  margin: 2.5rem auto 0;
  padding: 1.1rem 1.4rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--amber-dim);
  border: 1px solid var(--amber-glow);
  border-radius: var(--radius-md);
}

.safety-banner svg {
  flex-shrink: 0;
  color: var(--amber);
  margin-top: 2px;
}

.safety-banner-body h4 {
  font-size: 0.85rem;
  color: var(--amber);
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.safety-banner-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* --- Version Tabs --- */
.version-switch {
  position: sticky;
  top: var(--nav-height);
  z-index: 900;
  background: rgba(6, 6, 12, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--border-subtle);
}

.version-switch-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.version-switch-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.version-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.version-tab {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.25s ease;
}

.version-tab:hover {
  color: var(--cyan);
  border-color: var(--cyan-glow);
}

.version-tab[aria-selected="true"] {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.12);
}

.version-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.version-tab[aria-selected="true"] .version-tab-dot {
  opacity: 1;
  box-shadow: 0 0 8px var(--cyan);
}

/* --- Install Panel --- */
.install-panel {
  padding: 4rem 2rem 6rem;
}

.install-panel[hidden] {
  display: none;
}

.install-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Panel summary strip */
.panel-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: rgba(255, 255, 255, 0.06);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 3rem;
}

.summary-cell {
  background: var(--bg-surface);
  padding: 1.25rem 1.4rem;
}

.summary-cell-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.summary-cell-value {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.summary-cell-value.is-cyan {
  color: var(--cyan);
}

/* --- Steps --- */
.steps {
  list-style: none;
  position: relative;
}

/* Vertical rail linking the step markers */
.steps::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: linear-gradient(
    180deg,
    var(--cyan-glow),
    rgba(0, 229, 255, 0.1) 60%,
    transparent
  );
}

.step {
  position: relative;
  padding-left: 4.5rem;
  padding-bottom: 3.5rem;
}

.step:last-child {
  padding-bottom: 0;
}

.step-num {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cyan);
  background: var(--bg-deep);
  border: 1px solid var(--cyan-glow);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.step-head {
  margin-bottom: 1rem;
}

.step h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  padding-top: 0.4rem;
}

.step-body p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1rem;
  max-width: 68ch;
}

.step-body p strong {
  color: var(--text-primary);
  font-weight: 600;
}

.step-body p .hl {
  color: var(--cyan);
  font-weight: 600;
}

.step-list {
  list-style: none;
  margin: 0 0 1.25rem;
  max-width: 68ch;
}

.step-list li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.7;
}

.step-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  background: var(--cyan);
  transform: rotate(45deg);
  opacity: 0.8;
}

/* --- Photo Slots --- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.photo-grid--single {
  grid-template-columns: minmax(0, 620px);
}

.photo-slot {
  /* Slots crop to 4:3 by default; override per-slot so a portrait or
     letterbox shot isn't cropped to pieces. The placeholder reads the
     same variable, so an empty slot reserves the real photo's shape. */
  --slot-ratio: 4 / 3;
  margin: 0;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  border: var(--border-subtle);
}

.photo-slot--tall { --slot-ratio: 3 / 4; }
.photo-slot--wide { --slot-ratio: 3 / 2; }
.photo-slot--16x9 { --slot-ratio: 16 / 9; }
.photo-slot--portrait { --slot-ratio: 9 / 16; }
.photo-slot--square { --slot-ratio: 1 / 1; }

/* Phone screenshots: show at the capture's native aspect ratio so nothing
   is cropped top/bottom, keep a phone-like width centered in the column,
   and drop the hover zoom (it would magnify over neighbouring content). */
.photo-slot--phone {
  --slot-ratio: 9 / 16;      /* placeholder still reserves a portrait shape */
  max-width: 400px;
  justify-self: center;
}
.photo-slot--phone img {
  aspect-ratio: auto;
  object-fit: contain;
}
.photo-slot--phone.has-photo:hover img {
  transform: none;
}

.photo-slot img {
  display: block;
  width: 100%;
  aspect-ratio: var(--slot-ratio);
  object-fit: cover;
  background: var(--bg-surface);
  transition: transform 0.5s var(--ease-out-expo);
}

.photo-slot.has-photo:hover img {
  transform: scale(1.03);
}

.photo-slot figcaption {
  padding: 0.7rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-secondary);
  border-top: var(--border-subtle);
  background: var(--bg-deep);
}

/* Placeholder covers the image box until a real photo exists at the img's
   src. It is the default state: js/install.js adds .has-photo only once the
   image actually loads, so a missing photo (or no JS at all) still reads as
   a deliberate empty slot rather than a broken image.
   Sized by aspect-ratio rather than inset:0 so it matches the image box
   exactly and leaves the figcaption below it untouched. */
.photo-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: var(--slot-ratio);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.015) 10px,
      rgba(255, 255, 255, 0.015) 20px
    );
  border: 1px dashed rgba(0, 229, 255, 0.25);
}

.photo-slot.has-photo .photo-placeholder {
  display: none;
}

.photo-placeholder svg {
  color: var(--cyan);
  opacity: 0.4;
}

.photo-placeholder-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--cyan);
  opacity: 0.7;
}

.photo-placeholder-path {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* --- Wiring Table --- */
.wire-table-wrap {
  max-width: 68ch;
  margin: 1.25rem 0;
  overflow-x: auto;
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.wire-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 420px;
}

.wire-table th {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-align: left;
  padding: 0.7rem 0.9rem;
  background: var(--bg-elevated);
  border-bottom: var(--border-subtle);
  white-space: nowrap;
}

.wire-table td {
  padding: 0.7rem 0.9rem;
  border-bottom: var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.wire-table tbody tr:last-child td {
  border-bottom: none;
}

/* Group separator between the two harness triples */
.wire-table tr.wire-group-start td {
  border-top: 1px solid var(--cyan-glow);
}

.wire-table .wire-group {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  white-space: nowrap;
}

.wire {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.wire-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.wire-dot--red { background: #e53935; }
.wire-dot--green { background: #43a047; }
.wire-dot--yellow { background: #fdd835; }
.wire-dot--brown { background: #6d4c41; }
.wire-dot--blue { background: #1e88e5; }
.wire-dot--white { background: #f5f5f5; }
.wire-dot--black { background: #212121; }

/* Cavity/pin number badge — mirrors the digits molded on the AMP housing */
.pin-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan);
  background: var(--cyan-dim);
  border: 1px solid var(--cyan-glow);
  border-radius: var(--radius-sm);
}

.wire-role {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.wire-role--pos { color: var(--red); }
.wire-role--neg { color: var(--text-secondary); }
.wire-role--sig { color: var(--cyan); }

/* --- Callouts --- */
.callout {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  max-width: 68ch;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  border: 1px solid;
}

.callout svg {
  flex-shrink: 0;
  margin-top: 3px;
}

.callout strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.callout--warn {
  background: var(--amber-dim);
  border-color: var(--amber-glow);
}

.callout--warn svg,
.callout--warn strong {
  color: var(--amber);
}

.callout--info {
  background: var(--cyan-dim);
  border-color: var(--cyan-glow);
}

.callout--info svg,
.callout--info strong {
  color: var(--cyan);
}

.callout--danger {
  background: rgba(255, 23, 68, 0.08);
  border-color: var(--red-glow);
}

.callout--danger svg,
.callout--danger strong {
  color: var(--red);
}

/* --- Verify / Finish Block --- */
.verify-block {
  margin-top: 3.5rem;
  padding: 2rem;
  background: var(--bg-surface);
  border: var(--border-subtle);
  border-left: 2px solid var(--cyan);
  border-radius: var(--radius-md);
}

.verify-block h3 {
  margin-bottom: 1.25rem;
}

.check-list {
  list-style: none;
  display: grid;
  gap: 0.85rem;
}

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

.check-list svg {
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--green);
}

/* --- Help Footer --- */
.help-strip {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  border-top: var(--border-subtle);
}

.help-strip p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.help-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .photo-grid--single {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-head {
    padding: calc(var(--nav-height) + 3rem) 1.25rem 2.5rem;
  }

  .install-panel {
    padding: 2.5rem 1.25rem 4rem;
  }

  .version-switch-inner {
    padding: 0.75rem 1.25rem;
    gap: 0.6rem;
  }

  .version-switch-label {
    display: none;
  }

  .version-tab {
    font-size: 0.72rem;
    padding: 0.5rem 0.8rem;
  }

  .step {
    padding-left: 0;
    padding-bottom: 2.5rem;
  }

  /* The rail and hex markers don't fit a narrow column — inline the number */
  .steps::before {
    display: none;
  }

  .step-num {
    position: static;
    width: 34px;
    height: 34px;
    margin-bottom: 0.75rem;
  }

  .step h3 {
    padding-top: 0;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }

  .verify-block {
    padding: 1.5rem 1.25rem;
  }
}
