/* Homepage-only styles: the research timeline and its carousels.
 *
 * Loaded by index.html alone. None of these selectors match anything on the
 * Learn or product pages, which is why they were split out of the shared
 * stylesheet — those pages were downloading ~45% of a stylesheet they never
 * used.
 *
 * Source order is significant. Several `body.technologies-page` rules further
 * down deliberately override the plain `#content .tech-*` rules above them at
 * equal specificity, and the mobile block near the end re-asserts values that
 * a later desktop rule would otherwise win. Reordering this file will change
 * the layout.
 */

body[data-bg-mode='page'] {
  /* The JPEG declaration is the fallback: an engine without image-set()/type()
   * support drops the WebP rule below and keeps this one. */
  background-image:
    linear-gradient(to bottom, rgba(14, 24, 40, 0.55), rgba(9, 14, 25, 0.72)),
    url('/public/background.jpg');
  background-image:
    linear-gradient(to bottom, rgba(14, 24, 40, 0.55), rgba(9, 14, 25, 0.72)),
    image-set(
      url('/public/background.webp') type('image/webp'),
      url('/public/background.jpg') type('image/jpeg')
    );
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body.technologies-page #content .page {
  position: relative;
}

body.technologies-page #content .page > * {
  position: relative;
  z-index: 1;
}

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

#content .tech-desc {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

/* The research projects read top to bottom, one per row, in the normal
 * content measure. They used to be a horizontal scroller; the arrows in
 * `.tech-carousel-controls` now step the page down the stack instead. */
#content .tech-timeline {
  position: relative;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-8);
  scroll-behavior: smooth;
}

#content .tech-item {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  scroll-margin-top: 90px;
  content-visibility: auto;
  contain-intrinsic-size: auto 450px;
}

/* A hairline between projects rather than card chrome — the stack reads as
 * one continuous section, not a row of boxes. */
#content .tech-item + .tech-item {
  border-top: 1px solid var(--border-hairline);
  padding-top: var(--space-8);
}

#content .tech-item h3 {
  margin-top: 0;
}

#content .tech-item .tech-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

#content .tech-item .tech-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  text-decoration: none;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease,
    box-shadow 0.3s ease;
}

#content .tech-item .tech-github img {
  display: block;
  height: 28px;
  width: auto;
}

#content .tech-item .tech-github:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

#content .tech-item .tech-github:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(35, 119, 214, 0.35);
}

#content .tech-item .tech-desc:last-child {
  margin-top: auto;
}

/* The old horizontal layout reserved two lines of height on every question so
 * that side-by-side cards started their screenshots at the same y. Stacked
 * vertically there is nothing to line up against, so the reserve is gone and
 * each question takes the height it needs. */
#content .tech-item > p.tech-desc {
  max-width: 60ch;
}

#content .tech-item img {
  display: block;
}

#content .tech-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius);
  background: transparent;
  border: none;
}

#content .tech-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Interrobang and Product Manager AI Assistant each show one wide image; at
 * full column width they overpowered the stack, so they sit at 90%. Left
 * aligned rather than centred, to keep the same left edge as the heading and
 * the question above them.
 *
 * Cloak is excluded — its screenshots are sized by the split grid. My is
 * excluded here and shrunk via `.pc-carousel` below instead: its arrows are
 * positioned against the carousel, so shrinking the viewport alone would put
 * them back out over the letterbox. */
#content .tech-media:not(.cloak-media):not(.pc-carousel-viewport) {
  width: 90%;
}

/* Cloak's card splits in two on desktop: the App Store screenshots on the
 * left, the summary and links on the right. Below the breakpoint it falls
 * back to one column, screenshots first. */
.cloak-split {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .cloak-split {
    /* 280px keeps each phone around 134px wide — small enough that the 2x2
     * block does not tower over the short summary next to it, big enough that
     * the in-app text stays readable, which is the reason the screenshots are
     * on the page at all. Widening this column makes the block taller, not
     * wider, so the empty space beside the summary grows quickly. */
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    gap: var(--space-8);
    /* The block is still taller than the summary, so the summary is centred
     * against it rather than hanging off the top over a column of empty
     * space. */
    align-items: center;
  }
}

/* `#content .tech-item .tech-desc:last-child { margin-top: auto }` above
 * bottom-aligns the last block in a card. Inside the split that rule pushes
 * the summary to the foot of a ~680px grid row, so it is cancelled here —
 * at matching specificity, which is why the selector is this long. */
#content .tech-item .cloak-split > .tech-desc:last-child {
  margin-top: 0;
}

/* Four phones in a 2x2 block rather than a single row of four: at this column
 * width a row would shrink each one below the point where the in-app text is
 * readable, which is the whole reason the screenshots are here. */
#content .tech-media.cloak-media {
  aspect-ratio: unset;
  height: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
  justify-content: center;
  overflow: visible;
}

#content .tech-item .tech-desc:has(.cloak-media) {
  margin-top: 0;
  margin-bottom: 0;
}

#content .tech-media.cloak-media img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: var(--radius);
}

/* Home layout ------------------------------------------------------------- */

.home-layout {
  display: grid;
  gap: var(--space-6);
}

.page-section {
  scroll-margin-top: 90px;
}

.page-section + .page-section {
  margin-top: var(--space-8);
}

@media (min-width: 900px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr) 420px;
    align-items: start;
  }
}

@media (max-width: 768px) {
  body.technologies-page .pc-carousel-arrow {
    background: rgba(4, 13, 23, 0.55);
  }

  body.technologies-page #content .tech-item .tech-desc:last-child {
    margin-top: 0.2rem;
  }

  #content .tech-timeline {
    gap: var(--space-6);
  }

  #content .tech-item + .tech-item {
    padding-top: var(--space-6);
  }
}

/* Timeline carousel controls ---------------------------------------------- */

.tech-carousel-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.tech-carousel-button {
  border: 1px solid rgba(115, 170, 231, 0.35);
  border-radius: var(--radius);
  padding: 0.3rem;
  cursor: pointer;
  background: rgba(4, 13, 23, 0.22);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.tech-carousel-button:hover {
  background: rgba(115, 170, 231, 0.06);
  border-color: rgba(115, 170, 231, 0.55);
}

/* display:none rather than a fade, so the down and up arrows share one slot
 * and the visible one always sits flush right — the up arrow replaces the
 * down arrow in place instead of shifting across. */
.tech-carousel-button.is-hidden {
  display: none;
}

/* Screenshot carousel ------------------------------------------------------ */

/* 90% to match Interrobang and Product Manager AI Assistant. It goes on the
 * carousel rather than the viewport so the arrows, which are absolutely
 * positioned against this box, shrink with the picture. */
.pc-carousel {
  position: relative;
  display: block;
  isolation: isolate;
  width: 90%;
}

.pc-carousel-viewport {
  position: relative;
  min-width: 0;
  perspective: 900px;
  z-index: 1;
}

/* The slides are 1686x1090 (1.547), but `.tech-media` boxes them at 16/10
 * (1.600). `object-fit: contain` then pillarboxes each slide by ~1.6% a side,
 * and the arrows below — inset from the *box* — ended up sitting on that empty
 * strip, half off the picture. Matching the box to the slides removes the
 * strip, so `left/right: 14px` is measured from the image edge itself.
 * Specificity has to beat `#content .tech-media`, hence both classes. */
#content .tech-media.pc-carousel-viewport {
  aspect-ratio: 1686 / 1090;
}

.pc-carousel-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
  opacity: 0;
  transform: translateX(0) scale(0.98);
  transition:
    transform 220ms ease,
    opacity 220ms ease;
  pointer-events: none;
}

.pc-carousel-slide.is-active {
  opacity: 1;
  transform: translateX(0) translateZ(0) scale(1);
  z-index: 3;
  pointer-events: none;
}

.pc-carousel-slide.is-prev {
  opacity: 0.22;
  transform: translateX(-12px) translateZ(-70px) rotateY(10deg) scale(0.96);
  z-index: 2;
}

.pc-carousel-slide.is-next {
  opacity: 0.22;
  transform: translateX(12px) translateZ(-70px) rotateY(-10deg) scale(0.96);
  z-index: 2;
}

.pc-carousel-arrow {
  border: 1px solid rgba(115, 170, 231, 0.35);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background: rgba(4, 13, 23, 0.32);
  color: var(--text-primary);
  font-weight: 600;
  line-height: 0;
  font-size: 0;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  pointer-events: auto;
}

.pc-carousel-arrow[data-pc-prev] {
  left: 14px;
}

.pc-carousel-arrow[data-pc-next] {
  right: 14px;
}

.pc-carousel-arrow svg {
  display: block;
  width: 16px;
  height: 16px;
}

.pc-carousel-arrow:hover {
  background: rgba(115, 170, 231, 0.06);
  border-color: rgba(115, 170, 231, 0.55);
}

.pc-carousel-arrow:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Timeline typography ------------------------------------------------------ */
/* These intentionally follow the rules above and override them at equal or
   higher specificity. The full-bleed 100vw track that used to live here went
   away with the horizontal layout — the stack sits in the content measure. */

body.technologies-page #content h3 {
  font-size: 1.05rem;
  margin-top: 0;
}

body.technologies-page #content .tech-desc {
  margin-top: 0.2rem;
  margin-bottom: 0.7rem;
}

@media (max-width: 768px) {
  body.technologies-page #content .tech-item {
    content-visibility: visible;
    contain-intrinsic-size: none;
  }
}

body.technologies-page .tech-carousel-controls {
  margin-top: 0.15rem;
  margin-bottom: 0.55rem;
}

/* Hero lede: the page's h1 is the positioning statement, rendered at body-text
   size so it reads as a bold lead paragraph rather than a display heading. */
#content .home-lede {
  font-size: inherit;
  font-weight: 600;
  line-height: 1.6;
  margin: 0 0 1em 0;
}
