*, *::before, *::after { box-sizing: border-box; }

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-text-muted: color-mix(in srgb, #e9e9ed 65%, transparent);
  --color-accent: #9184d9;
  --color-accent-soft: color-mix(in srgb, #9184d9 16%, transparent);
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --font-heading: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55);
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.6;
  /* Soft accent-colored glows plus a faint dot grid, all fixed so the
     backdrop feels like a stable atmosphere behind the scrolling content
     rather than a texture that scrolls with it. */
  background-color: var(--color-bg);
  background-image:
    radial-gradient(38rem 30rem at 10% -5%, color-mix(in srgb, var(--color-accent) 22%, transparent), transparent 65%),
    radial-gradient(34rem 28rem at 100% 12%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 65%),
    radial-gradient(42rem 34rem at 50% 105%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 60%),
    radial-gradient(color-mix(in srgb, var(--color-text) 7%, transparent) 1px, transparent 1px);
  background-size: auto, auto, auto, 28px 28px;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat;
  background-attachment: fixed, fixed, fixed, fixed;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-accent);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

button {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* — layout — */
.layout {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 var(--space-5) var(--space-8);
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: var(--space-8);
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* — header — */
header {
  padding: var(--space-8) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  text-align: left;
}

.hero-title h1 {
  font-size: clamp(2rem, 3vw + 1rem, 2.75rem);
  margin: 0;
}

.hero-context {
  max-width: 26rem;
}

.hero-context h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.hero-context p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* — step map — */
main {
  padding: var(--space-8) 0;
}

.step-map {
  list-style: none;
  margin: 0 auto;
  padding: 0;
}

.step-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

/* Narrow viewports: a single winding column, nodes alternating left/right so
   the path reads as a winding, S-shaped sidewalk rather than a straight line;
   each connector is a hand-tuned curve whose endpoints match the swing to the
   next node. Wide viewports switch to a two-column "snake" grid below. */
@media (max-width: 699px) {
  .step-map {
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    row-gap: 70px;
  }

  .step-item {
    transform: translateX(var(--stagger, 0px));
  }

  .step-item:nth-child(odd)  { --stagger: -48px; }
  .step-item:nth-child(even) { --stagger: 48px; }

  .step-item::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    height: 70px;
    background-repeat: no-repeat;
    background-position: center top;
    pointer-events: none;
  }

  /* swings right toward the next node */
  .step-item:nth-child(odd)::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='70' viewBox='0 0 260 70'%3E%3Cpath d='M130,0 C130,30 226,40 226,70' stroke='rgba(233,233,237,0.35)' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='5 6'/%3E%3C/svg%3E");
  }

  /* swings left toward the next node */
  .step-item:nth-child(even)::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='70' viewBox='0 0 260 70'%3E%3Cpath d='M130,0 C130,30 34,40 34,70' stroke='rgba(233,233,237,0.35)' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='5 6'/%3E%3C/svg%3E");
  }

  .step-item:last-child::before {
    display: none;
  }
}

/* Narrow phones: shrink the swing and the row gap so the S-curve stays
   comfortably inside the viewport instead of crowding its edges. */
@media (max-width: 480px) {
  .step-map {
    row-gap: 55px;
  }

  .step-item:nth-child(odd)  { --stagger: -26px; }
  .step-item:nth-child(even) { --stagger: 26px; }

  .step-item::before {
    width: 150px;
    height: 55px;
  }

  .step-item:nth-child(odd)::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='55' viewBox='0 0 150 55'%3E%3Cpath d='M75,0 C75,23 127,32 127,55' stroke='rgba(233,233,237,0.35)' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='5 6'/%3E%3C/svg%3E");
  }

  .step-item:nth-child(even)::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='55' viewBox='0 0 150 55'%3E%3Cpath d='M75,0 C75,23 23,32 23,55' stroke='rgba(233,233,237,0.35)' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='5 6'/%3E%3C/svg%3E");
  }
}

/* Wide viewports: a two-column "snake" grid. Steps sit in pairs (1–2, 3–4,
   5–6, 7–8) with each pair's right-hand node dropping down into the left
   column below it, so the path zigzags down the page instead of winding
   down a single lane. Node/column geometry is hand-tuned in pixels (not %)
   so the connector lines below can be positioned deterministically. */
@media (min-width: 700px) {
  .step-map {
    width: fit-content;
    display: grid;
    grid-template-columns: repeat(2, 160px);
    column-gap: 56px;
    row-gap: 88px;
  }

  .step-node {
    position: relative;
  }

  /* left column (1, 3, 5, 7): a straight line over to its row-mate */
  .step-item:nth-child(odd) .step-node::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    width: 152px;
    height: 0;
    border-top: 2px dashed rgba(233, 233, 237, 0.35);
    pointer-events: none;
  }

  /* right column (2, 4, 6): curves down into the left column of the next row */
  .step-item:nth-child(even):not(:last-child)::before {
    content: '';
    position: absolute;
    top: 100%;
    right: 80px;
    width: 216px;
    height: 88px;
    background-repeat: no-repeat;
    background-position: top right;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='216' height='88' viewBox='0 0 216 88'%3E%3Cpath d='M216,0 C216,44 0,44 0,88' stroke='rgba(233,233,237,0.35)' stroke-width='2' fill='none' stroke-linecap='round' stroke-dasharray='5 6'/%3E%3C/svg%3E");
    pointer-events: none;
  }
}

.step-node {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-accent) 75%, transparent);
  color: var(--color-accent);
  font-family: var(--font-heading);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.step-node:hover,
.step-node:focus-visible {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.step-node-title {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  max-width: 10rem;
}

/* — dialog — */
.step-dialog {
  width: min(46rem, calc(100vw - var(--space-6)));
  max-height: min(85vh, 640px);
  overflow-y: auto;
  padding: var(--space-6);
  border: none;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

.step-dialog::backdrop {
  background: color-mix(in srgb, black 60%, transparent);
}

.step-dialog-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-2);
}

.step-dialog-title {
  font-size: 1.5rem;
  margin-bottom: var(--space-4);
}

.step-dialog-body {
  font-size: 0.98rem;
}

.step-dialog-body p:last-child {
  margin-bottom: 0;
}

.step-dialog-body ul {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}

.step-dialog-body li {
  margin-bottom: var(--space-1);
}

.step-dialog-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--color-bg);
  color: var(--color-accent);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

.step-dialog-body em {
  color: var(--color-text-muted);
}

.step-dialog-resources {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  text-align: right;
}

.step-dialog-resources-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.step-dialog-resources ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.step-dialog-resources li + li {
  padding-top: var(--space-2);
}

.step-dialog-resources a {
  font-weight: 600;
  color: var(--color-accent);
}

.step-dialog-resources a:hover,
.step-dialog-resources a:focus-visible {
  text-decoration-thickness: 2px;
}

.step-dialog-resources p {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.step-dialog-media {
  display: flex;
  gap: var(--space-4);
}

.step-dialog-text {
  flex: 1 1 auto;
  min-width: 0;
}

.step-dialog-images {
  flex: 0 0 auto;
  width: 16rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step-dialog-image-btn {
  display: block;
  width: 100%;
  padding: 0;
  cursor: zoom-in;
  border-radius: var(--radius-md);
  transition: box-shadow 0.15s ease;
}

.step-dialog-image-btn img {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-sm);
}

.step-dialog-image-btn:hover img,
.step-dialog-image-btn:focus-visible img {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

@media (max-width: 600px) {
  .step-dialog-media {
    flex-direction: column;
  }

  .step-dialog-images {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .step-dialog-image-btn {
    flex: 1 1 8rem;
  }
}

/* — image lightbox — */
.image-lightbox {
  width: min(90vw, 900px);
  max-height: 90vh;
  padding: var(--space-4);
  border: none;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
}

.image-lightbox::backdrop {
  background: color-mix(in srgb, black 70%, transparent);
}

.image-lightbox-img {
  display: block;
  width: 100%;
  max-height: calc(90vh - 6rem);
  object-fit: contain;
  border-radius: var(--radius-md);
}

.image-lightbox .step-dialog-close {
  margin-top: var(--space-3);
}

.step-dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-5);
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  color: var(--color-accent);
  font-family: var(--font-heading);
  font-weight: 600;
  transition: background 0.15s ease;
}

.step-dialog-close:hover,
.step-dialog-close:focus-visible {
  background: var(--color-accent-soft);
}

/* — footer — */
footer {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
  border-top: 1px solid var(--color-divider);
  text-align: center;
}

footer p {
  color: var(--color-text-muted);
  margin: 0;
}

.footer-credit {
  margin-top: var(--space-3);
  font-size: 0.85rem;
}
