/* La tipografía está en font.css */

:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #707070;
  --line: #e6e6e6;
  --soft: #f2f2f2;
  --error: #b3261e;

  --pad: clamp(14px, 1.6vw, 26px);
  --bar: 64px; /* alto reservado para la cabecera */
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

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

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html.is-home,
html.is-home body,
html.has-sheet {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Cabecera: texto blanco en modo «diferencia», así se ve negro sobre el
   blanco de la web y claro (invertido) sobre las fotos. */

.topbar {
  position: fixed;
  top: var(--pad);
  right: var(--pad);
  left: var(--pad);
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}

.topbar a {
  color: #fff;
  pointer-events: auto;
  text-decoration: none;
}

.topbar :focus-visible {
  outline-color: #fff;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.wordmark {
  font-stretch: 62%;
  font-weight: 780;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.004em;
}

.section-label {
  opacity: 0.7;
  font-size: 16px;
  font-weight: 500;
}

.topbar-link {
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
}

.topbar-link:hover,
.wordmark:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* Lista de proyectos para teclado y lectores de pantalla:
   solo se ve cuando uno de sus enlaces tiene el foco */

.index {
  position: fixed;
  top: calc(var(--pad) + 44px);
  left: var(--pad);
  z-index: 21;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.index:focus-within {
  width: auto;
  height: auto;
  clip: auto;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  background: var(--bg);
}

.index ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.index a {
  display: block;
  padding: 4px 0;
  font-stretch: 62%;
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
}

.hint {
  position: fixed;
  left: var(--pad);
  bottom: var(--pad);
  z-index: 5;
  margin: 0;
  color: #fff;
  mix-blend-mode: difference;
  font-size: 15px;
  font-weight: 500;
  pointer-events: none;
}

.hint.is-gone {
  opacity: 0;
}

.status {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 5;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.status[hidden] {
  display: none;
}

/* Lienzo infinito */

.canvas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.canvas:focus-visible {
  outline-offset: -3px;
}

.canvas.is-dragging {
  cursor: grabbing;
}

.world {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.tile {
  position: absolute;
  display: block;
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
}

.canvas.is-dragging .tile {
  cursor: grabbing;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  -webkit-user-drag: none;
  pointer-events: none;
}

.tile img.is-loaded {
  opacity: 1;
}

.tile-cap,
.tile-badge {
  position: absolute;
  color: #fff;
  mix-blend-mode: difference;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.tile-cap {
  left: 12px;
  bottom: 12px;
  opacity: 0;
}

.tile-badge {
  top: 12px;
  right: 12px;
  font-size: 13px;
}

@media (hover: hover) {
  .canvas:not(.is-dragging) .tile:hover .tile-cap {
    opacity: 1;
  }
}

/* Fichas (proyecto y contacto) */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}

.sheet[hidden] {
  display: none;
}

.sheet-close {
  position: fixed;
  top: var(--pad);
  right: var(--pad);
  z-index: 3;
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.sheet-close:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.project {
  display: grid;
  grid-template-areas:
    "head"
    "stage"
    "text";
  gap: 22px;
  padding: calc(var(--pad) + 4px) var(--pad) 64px;
}

.project-head {
  grid-area: head;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  /* en móvil el nombre comparte fila con «Cerrar» */
  padding-right: 90px;
}

.title {
  margin: 0;
  font-stretch: 62%;
  font-weight: 820;
  font-size: clamp(44px, 12vw, 88px);
  line-height: 0.84;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 0;
  font-size: 15px;
}

.meta dt {
  color: var(--muted);
}

.meta dd {
  margin: 0;
}

.stage {
  grid-area: stage;
  display: grid;
  grid-template-areas:
    "fig fig fig"
    "prev count next";
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  touch-action: pan-y;
}

.stage-media {
  grid-area: fig;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
}

.stage-media img,
.stage-media video {
  display: block;
  max-width: 100%;
  max-height: 52vh;
  max-height: 52svh;
  width: auto;
  height: auto;
  opacity: 0;
  -webkit-user-drag: none;
}

.stage-media img.is-loaded,
.stage-media video {
  opacity: 1;
}

.stage-media iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.arrow {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  cursor: pointer;
}

.arrow:hover {
  background: var(--line);
}

.arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arrow-prev {
  grid-area: prev;
}

.arrow-next {
  grid-area: next;
}

.count {
  grid-area: count;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.project-text {
  grid-area: text;
  width: 100%;
  max-width: 62ch;
  font-size: 16px;
  line-height: 1.6;
}

.project-text p {
  margin: 0 0 1em;
}

.next {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 36px;
}

.next-label {
  color: var(--muted);
  font-size: 15px;
}

.next a {
  font-stretch: 62%;
  font-weight: 760;
  font-size: 30px;
  line-height: 0.95;
  text-decoration: none;
}

.next a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* Contacto */

.contact {
  display: grid;
  gap: 32px;
  padding: calc(var(--pad) + 4px) var(--pad) 72px;
}

.portrait {
  display: grid;
  place-items: center;
  width: min(100%, 420px);
  aspect-ratio: 4 / 5;
  margin: 0;
  overflow: hidden;
  background: var(--soft);
  color: var(--muted);
  font-size: 15px;
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-body {
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
  max-width: 560px;
}

.contact-body .title {
  padding-right: 90px;
}

.about {
  font-size: 17px;
  line-height: 1.6;
}

.about p {
  margin: 0 0 1em;
}

.about p:last-child {
  margin-bottom: 0;
}

.contact-links a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.form-title {
  margin: 0;
  font-stretch: 62%;
  font-weight: 760;
  font-size: 30px;
  line-height: 1;
}

.contact-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 14px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-bottom-color: var(--ink);
}

.field[data-invalid] input,
.field[data-invalid] textarea {
  border-bottom-color: var(--error);
}

.field-error {
  margin: 0;
  color: var(--error);
  font-size: 13px;
}

.field-error:empty {
  display: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.send {
  padding: 14px 24px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.send:hover {
  background: #000;
}

.send[disabled] {
  opacity: 0.5;
  cursor: progress;
}

.form-status {
  margin: 0;
  font-size: 15px;
}

.form-status[data-kind="error"] {
  color: var(--error);
}

@media (min-width: 900px) {
  /* Todo cabe en una pantalla: nombre y texto a la izquierda, foto a la derecha */
  .project {
    grid-template-areas:
      "head stage"
      "text stage";
    grid-template-columns: minmax(260px, 27vw) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: clamp(24px, 3vw, 56px);
    row-gap: 28px;
    height: 100vh;
    height: 100svh;
    padding: calc(var(--pad) + 6px) var(--pad) var(--pad);
  }

  .project-head {
    gap: 18px;
    padding-right: 0;
  }

  .title {
    font-size: clamp(48px, 4.4vw, 92px);
  }

  .project-text {
    min-height: 0;
    max-width: 40ch;
    overflow-y: auto;
    padding-right: 6px;
  }

  /* Hueco arriba y abajo para que la foto nunca toque «Cerrar» */
  .stage {
    grid-template-areas:
      "prev fig next"
      ". count .";
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    grid-template-rows: auto auto;
    align-content: center;
    gap: 16px clamp(14px, 2vw, 32px);
    height: 100%;
    min-height: 0;
    padding: calc(var(--bar) + 6px) 0 calc(var(--bar) - 26px);
  }

  .stage-media img,
  .stage-media video {
    max-height: min(70vh, calc(100vh - var(--pad) * 2 - var(--bar) * 2 - 70px));
    max-height: min(70svh, calc(100svh - var(--pad) * 2 - var(--bar) * 2 - 70px));
  }

  .stage-media iframe {
    max-height: 100%;
  }

  .contact {
    grid-template-columns: minmax(260px, 34vw) minmax(0, 1fr);
    column-gap: clamp(32px, 5vw, 96px);
    align-items: start;
    padding-top: calc(var(--pad) + 6px);
  }

  .portrait {
    position: sticky;
    top: calc(var(--pad) + 6px);
    width: 100%;
    max-height: calc(100svh - var(--pad) * 2 - 12px);
  }

  .contact-body .title {
    padding-right: 0;
    font-size: clamp(56px, 6vw, 112px);
  }
}

@media (max-width: 759px) {
  .wordmark {
    font-size: 26px;
  }

  .portrait {
    width: 72%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .tile img,
  .stage-media img {
    transition: opacity 0.35s ease;
  }

  .tile-cap {
    transition: opacity 0.15s ease;
  }

  .hint {
    transition: opacity 0.6s ease;
  }

  .sheet.is-entering {
    animation: sheet-in 0.22s ease-out;
  }

  @keyframes sheet-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}
