/* ============================================================
   pol roig · style (polroig2)
   mobile-first, minimal
   ============================================================ */

:root {
  --bg: #000;
  --fg: #fff;
  --accent: #f00;
  --muted: #ccc;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --swap-dur: 1100ms;

  --header-h: 3.25rem;

  /* pad-x scales with viewport — desktop gap mirrors this so the rhythm
     pad | stage | gap | side | pad stays balanced at any width */
  --pad-x: clamp(1.25rem, 4vw, 6rem);

  /* hard cap on content width so ultra-wide screens stay readable */
  --max-w: 1600px;
}

/* -------- reset / base -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color: var(--fg); }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--fg);
  min-height: 100svh;
  overflow-x: hidden;
  text-wrap: pretty;
}
a { color: inherit; text-decoration: none; }
button {
  font: inherit; color: inherit;
  background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
img { max-width: 100%; display: block; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.view[hidden] { display: none !important; }

/* -------- top bar -------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem var(--pad-x);
  max-width: var(--max-w);
  margin: 0 auto;
  position: relative;
  z-index: 20;
}
.logo {
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.lang { position: relative; }
.lang__toggle {
  color: var(--accent);
  font-size: 1rem;
}
.lang__menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.35rem;
  background: var(--bg);
  padding: 0.25rem 0;
  text-align: right;
  min-width: 3rem;
}
.lang__menu[hidden] { display: none; }
.lang__menu li a {
  display: block;
  padding: 0.2rem 0.4rem;
  color: var(--accent);
}
.lang__menu li a[aria-current="true"] { opacity: 0.5; }

/* ==============================================================
   HOME
   Mobile / portrait: stage on top (2/3 height), side underneath
   (cloud 1/3 height + texts below).
   Desktop / landscape: stage 2/3 width on the left, side 1/3 on the
   right (cloud on top, texts under).
   ============================================================== */
.home {
  padding: 0 var(--pad-x) 1.5rem;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: calc(100dvh - var(--header-h));
}

/* ---- stage (mirilla area) ---- */
.home__stage {
  position: relative;
  width: 100%;
  height: calc((100dvh - var(--header-h)) * 2 / 3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mirilla {
  display: block;
  position: relative;
  width: min(100%, calc((100dvh - var(--header-h)) * 2 / 3 - 1rem));
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  view-transition-name: mirilla;
  cursor: pointer;
}
.mirilla__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Mirilla swap — two sequential OPENINGS (no closing):
   1) a black iris grows from the centre out, covering the old image;
   2) on top, the new image is revealed by a circle that also grows
      from the centre out. Meanwhile the whole mirilla spins.
   The ::after reveal layer only exists while .is-swapping, so the
   resting-state mirilla stays clean (important for the page
   view-transition snapshot — otherwise an invisible pseudo-element
   can make the morph look broken). */
.mirilla__iris {
  position: absolute;
  inset: 0;
  background: #000;
  pointer-events: none;
  clip-path: circle(0% at 50% 50%);
}
.mirilla.is-swapping::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--next-img, none);
  background-size: cover;
  background-position: center;
  pointer-events: none;
  clip-path: circle(0% at 50% 50%);
  animation: iris-grow 950ms 150ms var(--ease-soft) forwards;
}
.mirilla.is-swapping {
  animation: mirilla-spin var(--swap-dur) var(--ease-soft);
}
.mirilla.is-swapping .mirilla__iris {
  animation: iris-grow 950ms var(--ease-soft) forwards;
}
@keyframes iris-grow {
  from { clip-path: circle(0% at 50% 50%); }
  to   { clip-path: circle(75% at 50% 50%); }
}
@keyframes mirilla-spin {
  from { rotate: 0deg; }
  to   { rotate: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
  .mirilla.is-swapping,
  .mirilla.is-swapping .mirilla__iris,
  .mirilla.is-swapping::after { animation-duration: 1ms; }
}

/* ---- side (cloud + texts) ---- */
.home__side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}
.cloud {
  position: relative;
  width: 100%;
  height: calc((100dvh - var(--header-h)) * 1 / 3);
  min-height: 10rem;
}
.cloud__item {
  position: absolute;
  display: inline-block;
  font-size: 0.95rem;
  line-height: 1.15;
  padding: 0.2em 0.35em;
  color: var(--fg);
  opacity: 0.75;
  white-space: nowrap;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
  cursor: pointer;
  text-wrap: balance;
}
.cloud__item:hover { opacity: 1; color: var(--accent); }
.cloud__item[data-active="true"] {
  opacity: 1;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 32rem;
}
.synopsis, .bio-frag {
  font-size: 0.92rem;
  line-height: 1.5;
}
.bio-frag { color: var(--muted); }

/* ==============================================================
   PROYECTO PAGE (unchanged from polroig)
   ============================================================== */
@keyframes proyecto-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.proyecto__head,
.proyecto__synopsis,
.proyecto__text,
.proyecto__creditos,
.proyecto__back {
  animation: proyecto-rise 0.5s var(--ease) both;
}
.proyecto__head      { animation-delay: 0.10s; }
.proyecto__synopsis  { animation-delay: 0.22s; }
.proyecto__text      { animation-delay: 0.30s; }
.proyecto__creditos  { animation-delay: 0.38s; }
.proyecto__back      { animation-delay: 0.55s; }

.proyecto__gallery img {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.proyecto__gallery img.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .proyecto__head,
  .proyecto__synopsis,
  .proyecto__text,
  .proyecto__creditos,
  .proyecto__back,
  .proyecto__gallery img {
    animation: none;
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.proyecto {
  padding: 0 var(--pad-x) 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
}
.proyecto__article {
  max-width: 46rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.proyecto__head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
}
.proyecto__title {
  font-size: 1.5rem;
  font-weight: normal;
  margin: 0;
}
.proyecto__sub {
  color: var(--muted);
  font-size: 0.9rem;
}
.proyecto__mirilla {
  position: relative;
  width: 80%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  margin: 0.5rem auto 1rem;
  background: transparent;
  view-transition-name: mirilla;
}
.proyecto__synopsis {
  font-style: italic;
  color: var(--muted);
}
.proyecto__text {
  line-height: 1.55;
}
.proyecto__creditos li {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
}
.proyecto__creditos li::before {
  content: "·";
}
.proyecto__gallery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.proyecto__gallery img {
  width: 100%;
  height: auto;
}
.proyecto__back {
  margin-top: 2rem;
  align-self: center;
  color: var(--accent);
}

/* ==============================================================
   DESKTOP / LANDSCAPE: two columns (2/3 + 1/3)
   ============================================================== */
@media (min-width: 900px) {
  .home {
    flex-direction: row;
    align-items: stretch;
    gap: var(--pad-x);
    height: calc(100dvh - var(--header-h));
    min-height: 0;
    padding-bottom: 1.5rem;
    overflow: hidden;
  }
  .home__stage {
    flex: 0 0 calc((100% - var(--pad-x)) * 2 / 3);
    height: 100%;
  }
  .mirilla {
    width: min(100%, calc(100dvh - var(--header-h) - 3rem));
    height: auto;
  }
  .home__side {
    flex: 0 0 calc((100% - var(--pad-x)) * 1 / 3);
    height: 100%;
    justify-content: space-between;
  }
  .cloud {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }
  .project-info {
    flex: 0 0 auto;
    padding-bottom: 0.5rem;
  }

  .proyecto__article { max-width: 64rem; }
}

/* ==============================================================
   VIEW TRANSITIONS
   ============================================================== */
@keyframes vt-fade-in  { from { opacity: 0 } }
@keyframes vt-fade-out { to   { opacity: 0 } }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 420ms;
  animation-timing-function: var(--ease);
}
::view-transition-old(root) { animation-name: vt-fade-out; }
::view-transition-new(root) { animation-name: vt-fade-in; }

::view-transition-old(mirilla),
::view-transition-new(mirilla) {
  animation-duration: 520ms;
  animation-timing-function: var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  ::view-transition-old(mirilla),
  ::view-transition-new(mirilla) {
    animation-duration: 1ms;
  }
}
