/* ==========================================================================
   PREVIEW PROJECTS
   A pinned section that scrolls sideways. Each panel is a project: image +
   title; hovering lifts a coloured card carrying the description over it.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.mast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(0.9rem, 2vh, 1.5rem) var(--gutter);
  background: linear-gradient(to bottom, var(--paper) 55%, rgba(255, 255, 255, 0));
  pointer-events: none;
}

.mast > * { pointer-events: auto; }

.mast__home {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.4s var(--ease);
}

.mast__home:hover,
.mast__home:focus-visible { color: var(--ink); }

.mast__badge {
  width: 34px;
  height: 34px;
  transition: transform 0.6s var(--ease);
}

.mast__home:hover .mast__badge { transform: rotate(-18deg); }

.mast__title {
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   Sideways scroller
   -------------------------------------------------------------------------- */

.rail-driver { position: relative; }   /* height set by projects.js */

.rail-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  /* Cards sit near the top of the stage rather than centred in it. Centring
     left ~140px of slack above them, which read as a hole between the
     "Projects" title and the first card. The space below is not wasted: the
     scroll hint and the progress bar live down there. */
  align-items: flex-start;
  padding-top: clamp(0.75rem, 3vh, 2rem);
}

.rail-track {
  display: flex;
  align-items: stretch;
  gap: clamp(1rem, 2.2vw, 2.25rem);
  padding-inline: var(--gutter);
  will-change: transform;
}

/* --------------------------------------------------------------------------
   Project card
   -------------------------------------------------------------------------- */

.pcard {
  position: relative;
  flex: 0 0 auto;
  width: clamp(240px, 27vw, 400px);
  height: min(70vh, 620px);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

/* a little rhythm, as in the reference — panels are not all one width */
.pcard:nth-child(3n + 2) { width: clamp(240px, 32vw, 470px); }
.pcard:nth-child(4n + 3) { width: clamp(240px, 24vw, 350px); }

.pcard__head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.9rem;
  /* two lines' worth, so every image well starts on the same line */
  min-height: 3.6em;
}

.pcard__title {
  font-size: clamp(0.95rem, 1.15vw, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

/* --- the image well ----------------------------------------------------- */
.pcard__well {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background: var(--paper-warm);
}

.pcard__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
}

.pcard:hover .pcard__img,
.pcard:focus-visible .pcard__img {
  transform: scale(1.045);
  filter: saturate(0.85);
}

/* --- the description that rises over the image -------------------------- */
.pcard__veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.9rem;
  padding: clamp(1.1rem, 1.6vw, 1.75rem);
  overflow: hidden;
  transform: translateY(101%);
  transition: transform 0.72s var(--ease);
}

.pcard:hover .pcard__veil,
.pcard:focus-visible .pcard__veil { transform: translateY(0); }

.pcard__desc {
  font-size: clamp(0.72rem, 0.86vw, 0.9rem);
  line-height: 1.5;
  letter-spacing: -0.005em;
  overflow: hidden;
}

.pcard__desc p + p { margin-top: 0.85em; }

.pcard__desc strong { font-weight: 700; }

.pcard__open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding-top: 0.8rem;
  border-top: 1px solid currentColor;
  opacity: 0.75;
}

/* --- veil colour ways, drawn from the badge ----------------------------- */
.pcard[data-tone="amber"] .pcard__veil { background: var(--amber);      color: var(--navy-deep); }
.pcard[data-tone="navy"]  .pcard__veil { background: var(--navy);       color: #fff; }
.pcard[data-tone="peri"]  .pcard__veil { background: var(--peri);       color: var(--navy-deep); }
.pcard[data-tone="sun"]   .pcard__veil { background: var(--amber-bright); color: var(--navy-deep); }

/* --- work-in-progress card (no image) ----------------------------------- */
.pcard--wip .pcard__well {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  padding: clamp(1.25rem, 2vw, 2rem);
  background: var(--paper);
  border: 1px dashed var(--rule);
}

.pcard--wip .pcard__statement {
  font-size: clamp(1.1rem, 1.7vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.pcard--wip .pcard__wip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange);
}

.pcard--wip .pcard__wip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  animation: wip-pulse 1.8s ease-in-out infinite;
}

@keyframes wip-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.7); }
}

/* --- end plate ---------------------------------------------------------- */
.rail-end {
  flex: 0 0 auto;
  align-self: center;
  display: grid;
  gap: 0.6rem;
  padding-inline: clamp(2rem, 6vw, 6rem);
  max-width: 34ch;
}

.rail-end__word {
  font-size: clamp(1.6rem, 3vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

/* --------------------------------------------------------------------------
   Progress + hint
   -------------------------------------------------------------------------- */

.rail-hint {
  position: absolute;
  left: var(--gutter);
  bottom: clamp(1.5rem, 5vh, 3rem);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.5s var(--ease);
}

.rail-hint__arrow { animation: hint-slide 1.9s var(--ease) infinite; }

@keyframes hint-slide {
  0%, 100% { transform: translateX(0);    opacity: 0.4; }
  50%      { transform: translateX(0.5em); opacity: 1; }
}

.rail-bar {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 0;
  height: 2px;
  background: var(--rule);
}

.rail-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--amber);
  transform-origin: left;
}

/* --------------------------------------------------------------------------
   Touch / narrow / reduced motion — a plain vertical list, descriptions open
   -------------------------------------------------------------------------- */

@media (hover: none), (max-width: 860px), (prefers-reduced-motion: reduce) {
  .rail-driver { height: auto !important; }

  .rail-stage {
    position: static;
    height: auto;
    display: block;
    /* the old top padding cleared a fixed masthead; the rail lives on the
       home page now, under its own title, so it only needs a little air */
    padding: 1rem 0 4rem;
  }

  .rail-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: clamp(2rem, 5vw, 3rem);
    transform: none !important;
  }

  .pcard,
  .pcard:nth-child(3n + 2),
  .pcard:nth-child(4n + 3) {
    width: auto;
    height: auto;
  }

  .pcard__head { min-height: 0; }

  /* the well stops being a clipping frame so the description can sit below */
  .pcard__well {
    display: block;
    flex: none;
    overflow: visible;
    background: none;
  }

  .pcard__img {
    aspect-ratio: 4 / 5;
    height: auto;
    transform: none !important;
    filter: none !important;
  }

  .pcard__veil {
    position: static;
    transform: none;
    margin-top: 0.9rem;
    padding: clamp(1rem, 4vw, 1.5rem);
  }

  .pcard__desc { font-size: 0.875rem; max-height: none; }

  /* the work-in-progress card keeps its dashed frame */
  .pcard--wip .pcard__well {
    display: flex;
    min-height: 20rem;
    background: var(--paper);
    border: 1px dashed var(--rule);
  }

  .rail-hint { display: none; }
  .rail-bar { display: none; }

  .rail-end {
    max-width: none;
    padding: 2rem 0 0;
    border-top: 1px solid var(--rule);
  }
}

/* --- plain card (no image): white with the title, the text on hover ------ */
.pcard--plain .pcard__well {
  display: flex;
  align-items: flex-end;
  padding: clamp(1.25rem, 2vw, 2rem);
  background: var(--paper);
  border: 1px solid var(--rule);
}

.pcard--plain .pcard__statement {
  font-size: clamp(1.35rem, 2.4vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
}

/* the veil slides up over it exactly as it does over a photograph */
.pcard--plain .pcard__veil { justify-content: flex-end; }

/* the date sits at the far end of the card head, so the rail reads as a
   timeline: newest on the left, oldest on the right */
.pcard__when {
  margin-left: auto;
  align-self: baseline;
  flex: 0 0 auto;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
