@layer reset, base, layout, component;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  img {
    max-width: 100%;
    display: block;
  }
}

@layer base {
  /* Start – Fonts */
  @font-face {
    font-family: "Rubik";
    src: url("../../fonts/Rubik-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
  }
  @font-face {
    font-family: "Rubik";
    src: url("../../fonts/Rubik-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
  }
  @font-face {
    font-family: "Google Sans Flex";
    src: url("../../fonts/GoogleSansFlex-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
  }
  @font-face {
    font-family: "Roboto Mono";
    src: url("../../fonts/RobotoMono-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
  }
  /* End – Fonts */

  /* Start — Type Scale and Colors */
  :root {
    /* --- Surfaces --- */
    --paper: #fcfcfa;
    --dot: #ececef;
    --card: #ffffff;

    /* --- Ink --- */
    --ink: #333b4a;
    --ink-heading: #0e1b3d;
    --ink-light: #6b7280;
    --hairline: #e4e5e9;

    /* --- Devlink spectrum --- */
    --spec-teal: #5fd3c4;
    --spec-blue: #4c6fe8;
    --spec-purple: #7b3fe4;
    --spec-magenta: #e03fb8;
    --spec-orange: #f5834a;
    --spec-yellow: #f5d06b;

    /* The button stroke, verbatim (horizontal) */
    --spec-gradient: linear-gradient(
      90deg,
      var(--spec-teal) 0%,
      var(--spec-blue) 18%,
      var(--spec-purple) 36%,
      var(--spec-magenta) 54%,
      var(--spec-orange) 74%,
      var(--spec-yellow) 100%
    );
    /* Same stroke, unrolled vertically for the timeline */
    --spec-gradient-v: linear-gradient(
      180deg,
      var(--spec-teal) 0%,
      var(--spec-blue) 18%,
      var(--spec-purple) 36%,
      var(--spec-magenta) 54%,
      var(--spec-orange) 74%,
      var(--spec-yellow) 100%
    );

    /* --- Type --- */
    --font-heading: "Rubik", sans-serif;
    --font-body: "Google Sans Flex", sans-serif;
    --font-mono: "Roboto Mono", monospace;

    /* --- Layout --- */
    --max-width: 1440px;
    --gutter: 120px;
    --section-pad: 50px; /* matches homepage section rhythm (hp-style.css) */
  }
  /* End — Type Scale and Colors */

  html {
    scroll-behavior: smooth;
  }

  body {
    background-color: var(--paper);
    /* The dot grid */
    background-image: radial-gradient(circle, var(--dot) 2px, transparent 2px);
    background-size: 24px 24px;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
  }

  h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 48px;
    line-height: 1.1;
    color: var(--ink-heading);
  }

  h2 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 22px;
    line-height: 1.3;
    color: var(--ink-heading);
  }

  h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 18px;
    line-height: 1.3;
    color: var(--ink-heading);
  }

  h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
    color: var(--ink-heading);
  }

  a {
    color: #7f8590;
    text-decoration: underline;
    text-decoration-color: #7f8590;
    text-underline-offset: 3px;
  }

  a:hover:not(:where(.return, .crumb a)),
  a:focus-visible:not(:where(.return, .crumb a)) {
    background-image: var(--spec-gradient);
    background-size: 200% 100%;
    background-position: 0 0;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    animation: spectrum-sweep 1.8s ease infinite alternate;
  }

  @keyframes spectrum-sweep {
    to {
      background-position: 100% 0;
    }
  }

  .list__indent {
    list-style-type: disc;
    padding-left: 50px;
    margin-bottom: 20px;
  }

  .list__indent-num {
    list-style-type: decimal;
    padding-left: 50px;
    margin-top: 15px;
    margin-bottom: 15px;
  }

  .list__indent li + li {
    margin-top: 16px;
  }

  /* Determines color of cursor highlighted text */
  ::selection {
    background: var(--spec-teal);
    color: var(--ink-heading);
  }

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

  /* Start — Standard highlight */
  .highlight-yellow {
    background-color: hsl(46, 100%, 65%);
  }

  .highlight-orange {
    background-color: hsl(28, 100%, 72%);
  }

  .highlight-green {
    background-color: hsl(162, 100%, 68%);
  }

  .highlight-pink {
    background-color: hsl(307, 91%, 82%);
  }

  .highlight-purple {
    background-color: hsl(263, 100%, 83%);
  }
  /* End — Standard highlight */

  /* Start — Marker highlight */
  .marker-yellow {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(46, 100%, 65%, 0.1),
      hsla(46, 100%, 65%, 0.7) 4%,
      hsla(46, 100%, 65%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-orange {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(28, 100%, 72%, 0.1),
      hsla(28, 100%, 72%, 0.7) 4%,
      hsla(28, 100%, 72%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-green {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(162, 100%, 68%, 0.1),
      hsla(162, 100%, 68%, 0.7) 4%,
      hsla(162, 100%, 68%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-pink {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(307, 91%, 82%, 0.1),
      hsla(307, 91%, 82%, 0.7) 4%,
      hsla(307, 91%, 82%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-purple {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(263, 100%, 83%, 0.1),
      hsla(263, 100%, 83%, 0.7) 4%,
      hsla(263, 100%, 83%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-blue {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(203, 100%, 83%, 0.1),
      hsla(203, 93%, 71%, 0.7) 4%,
      hsla(203, 100%, 83%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  /* End — Marker highlight */
}

@layer layout {
  .wrapper {
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  @media (max-width: 1200px) {
    :root {
      --gutter: 80px;
    }
  }
  @media (max-width: 992px) {
    :root {
      --gutter: 48px;
    }
  }
  @media (max-width: 767px) {
    :root {
      --gutter: 24px;
    }
  }
}

@layer component {
  /* ---------- Breadcrumb ---------- */
  .crumb {
    padding-block: 28px 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink-light);
  }

  .crumb a {
    text-decoration: none;
    color: var(--ink-light);
    transition: color 0.2s ease;
  }

  .crumb a:hover,
  .crumb a:focus-visible {
    color: #7f8590;
  }

  .crumb__sep {
    margin-inline: 6px;
  }

  .crumb__here {
    color: var(--ink-heading);
  }

  /* ---------- Hero ---------- */
  .hero {
    padding-block: var(--section-pad);
  }

  .hero__kicker {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--ink-light);
    margin-bottom: 12px;
  }

  .hero__lede {
    width: 80%;
    max-width: none;
    margin-top: 20px;
  }

  .spectrum-rule {
    height: 3px;
    border: none;
    border-radius: 3px;
    background: var(--spec-gradient);
    margin-block: 20px;
  }

  /* Start – TL;DR content */
  .tldr-btn {
    appearance: button;
    background-color: #4d4ae8;
    background-image: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.15),
      rgba(255, 255, 255, 0)
    );
    border: 1px solid #4d4ae8;
    border-radius: 1rem;
    box-shadow:
      rgba(255, 255, 255, 0.15) 0 1px 0 inset,
      rgba(46, 54, 80, 0.075) 0 1px 1px;
    box-sizing: border-box;
    color: #ffffff;
    cursor: pointer;
    display: inline-block;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    margin-top: 24px;
    padding: 0.5rem 2.5rem;
    text-align: center;
    text-transform: none;
    transition:
      color 0.15s ease-in-out,
      background-color 0.15s ease-in-out,
      border-color 0.15s ease-in-out,
      box-shadow 0.15s ease-in-out;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    vertical-align: middle;
  }

  .tldr-btn:focus:not(:focus-visible),
  .tldr-btn:focus {
    outline: 0;
  }

  .tldr-btn:hover {
    background-color: #3733e5;
    border-color: #3733e5;
  }

  .tldr-btn:focus {
    background-color: #413fc5;
    border-color: #3e3bba;
    box-shadow:
      rgba(255, 255, 255, 0.15) 0 1px 0 inset,
      rgba(46, 54, 80, 0.075) 0 1px 1px;
  }

  .tldr-btn:active {
    background-color: #3e3bba;
    background-image: none;
    border-color: #3a38ae;
    box-shadow: rgba(46, 54, 80, 0.125) 0 3px 5px inset;
  }

  .tldr-btn:active:focus {
    box-shadow: rgba(46, 54, 80, 0.125) 0 3px 5px inset;
  }

  .tldr-btn:disabled {
    background-image: none;
    box-shadow: none;
    opacity: 0.65;
    pointer-events: none;
  }

  .tldr-viewer {
    position: relative;
    margin: auto;
    width: min(92vw, 640px);
    max-height: 80vh;
    display: none;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    overflow: hidden;
    /* Frosts only what's directly behind this card — the ::backdrop
       below is left un-blurred so the rest of the page stays sharp. */
    background: rgba(219, 219, 227, 0.24);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    box-shadow:
      0 8px 32px rgba(227, 227, 231, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.5),
      inset 0 -1px 0 rgba(255, 255, 255, 0.1);
  }

  /* Thin light-catching edges, same trick as the glass-card reference */
  .tldr-viewer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.8),
      transparent
    );
  }

  .tldr-viewer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.8),
      transparent,
      rgba(255, 255, 255, 0.3)
    );
  }

  .tldr-viewer[open] {
    display: flex;
    flex-direction: column;
  }

  /* A dim, not a blur — only the card itself frosts, not the page behind it */
  .tldr-viewer::backdrop {
    background: rgba(58, 58, 59, 0.75);
  }

  .tldr-viewer__titlebar {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(210, 200, 255, 0.65);
  }

  .tldr-viewer__caption {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 18px;
    color: #ffffff;
  }

  .tldr-viewer__close {
    font-family: var(--font-mono);
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: #ffffff;
    white-space: nowrap;
  }

  .tldr-viewer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 28px;
    color: #ffffff;
    line-height: 1.6;
  }

  .tldr-viewer__body p + p {
    margin-top: 12px;
  }

  @media (max-width: 767px) {
    .tldr-viewer {
      width: 94vw;
      max-height: 88vh;
    }
    .tldr-viewer__body {
      padding: 20px;
    }
  }
  /* End – TL;DR content */

  /* ---------- Build section (spine + phase cards) ---------- */
  .build {
    padding-block: var(--section-pad);
  }

  .phases {
    --line-x: 11px; /* line center from list edge */
    --dot-size: 16px;
    list-style: none;
    position: relative;
    display: grid;
    gap: 52px; /* ≈ two <br /> line breaks of space between cards */
    padding-left: 56px;
    /* Cards read better capped near a text measure;
       delete line below for full-width cards */
    max-width: 900px;
  }

  .phases::before {
    content: "";
    position: absolute;
    top: 30px; /* start at the first dot */
    bottom: 0;
    left: calc(var(--line-x) - 1px);
    width: 2px;
    border-radius: 2px;
    background: var(--spec-gradient-v);
  }

  .phases__item:last-child::after {
    content: "";
    position: absolute;
    left: calc(-56px + var(--line-x) - 2px);
    top: 40px; /* just below this card's dot */
    bottom: 0;
    width: 4px;
    background: var(--paper);
  }

  .phases__item {
    position: relative;
    /* The lifted card */
    background: var(--card);
    border: 1px solid var(--hairline);
    border-top: 8px solid var(--key, var(--spec-blue));
    border-radius: 15px;
    padding: 24px 28px;
    box-shadow: 0 2px 10px rgba(14, 27, 61, 0.05);
  }

  /* Node dot on the timeline, keyed to its card */
  .phases__item::before {
    content: "";
    position: absolute;
    left: calc(-56px + var(--line-x) - var(--dot-size) / 2);
    top: 26px;
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
    background: var(--key, var(--spec-blue));
    /* Background colored ring so the dot separated from the line */
    box-shadow: 0 0 0 4px var(--paper);
  }

  .phases__item--teal {
    --key: var(--spec-teal);
  }
  .phases__item--blue {
    --key: var(--spec-blue);
  }
  .phases__item--purple {
    --key: var(--spec-purple);
  }
  .phases__item--magenta {
    --key: var(--spec-magenta);
  }
  .phases__item--orange {
    --key: var(--spec-orange);
  }
  .phases__item--yellow {
    --key: var(--spec-yellow);
  }

  .phases__kicker {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--ink-light);
    margin-bottom: 6px;
  }

  .phases__item h2 {
    margin-bottom: 10px;
  }

  .phases__item h3 {
    margin-block: 18px 6px;
  }

  .phases__item p + p {
    margin-top: 10px;
  }

  /* ---------- The particulars ---------- */
  .particulars {
    padding-block: var(--section-pad);
    max-width: 760px;
  }

  .particulars h2 {
    font-size: 26px;
    margin-bottom: 20px;
  }

  .particulars__list {
    font-family: var(--font-mono);
    font-size: 14px;
    border-top: 1px solid var(--hairline);
  }

  .particulars__row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 24px;
    padding-block: 12px;
    border-bottom: 1px solid var(--hairline);
  }

  .particulars__row dt {
    color: var(--ink-light);
    text-transform: lowercase;
  }

  .particulars__row dd a {
    color: #7f8590;
    text-decoration-color: #7f8590;
    text-underline-offset: 5px;
    transition: color 0.2s ease;
  }

  .particulars__row dd a:hover,
  .particulars__row dd a:focus-visible {
    color: var(--ink);
  }

  /* ---------- Return button (devlink recipe, verbatim) ---------- */
  .return {
    /* --- Local tokens --- */
    --devlink-fill: var(--paper);
    --devlink-text: var(--ink-heading);
    --devlink-stroke-w: 2px;

    /* --- Box --- */
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 10px;
    margin-block: 0 60px; /* the particulars' bottom pad supplies 50px above */
    padding: 14px 28px;
    border: var(--devlink-stroke-w) solid transparent;
    border-radius: 999px; /* pill: any huge value works */

    /* --- The trick ---
       Layer 1 (fill) is clipped to the padding box, so it stops at the
       inner edge of the border. Layer 2 (gradient) is clipped to the
       border box, so it shows only where the transparent border is.
       background-origin: border-box makes both layers start from the
       same outer edge, which keeps the gradient aligned around the curve. */
    background-image:
      linear-gradient(var(--devlink-fill), var(--devlink-fill)),
      var(--spec-gradient);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    background-repeat: no-repeat;
    background-size:
      auto,
      200% 100%; /* stroke is double-wide so it can slide on hover */
    background-position:
      0 0,
      0 0;

    /* --- Type --- */
    color: var(--devlink-text);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;

    transition:
      background-position 0.45s ease,
      transform 0.2s ease,
      box-shadow 0.2s ease;
  }

  /* --- Hover / focus: gradient slides, button grows --- */
  .return:hover,
  .return:focus-visible {
    background-position:
      0 0,
      100% 0;
    transform: scale(1.03);
    box-shadow: 0 6px 18px rgba(26, 26, 26, 0.14);
  }

  .return:active {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.12);
  }

  .return:focus-visible {
    outline: 2px solid var(--spec-blue);
    outline-offset: 3px;
  }

  /* --- Mobile --- */
  @media (max-width: 767px) {
    .return {
      gap: 8px;
      padding: 14px 22px;
      font-size: 15px;
    }
  }

  /* ---------- Mobile ---------- */
  @media (max-width: 767px) {
    h1 {
      font-size: 34px;
    }
    h2 {
      font-size: 20px;
    }
    h3 {
      font-size: 17px;
    }
    .phases {
      padding-left: 40px;
      gap: 40px;
    }
    .phases__item {
      padding: 20px;
    }
    .phases__item::before {
      left: calc(-40px + var(--line-x) - var(--dot-size) / 2);
    }
    .phases__item:last-child::after {
      left: calc(-40px + var(--line-x) - 2px);
    }
    .particulars__row {
      grid-template-columns: 1fr;
      gap: 4px;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
    .crumb a,
    .return,
    .particulars__row dd a {
      transition: none;
    }
    .return:hover,
    .return:focus-visible,
    .return:active {
      transform: none;
    }
  }
}
