/* Landing page: three panels and the thread running behind them */

:root {
  --paper: #f4efe7;
  --ink: #1d1a16;
  --line: rgba(29, 26, 22, 0.14);
  --thread: #b5573f;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
}

/* ---------- Landing panels ---------- */

.panels {
  position: relative;
  display: flex;
  height: 100vh;
  height: 100svh;
}

.panel {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow: hidden;
  container-type: inline-size; /* lets the word size itself to the panel */
  color: inherit;
  text-decoration: none;
  background-color: transparent;
  transition: flex-grow 0.9s var(--ease), background-color 0.6s ease;
}

.panel + .panel {
  border-left: 1px solid var(--line);
}

.panel__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* Soft dark wash over the video so the word stays readable */
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.panel__word {
  position: relative;
  z-index: 1;
  /* Scales with the panel's width, so words shrink and grow with their panel */
  font-size: min(15cqi, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.6s ease, opacity 0.6s ease;
}

/* ---------- Thread running behind all three panels ---------- */

.thread {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--thread);
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.thread path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0.55;
}

/* The paths repeat every 2400 units, so sliding by that much loops seamlessly */
.thread__lines {
  animation: thread-flow 150s linear infinite;
}

@keyframes thread-flow {
  to { transform: translateX(-2400px); }
}

.panels:has(.is-active) .thread {
  opacity: 0.4;
}

/* Small index number at the top of each panel */
.panel__num {
  position: absolute;
  z-index: 1;
  top: 2rem;
  left: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0.7;
  transition: color 0.6s ease, opacity 0.6s ease;
}

/* One-liner pinned to the bottom of each panel */
.panel__line {
  position: absolute;
  z-index: 1;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 2rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.7;
  transition: color 0.6s ease, opacity 0.6s ease;
}

/* Active = hovered, focused, or the current one in the mobile cycle */
.panel.is-active {
  flex-grow: 2.4;
  background-color: var(--ink); /* shows if a video is missing */
}

.panel.is-active .panel__video,
.panel.is-active::after {
  opacity: 1;
}

.panel.is-active .panel__word,
.panel.is-active .panel__line,
.panel.is-active .panel__num {
  color: #fff;
}

.panel.is-active .panel__line,
.panel.is-active .panel__num {
  opacity: 0.9;
}

.panels:has(.is-active) .panel:not(.is-active) .panel__word {
  opacity: 0.45;
}

.panels:has(.is-active) .panel:not(.is-active) :is(.panel__line, .panel__num) {
  opacity: 0.3;
}

.panel:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -6px;
}

.panel.is-active:focus-visible {
  outline-color: #fff;
}

/* ---------- Phones: stack the three panels ---------- */

@media (max-width: 720px) {
  .panels {
    flex-direction: column;
  }

  .panel + .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  /* Panels are full width here, so cap the size instead */
  .panel__word {
    font-size: min(15cqi, 4rem);
  }

  .panel__line {
    bottom: 1.25rem;
    font-size: 0.6875rem;
  }

  .panel__num {
    top: 1.25rem;
  }

  .panels .thread {
    inset: auto;
    top: 50%;
    left: 50%;
    width: 100vh;
    width: 100svh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .panel__word,
  .panel__line {
    transition-duration: 0.01ms;
  }

  .thread__lines {
    animation: none;
  }
}
