/* Baja SAE: Longhorn Baja Racing theme over the site's dark grey. A static timeline (left), on the
   same background as the story, tracks one scrollable story (right). Colors come from the --lbr-* tokens. */

/* Off-road grit: a faint speckle over the whole page, behind the content */
.page-baja::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--grit-texture);
  opacity: var(--grit-opacity);
  pointer-events: none;
}

/* ---------- Team logo in the nav row (this page only) ---------- */

.nav__team {
  position: absolute;
  top: 50%;
  left: var(--gutter);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 6px;
  text-decoration: none;
  pointer-events: auto;
  transform: translateY(-50%);
}

.nav__team-logo {
  display: block;
  width: 88px;
  aspect-ratio: 3.4 / 1;
  overflow: hidden;
  border-radius: 4px;
  outline: 1px solid var(--rule-strong);
  transition: outline-color var(--dur-fast) var(--ease-out);
}

.nav__team-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A small "opens elsewhere" arrow that lifts on hover */
.nav__team-arrow {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}

.nav__team:hover .nav__team-logo,
.nav__team:focus-visible .nav__team-logo {
  outline-color: var(--lbr-stripe-1);
}

.nav__team:hover .nav__team-arrow,
.nav__team:focus-visible .nav__team-arrow {
  opacity: 1;
  color: var(--lbr-text-yellow);
  transform: translate(2px, -2px);
}

/* ---------- Timeline ---------- */

.bt__list {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.2vh, 22px);
}

.bt__link,
.bt__heading {
  display: block;
  line-height: 1.3;
  text-decoration: none;
  opacity: 0.9;
  transform-origin: left center;
  transition: opacity var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

/* Hover: the active state's color, and a slight growth from the left edge (nothing around it moves) */
.bt__link:hover,
.bt__link:focus-visible,
.bt__heading:hover,
.bt__heading:focus-visible {
  opacity: 1;
  color: var(--lbr-text-yellow);
  transform: scale(1.04);
}

@media (prefers-reduced-motion: reduce) {
  .bt__link:hover,
  .bt__link:focus-visible,
  .bt__heading:hover,
  .bt__heading:focus-visible {
    transform: none;
  }
}

/* Main headings, and Overview at the same level */
.bt__heading,
.bt__link--top {
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.bt__heading.is-active,
.bt__link--top[aria-current] {
  opacity: 1;
  color: var(--lbr-text-yellow);
}

.bt__items {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.7vh, 8px);
  padding-left: var(--space-4);
  border-left: 2px solid var(--rule-strong);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.bt__group.is-active .bt__items {
  border-left-color: var(--lbr-stripe-1);
}

.bt__items .bt__link {
  padding-block: clamp(2px, 0.5vh, 5px);
  font-size: 0.9375rem;
  font-weight: 500;
}

.bt__link[aria-current] {
  opacity: 1;
  font-weight: 700;
  color: var(--lbr-text-yellow);
}

/* ---------- Story pane ---------- */

.bsec {
  container-type: inline-size;
  padding: var(--space-8) var(--gutter);
  border-top: 1px solid var(--rule);
}

.bsec > * + * {
  margin-top: var(--space-5);
}

.bsec--overview {
  padding: 0;
  border-top: 0;
}

.bsec__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lbr-text-yellow);
}

/* Three short slanted bars, echoing the header stripes */
.bsec__eyebrow::before {
  content: "";
  width: 28px;
  height: 9px;
  background: linear-gradient(to bottom, var(--lbr-stripe-1) 0 33%, var(--lbr-stripe-2) 33% 66%, var(--lbr-stripe-3) 66% 100%);
  transform: skewX(-24deg);
}

.bsec__title {
  font-size: clamp(1.6rem, 2.6vw, var(--fs-2xl));
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-transform: uppercase;
}

.bsec__chip {
  margin-top: var(--space-3);
}

.bsec__intro {
  max-width: var(--measure);
  font-size: var(--fs-lg);
  line-height: 1.5;
  color: var(--text-muted);
}

.bsub {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btext {
  max-width: var(--measure);
  color: var(--text-muted);
}

/* Bullets with a small slanted bar */
.points {
  display: grid;
  gap: var(--space-2);
  max-width: var(--measure);
}

.points li {
  position: relative;
  padding-left: 1.5em;
}

.points li::before {
  content: "";
  position: absolute;
  left: 0.15em;
  top: 0.6em;
  width: 0.75em;
  height: 0.32em;
  background: var(--lbr-stripe-2);
  transform: skewX(-24deg);
}

.bpoints__title,
.blist__title {
  margin-bottom: var(--space-3);
}

/* Numbered design goals: the design was shaped around these */
.goals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-4);
  max-width: 900px;
}

.goal {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 3px solid var(--lbr-stripe-2);
  background: var(--surface);
}

.goal__num {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--lbr-text-yellow);
}

.goal__text {
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
}

/* Label / value rows */
.kv {
  max-width: 760px;
  border-top: 1px solid var(--rule);
}

.kv__row {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}

.kv dd {
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.btable-wrap {
  max-width: 820px;
  overflow-x: auto;
}

.btable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.btable th,
.btable td {
  padding: 10px var(--space-4) 10px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: baseline;
}

.btable thead th {
  border-bottom-color: var(--rule-strong);
}

.btable tbody th {
  font-weight: 600;
}

/* Short items in columns */
.blist__items {
  columns: 3 13rem;
  column-gap: var(--space-6);
  max-width: 900px;
}

.blist__items li {
  position: relative;
  padding: 3px 0 3px 1.1em;
  break-inside: avoid;
  font-size: var(--fs-sm);
}

.blist__items li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 0.45em;
  height: 0.45em;
  background: var(--lbr-stripe-1);
}

/* ---------- Media ---------- */

/*
 * Grids and rows size against the story column (the section is a size container):
 * --w is the usable width, --tile-h the height of a 3:4 grid tile at the current column count.
 */
.bmedia {
  --gap: var(--space-5);
  --cols: 1;
  --w: min(100cqw, 1200px);
  --tile-h: calc((var(--w) - (var(--cols) - 1) * var(--gap)) / var(--cols) * 4 / 3);
  margin-top: var(--space-6);
}

@container (min-width: 480px) {
  .bmedia {
    --cols: 2;
  }
}

/* Three across from about a 900 px window, so a set of three stays on one row */
@container (min-width: 600px) {
  .bmedia {
    --cols: 3;
  }
}

.bfig img,
.bfig video {
  width: 100%;
}

.bfig__media,
.mosaic__media {
  position: relative;
}

/* The image is a button that opens the expanded view */
.bfig__open {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

.bfig__open img {
  transition: opacity var(--dur-fast) var(--ease-out);
}

.bfig__open:hover img {
  opacity: 0.88;
}

.bfig__open:focus-visible {
  outline-offset: 2px;
}

.bmedia--feature,
.bmedia--stack {
  max-width: 1100px;
}

.bmedia--stack {
  display: grid;
  gap: var(--space-7);
}

.bmedia--pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--space-5);
  align-items: start;
  max-width: 1440px;
}

/* Grid: same-size 3:4 tiles, up to three per row. Other shapes are cropped here and shown whole when expanded. */
.bmedia--grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
  max-width: 1200px;
}

.bmedia--grid .bfig img {
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

/* Row: one line, every image the same height and uncropped. JS sets --n (count), --sum (summed
   width/height ratios), each figure's --ar, and --row-cap for screenshots never shown above their size. */
.bmedia--row {
  --row-cap: 36rem;
  --row-h: min(var(--row-cap), (var(--w) - (var(--n) - 1) * var(--gap)) / var(--sum));
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

/* No taller than a grid tile, so it lines up with the grid above it */
.bmedia--tile-height {
  --row-cap: var(--tile-h);
}

.bmedia--row .bfig {
  flex: none;
  width: calc(var(--row-h) * var(--ar));
}

.bmedia--row .bfig img {
  max-width: 100%;
}

/* Narrow columns: a row stacks, each image at full width (screenshots never above their own size) */
@container (max-width: 479.98px) {
  .bmedia--row {
    flex-direction: column;
  }

  .bmedia--row .bfig {
    width: min(100%, var(--row-cap) * var(--ar));
  }
}

.caption__text {
  display: block;
}

.media-toggle {
  margin-top: var(--space-2);
  padding: 2px var(--space-2);
  border: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text);
}

.media-toggle:hover {
  border-color: var(--text);
}

.bfig--video {
  max-width: 960px;
}

.bfig--video video {
  height: auto;
  background: var(--surface);
}

.bfig--model {
  display: block;
  width: 100%;
  height: min(70vh, 560px);
  background: var(--surface);
}

/* ---------- Overview ---------- */

/* Header after the team's sponsor packet: small name, big team name, roles, stripes */
.ovh {
  position: relative;
  padding: var(--space-8) var(--gutter) 0;
  overflow: hidden;
}

.ovh__title {
  display: grid;
  gap: var(--space-4);
}

.ovh__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--lbr-text-yellow);
}

.ovh__name {
  max-width: 11ch;
  font-size: clamp(2.4rem, 5.4vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 0.95;
  text-transform: uppercase;
}

.ovh__roles {
  margin-top: var(--space-4);
  font-size: clamp(0.95rem, 1.35vw, 1.125rem);
  font-weight: 600;
  color: var(--lbr-text-orange);
}

/* Three horizontal stripes, thinner than the packet's and a little roughed up */
.ovh__stripes {
  height: clamp(18px, 2.4vw, 30px);
  margin: var(--space-7) calc(var(--gutter) * -1) 0;
  background: linear-gradient(to bottom, var(--lbr-stripe-1) 0 33%, var(--lbr-stripe-2) 33% 66%, var(--lbr-stripe-3) 66% 100%);
  -webkit-mask-image: var(--grit-mask);
  mask-image: var(--grit-mask);
}

.ovh__break {
  margin: var(--space-7) var(--gutter) 0;
  border: 0;
  border-top: 1px solid var(--rule-strong);
}

.ovh__body {
  padding: var(--space-7) var(--gutter) var(--space-8);
}

.ovh__body > * + * {
  margin-top: var(--space-5);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.stat {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-5);
  border-top: 3px solid var(--lbr-stripe-2);
  background: var(--surface);
}

.stat__value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  line-height: 1;
  color: var(--lbr-text-yellow);
}

.stat__text {
  font-size: var(--fs-sm);
  line-height: 1.45;
}

/* Photo mosaic: the tall climb shot on the left, three others around it */
.mosaic {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, clamp(150px, 15vw, 290px));
  gap: var(--space-3);
  margin-top: var(--space-7);
}

.mosaic__item {
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.mosaic__media,
.mosaic__media .bfig__open {
  height: 100%;
}

.mosaic__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mosaic__item--1 {
  grid-column: 2 / 4;
  grid-row: 1;
}

.mosaic__item--2 {
  grid-column: 1;
  grid-row: 1 / 3;
}

.mosaic__item--4 img {
  object-position: center 30%;
}

.roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--space-5);
  margin-top: var(--space-7);
}

.role {
  display: grid;
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-5);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--lbr-stripe-1);
  background: var(--surface);
}

.role__title {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.role .points {
  font-size: var(--fs-md);
}

.role__group-title {
  margin-bottom: var(--space-2);
  color: var(--lbr-text-yellow);
}

.role__link {
  justify-self: start;
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* ---------- Wide screens ---------- */

@media (min-width: 768px) {
  /* The whole timeline fits on laptop heights; the list scrolls only on very short screens (a phone held sideways) */
  .bt {
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    overflow: hidden;
    padding: var(--space-5) var(--space-5) var(--space-5) var(--space-6);
  }

  /*
   * Spacing grows with the screen height so the list reaches further down the column: about three
   * quarters of it at 1440x900, and it still fits without scrolling at 1366x768. Most of the room goes
   * between the entries inside a group, so each group's left rule stays one continuous line.
   */
  .bt__list {
    max-height: 100%;
    gap: clamp(14px, 6vh, 80px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .bt__items {
    gap: clamp(4px, 2.6vh, 32px);
  }

  .bt__items .bt__link {
    padding-block: clamp(2px, 1.2vh, 14px);
  }

  .bsec {
    padding-inline: var(--space-6);
  }

  .ovh {
    padding-inline: var(--space-6);
  }

  .ovh__stripes {
    margin-inline: calc(var(--space-6) * -1);
  }

  .ovh__break,
  .ovh__body {
    margin-inline: var(--space-6);
    padding-inline: 0;
  }

  /* Room for the last section to reach the top of the pane */
  .pane--story {
    padding-bottom: 35vh;
  }
}

/* Main headings sit to the left of their items once the column is wide enough */
@media (min-width: 1230px) {
  .bt__group {
    display: grid;
    grid-template-columns: 7.75rem minmax(0, 1fr);
    column-gap: var(--space-3);
    align-items: start;
  }

  .bt__heading {
    padding-top: 2px;
  }
}

@media (min-width: 768px) and (max-width: 1229.98px) {
  .bt__heading {
    margin-bottom: var(--space-2);
  }
}

/* ---------- Phones ---------- */

@media (max-width: 767.98px) {
  /* The timeline becomes a sticky strip; its own background keeps the story from showing through */
  .bt {
    position: sticky;
    top: var(--nav-h);
    z-index: 10;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
  }

  .bt__list,
  .bt__group,
  .bt__items {
    flex-direction: row;
    align-items: center;
  }

  .bt__list {
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .bt__list::-webkit-scrollbar {
    display: none;
  }

  .bt__group {
    display: flex;
  }

  .bt__items {
    gap: 0;
    padding-left: 0;
    border-left: 0;
  }

  .bt__link,
  .bt__heading {
    padding: var(--space-3) var(--space-3);
    border-bottom: 2px solid var(--clear);
    white-space: nowrap;
  }

  .bt__items .bt__link {
    font-size: var(--fs-sm);
  }

  .bt__heading {
    padding-left: var(--space-4);
    border-left: 1px solid var(--rule-strong);
  }

  .bt__link[aria-current] {
    border-bottom-color: var(--lbr-text-yellow);
  }

  .bsec {
    scroll-margin-top: calc(var(--nav-h) + 44px);
  }

  .ovh {
    padding-top: var(--space-7);
  }

  .mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, clamp(120px, 34vw, 220px));
  }

  .mosaic__item--1 {
    grid-column: 1 / 3;
    grid-row: 1;
  }

  .mosaic__item--2 {
    grid-column: 1;
    grid-row: 2 / 4;
  }

  .kv__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  /* The logo shares the nav row with the Menu button */
  .nav__team-logo {
    width: 76px;
  }
}
