/*
 * ERDAN Portal — the WebGL front page.
 *
 * Two modes, same HTML:
 *  · default: a calm, readable page with a list of projects and their images (no WebGL, reduced motion,
 *    or before main-3d.js has started);
 *  · html.portal-3d: the scene runs on the fixed canvas behind everything, the flight section becomes a
 *    tall scroll track, and each project link is laid exactly over its glass slab by main-3d.js.
 */

body.erdan-portal-front {
  background: #020204;
}

#webgl-portfolio-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 900ms cubic-bezier(0.23, 1, 0.32, 1);
}

html.portal-3d #webgl-portfolio-canvas {
  opacity: 1;
}

html:not(.portal-3d) #webgl-portfolio-canvas {
  visibility: hidden;
}

.portal {
  position: relative;
  z-index: 1;
  color: var(--paper, #e5e7eb);
}

.portal-eyebrow {
  margin: 0;
  font: 500 0.75rem/1.4 var(--font-body, Inter, system-ui, sans-serif);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-2, #bcc0c8);
}

.portal-lede {
  max-width: 34rem;
  margin: 1.4rem 0 0;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  line-height: 1.65;
  color: var(--paper-2, #bcc0c8);
}

/* ─── Hero ─────────────────────────────────────────────────────────────────── */

.portal-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100svh;
  padding: 7rem var(--gutter, clamp(1rem, 4vw, 3rem)) clamp(4.5rem, 10vh, 7rem);
}

.portal-hero__inner {
  max-width: 46rem;
}

.portal-title {
  margin: 1rem 0 0;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(2.6rem, 1.4rem + 5.2vw, 6.4rem);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.portal-title__line {
  display: block;
}

.portal-title strong {
  font-weight: 500;
}

.portal-grad {
  font-style: normal;
  background: var(--grad, linear-gradient(90deg, #4f9bff, #a855f7));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  min-height: 3.25rem;
  padding: 0 1.6rem;
  border-radius: 999px;
  font: 500 0.95rem/1.2 var(--font-body, Inter, system-ui, sans-serif);
  text-decoration: none;
  transition:
    transform 160ms cubic-bezier(0.23, 1, 0.32, 1),
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease;
}

.portal-btn:active {
  transform: scale(0.97);
}

.portal-btn--solid {
  background: var(--paper, #e5e7eb);
  color: var(--accent-ink, #05060b);
}

.portal-btn--solid:hover {
  background: #fff;
}

.portal-btn--ghost {
  border: 1px solid rgb(229 231 235 / 0.28);
  color: var(--paper, #e5e7eb);
  background: rgb(2 2 4 / 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.portal-btn--ghost:hover {
  border-color: rgb(229 231 235 / 0.6);
}

.portal-btn:focus-visible,
.portal-work__link:focus-visible {
  outline: 2px solid var(--accent, #4f9bff);
  outline-offset: 4px;
}

.portal-cue {
  position: absolute;
  right: var(--gutter, clamp(1rem, 4vw, 3rem));
  bottom: clamp(1.5rem, 4vh, 2.5rem);
  display: none;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  font: 500 0.7rem/1 var(--font-body, Inter, system-ui, sans-serif);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-3, #959aa5);
}

.portal-cue span {
  width: 1px;
  height: 2.2rem;
  background: linear-gradient(to bottom, transparent, var(--accent, #4f9bff));
}

html.portal-3d .portal-cue {
  display: flex;
}

/* ─── Featured work: the readable list (default) ───────────────────────────── */

.portal-flight {
  position: relative;
  padding: clamp(4rem, 10vh, 7rem) var(--gutter, clamp(1rem, 4vw, 3rem));
}

.portal-work-head {
  margin-bottom: 2.5rem;
}

.portal-work-line {
  margin: 0.8rem 0 0;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(1.8rem, 1.2rem + 2.4vw, 3.2rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.portal-works {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-work__link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
}

.portal-work__magnet {
  position: relative;
  display: grid;
  gap: 0.35rem;
  height: 100%;
  padding: 0 0 1.25rem;
  border: 1px solid rgb(229 231 235 / 0.1);
  border-radius: 14px;
  background: rgb(26 26 31 / 0.55);
  overflow: hidden;
}

.portal-work__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  margin-bottom: 0.9rem;
}

.portal-work__num,
.portal-work__title,
.portal-work__cat,
.portal-work__view {
  padding: 0 1.25rem;
}

.portal-work__num {
  font: 500 0.7rem/1 var(--font-body, Inter, system-ui, sans-serif);
  letter-spacing: 0.2em;
  color: var(--accent, #4f9bff);
}

.portal-work__title {
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.portal-work__cat {
  font-size: 0.9rem;
  color: var(--paper-2, #bcc0c8);
}

.portal-work__view {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--paper, #e5e7eb);
}

/* ─── Featured work: the 3D flight ─────────────────────────────────────────── */

/* The track: its height is the length of the flight (the portal, then one stretch per project). */
html.portal-3d .portal-flight {
  height: calc((var(--count, 4) * 0.85 + 1.6) * 100svh);
  padding: 0;
}

html.portal-3d .portal-stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}

html.portal-3d .portal-work-head {
  position: absolute;
  top: clamp(5.5rem, 14vh, 8rem);
  left: var(--gutter, clamp(1rem, 4vw, 3rem));
  margin: 0;
  opacity: var(--head, 0);
  transform: translate3d(0, calc((1 - var(--head, 0)) * 12px), 0);
  pointer-events: none;
}

html.portal-3d .portal-works {
  display: block;
}

/* Each link is placed over its slab: main-3d.js writes transform, width, height and opacity. */
html.portal-3d .portal-work {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  will-change: transform, opacity;
}

html.portal-3d .portal-work[data-active="false"] {
  pointer-events: none;
}

html.portal-3d .portal-work__magnet {
  align-content: end;
  border: 0;
  padding: 0 0 clamp(0.9rem, 2vw, 1.4rem);
  background: linear-gradient(to top, rgb(2 2 4 / 0.82), rgb(2 2 4 / 0) 55%);
  will-change: transform;
}

html.portal-3d .portal-work__img {
  display: none;
}

html.portal-3d .portal-work__view {
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  transition:
    opacity 220ms ease,
    transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

html.portal-3d .portal-work[data-hover="true"] .portal-work__view {
  opacity: 1;
  transform: none;
  transition-duration: 480ms;
}

/* Narrow screens: the slab is short, so the title sits under it instead of over the screenshot. */
@media (max-width: 699.98px) {
  html.portal-3d .portal-work__magnet {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: auto;
    padding: 0.9rem 0 0;
    background: none;
    border-radius: 0;
    overflow: visible;
  }

  html.portal-3d .portal-work__num,
  html.portal-3d .portal-work__title,
  html.portal-3d .portal-work__cat,
  html.portal-3d .portal-work__view {
    padding: 0;
  }

  html.portal-3d .portal-work__view {
    opacity: 1;
    transform: none;
  }
}

/* ─── Sections after the flight: services, about, closing ──────────────────── */

.portal-section {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(5rem, 14vh, 9rem) var(--gutter, clamp(1rem, 4vw, 3rem));
}

.portal-index {
  display: inline-block;
  margin-right: 0.9em;
  padding-right: 0.9em;
  border-right: 1px solid rgb(229 231 235 / 0.25);
  color: var(--accent, #4f9bff);
}

.portal-section__title {
  max-width: 20ch;
  margin: 1.1rem 0 0;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(2rem, 1.3rem + 2.9vw, 3.9rem);
  font-weight: 300;
  line-height: 1.03;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

/* Services: four glass panels; the border lights where the pointer is */
.portal-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: clamp(2.5rem, 6vh, 4rem) 0 0;
  padding: 0;
  list-style: none;
}

.portal-card {
  --x: 50%;
  --y: 0%;
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.8rem;
  min-height: 15rem;
  padding: 1.75rem 1.6rem 1.9rem;
  border-radius: 20px;
  background:
    radial-gradient(28rem circle at var(--x) var(--y), rgb(79 155 255 / 0.1), transparent 45%),
    linear-gradient(180deg, rgb(255 255 255 / 0.045), rgb(255 255 255 / 0.015));
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.07),
    0 30px 60px -30px rgb(0 0 0 / 0.6);
  transition: transform 480ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* a 1px border drawn with a gradient that follows the pointer */
.portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background:
    radial-gradient(18rem circle at var(--x) var(--y), rgb(130 180 255 / 0.75), rgb(168 85 247 / 0.35) 40%, rgb(255 255 255 / 0.08) 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.portal-card:hover {
  transform: translate3d(0, -4px, 0);
}

.portal-card__icon {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0.55rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgb(79 155 255 / 0.18), rgb(168 85 247 / 0.18));
  color: #cfe0ff;
}

.portal-card__title {
  margin: 0.8rem 0 0;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.portal-card__text {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--paper-2, #bcc0c8);
}

/* About */
.portal-about__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: end;
}

.portal-about__title {
  max-width: 14ch;
}

.portal-about .portal-lede {
  max-width: 38rem;
  margin: 0;
  font-size: clamp(1.05rem, 0.98rem + 0.35vw, 1.22rem);
  color: var(--paper, #e5e7eb);
}

.portal-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--paper-2, #bcc0c8);
}

.portal-facts li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.6rem;
  border-radius: 50%;
  vertical-align: 0.1em;
  background: var(--grad, linear-gradient(90deg, #4f9bff, #a855f7));
}

.portal-shipped {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.6rem;
  margin-top: clamp(3rem, 8vh, 5rem);
  padding-top: 1.6rem;
  border-top: 1px solid rgb(229 231 235 / 0.1);
}

.portal-shipped__label {
  margin: 0;
  font: 500 0.72rem/1 var(--font-body, Inter, system-ui, sans-serif);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-3, #959aa5);
}

.portal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-chip {
  padding: 0.5rem 0.95rem;
  border: 1px solid rgb(229 231 235 / 0.14);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.03);
  font-size: 0.86rem;
  color: var(--paper, #e5e7eb);
}

.portal-chip__note {
  color: var(--paper-3, #959aa5);
}

.portal-chip--pending {
  border-style: dashed;
}

/* Closing: one glass panel, the email as a direct line */
.portal-closing {
  text-align: center;
}

.portal-closing__panel {
  position: relative;
  padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 5vw, 5rem);
  border-radius: 32px;
  background:
    radial-gradient(60% 80% at 50% 0%, rgb(79 155 255 / 0.16), transparent 70%),
    radial-gradient(50% 70% at 85% 100%, rgb(168 85 247 / 0.14), transparent 70%),
    rgb(8 8 16 / 0.35);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), inset 0 1px 0 rgb(255 255 255 / 0.1);
}

.portal-closing .portal-lede {
  margin-inline: auto;
}

.portal-closing .portal-actions {
  justify-content: center;
}

.portal-closing__title {
  max-width: 18ch;
  margin: 1.2rem auto 0;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(2.2rem, 1.3rem + 3.8vw, 4.8rem);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.portal-mail {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem 1rem;
  margin: 2.6rem 0 0;
  font-size: 0.9rem;
  color: var(--paper-3, #959aa5);
}

.portal-mail a {
  position: relative;
  font-family: var(--font-display, "Space Grotesk", system-ui, sans-serif);
  font-size: clamp(1.4rem, 1rem + 1.6vw, 2.2rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--paper, #e5e7eb);
  text-decoration: none;
}

.portal-mail a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.15em;
  height: 1px;
  background: var(--grad, linear-gradient(90deg, #4f9bff, #a855f7));
  transform: scaleX(0.25);
  transform-origin: left;
  transition: transform 480ms cubic-bezier(0.23, 1, 0.32, 1);
}

.portal-mail a:hover::after,
.portal-mail a:focus-visible::after {
  transform: scaleX(1);
}

/* Reveal on scroll — only once the scene runs; without it everything is simply there */
html.portal-3d [data-portal-reveal] {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition:
    opacity 700ms cubic-bezier(0.23, 1, 0.32, 1) calc(var(--d, 0) * 90ms),
    transform 900ms cubic-bezier(0.23, 1, 0.32, 1) calc(var(--d, 0) * 90ms);
}

html.portal-3d [data-portal-reveal].is-in {
  opacity: 1;
  transform: none;
}

@media (max-width: 1099.98px) {
  .portal-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-about__grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 599.98px) {
  .portal-cards {
    grid-template-columns: 1fr;
  }

  .portal-card {
    min-height: 0;
  }
}

@media (max-width: 539.98px) {
  .portal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-btn {
    justify-content: center;
    text-align: center;
  }
}
