/* ============================================================
   BASE — reset, typography primitives, shared utilities
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--c-bg);
  color: var(--c-dark);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

/* Components below set display:flex/grid on elements that are also
   toggled with the `hidden` attribute, which would otherwise win over
   the UA's [hidden] rule and leave "hidden" controls focusable. */
[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

/* Visible, on-brand focus for every interactive element. */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Only suppress the ring for pointer users who already see hover feedback. */
:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-2);
  z-index: 10000;
  padding: 0.75rem 1.25rem;
  background: var(--c-dark);
  color: var(--c-warm);
  border-radius: var(--radius-pill);
  font-size: var(--fs-small);
  transition: top var(--dur-fast) var(--ease-smooth);
}

.skip-link:focus {
  top: var(--sp-2);
}

/* ===== Layout shells ===== */

.shell {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--section-y);
}

/* Anchor targets stop short of the fixed nav instead of sliding under it. */
[id] {
  scroll-margin-top: clamp(4rem, 9vw, 7rem);
}

.section--pale {
  background: var(--c-bg-pale);
}

.section--dark {
  background: var(--c-deep);
  color: var(--c-warm);
}

/* ===== Typography primitives ===== */

.display {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  font-weight: 500;
}

.eyebrow {
  display: inline-block;
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--c-muted);
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: clamp(2.5rem, 6vw, 5rem);
}

.section-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.section-head__title {
  font-size: var(--fs-h2);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-heading);
  font-weight: 500;
  max-width: 16ch;
}

.section-head__lead {
  font-size: var(--fs-lead);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--c-muted);
  max-width: 34ch;
}

.section--dark .section-head__lead,
.section--dark .eyebrow {
  color: var(--c-on-dark-muted);
}

.rule {
  height: 1px;
  background: var(--c-line);
  border: 0;
}

/* ===== Text link with sliding underline ===== */

.link-underline {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-small);
  font-weight: 500;
  padding-block: 0.25rem;
}

.link-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform-origin: right;
  transform: scaleX(1);
  transition: transform var(--dur-fast) var(--ease-smooth);
}

.link-underline:hover::after {
  transform-origin: left;
  transform: scaleX(0);
}

.link-underline svg {
  transition: transform var(--dur-fast) var(--ease-smooth);
}

.link-underline:hover svg {
  transform: translate(3px, -3px);
}

/* ===== Scroll reveal (driven by IntersectionObserver) ===== */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.9s var(--ease-expressive),
    transform 0.9s var(--ease-expressive);
  transition-delay: var(--reveal-delay, 0s);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ===== Reduced motion =====
   Entrances resolve instantly; the site stays fully usable.
   `html.force-motion` (set by the ?motion=on override) opts back in. */
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) {
    scroll-behavior: auto;
  }

  html:not(.force-motion) *,
  html:not(.force-motion) *::before,
  html:not(.force-motion) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html:not(.force-motion) .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ===== Text card — stand-in for items without a photo ===== */

.text-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6rem;
  width: 100%;
  height: 100%;
  padding: clamp(1.1rem, 2.5vw, 2rem);
  overflow: hidden;
  isolation: isolate;
}

/* Two thin rings in the corner — decoration only. */
.text-card::before,
.text-card::after {
  content: '';
  position: absolute;
  z-index: -1;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.16;
  pointer-events: none;
}

.text-card::before {
  top: -30%;
  right: -25%;
  width: 85%;
  aspect-ratio: 1;
}

.text-card::after {
  top: -12%;
  right: -8%;
  width: 50%;
  aspect-ratio: 1;
}

.text-card--dark {
  background:
    radial-gradient(circle at 85% 10%, rgba(117, 197, 222, 0.28), transparent 55%),
    var(--c-deep);
  color: var(--c-warm);
}

.text-card--accent {
  background: linear-gradient(140deg, #8fd3e8 0%, var(--c-accent) 45%, #3f8fae 100%);
  color: var(--c-deep);
}

.text-card--warm {
  background:
    radial-gradient(circle at 85% 10%, rgba(117, 197, 222, 0.22), transparent 55%),
    var(--c-warm);
  color: var(--c-dark);
}

.text-card__eyebrow,
.text-card__sub {
  font-size: var(--fs-meta);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  opacity: 0.7;
}

.text-card__title {
  font-size: clamp(1.35rem, 2.6vw, 2.1rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Scroll progress bar ===== */

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  height: 3px;
  background: var(--c-accent);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
}

/* ===== Scroll animations ===== */

/* Reveals also come into focus as they rise. */
.reveal {
  filter: blur(6px);
  transition:
    opacity 0.9s var(--ease-expressive),
    transform 0.9s var(--ease-expressive),
    filter 0.9s var(--ease-expressive);
  transition-delay: var(--reveal-delay, 0s);
}

.reveal.is-visible {
  filter: none;
}

/* Photos drift gently against the scroll. Uses scroll-driven animations
   where supported (no JS); other browsers simply skip it. The individual
   `translate`/`scale` properties compose with the hover `transform`
   zooms rather than replacing them. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .project__img,
    .teaser__img,
    .intro__figure img,
    .detail__figure img,
    img.news-card__img {
      animation: pf-parallax linear both;
      animation-timeline: view();
      animation-range: cover;
    }

    .section-head__title {
      animation: pf-title-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 35%;
    }
  }
}

@keyframes pf-parallax {
  from { translate: 0 -4%; scale: 1.1; }
  to { translate: 0 4%; scale: 1.1; }
}

@keyframes pf-title-in {
  from { letter-spacing: 0.02em; opacity: 0.35; }
  to { letter-spacing: normal; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .reveal {
    filter: none !important;
  }

  html:not(.force-motion) .scroll-progress {
    display: none;
  }
}
