/* ─── Arxiu Balear · Landing de pròximament ───────────────────────
   Mateixa identitat que la web principal (src/app/globals.css),
   en versió fosca: carbó càlid, paper envellit i tinta de segell. */

@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/libre-caslon-text-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Caslon Text";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/libre-caslon-text-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  /* Colors */
  --bg: #0b0a09; /* negre càlid */
  --surface: #151311; /* carbó */
  --paper: #ebe3d2; /* text principal · 15,5:1 */
  --muted: #a69d8d; /* text secundari · 7,4:1 */
  --rule: #2e2a25; /* línies fines */
  --rule-strong: #4a443c;
  --seal: #9e2424; /* vermell de segell de la marca (només elements gràfics) */
  --seal-ink: #cc5a4f; /* tinta del segell amb text · 4,8:1 sobre el fons */

  /* Tipografia */
  --serif: "Libre Caslon Text", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Espai */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 46rem;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--bg);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Capa fixa (no es talla en fer scroll): llum molt tènue sobre la taula de l'arxiu
   i gra de paper pràcticament imperceptible */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgb(236 228 211 / 0.035) 0%, transparent 72%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .92 0 0 0 0 .89 0 0 0 0 .82 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
  background: color-mix(in srgb, var(--seal) 55%, transparent);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
  border-radius: 2px;
}

p,
dl,
dd,
h1 {
  margin: 0;
}

/* ─── Composició ───────────────────────────────────────────── */

.page {
  position: relative; /* per sobre del gra */
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  padding-inline: var(--gutter);
}

/* Etiquetes d'arxiu (monoespaiades) */
.ref,
.label,
.record dt,
.record dd,
.colophon {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.3;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ─── Capçalera ────────────────────────────────────────────── */

.masthead {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-top: clamp(1.25rem, 3vw, 2rem);
}

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-emblem {
  display: block;
  width: 3.5rem;
  height: 3.5rem;
}

.brand-name {
  font-size: 1.125rem;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ref {
  color: var(--muted);
}

/* Regle de registre: marques curtes cada 12 px i llargues cada 60 px */
.ruler {
  height: 9px;
  border-top: 1px solid var(--rule-strong);
  background:
    repeating-linear-gradient(90deg, var(--rule-strong) 0 1px, transparent 1px 60px) top left / 100% 8px no-repeat,
    repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 12px) top left / 100% 4px no-repeat;
}

/* ─── Bloc principal ───────────────────────────────────────── */

.access {
  align-self: center;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-block: clamp(3rem, 10vh, 6.5rem);
}

.label {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  color: var(--muted);
}
.label::before {
  content: "";
  flex: none;
  width: 2.25rem;
  height: 1px;
  background: var(--seal);
}

.headline {
  margin-top: 1.75rem;
  max-width: 16ch;
  font-weight: 400;
  font-size: clamp(2.25rem, 1.3rem + 4.4vw, 4.5rem);
  line-height: 1.08;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.headline em {
  font-style: italic;
  color: var(--paper);
}

.lede {
  margin-top: 1.75rem;
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(1.0625rem, 0.98rem + 0.4vw, 1.25rem);
  line-height: 1.6;
  text-wrap: pretty;
}

/* Enllaç de tornada (pàgina 404) */
.back {
  margin-top: 2.5rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.back a {
  display: inline-block;
  padding-block: 0.5rem;
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--seal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}
.back a:hover {
  text-decoration-color: currentColor;
}

/* Fitxa de registre */
.record {
  display: grid;
  grid-template-columns: 1fr auto;
  margin-top: clamp(2.5rem, 6vh, 3.5rem);
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}

.record-cell {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.875rem;
  padding: 1rem 0 1.125rem;
}

.record-cell--status {
  align-items: flex-start;
  padding-left: clamp(1.25rem, 4vw, 2.5rem);
  border-left: 1px solid var(--rule);
}

.record dt {
  color: var(--muted);
  font-size: 0.6875rem;
}
.record dd {
  color: var(--paper);
}

/* Segell estampat: doble vora, lleugera rotació i tinta irregular */
.stamp {
  display: inline-block;
  padding: 0.7em 0.85em 0.65em 1.07em; /* compensa l'espaiat de lletres */
  color: var(--seal-ink);
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.22em;
  white-space: nowrap;
  border: 2px solid currentColor;
  box-shadow:
    inset 0 0 0 3px var(--bg),
    inset 0 0 0 4px currentColor;
  transform: rotate(-3.5deg);
  /* Imperfecció d'impressió controlada: petites zones on la tinta no ha agafat */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -9 0 0 0 6.4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -9 0 0 0 6.4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  -webkit-mask-size: 180px 180px;
  mask-size: 180px 180px;
}

/* ─── Índex d'enllaços (/links) ────────────────────────────── */

/* La marca és un enllaç a l'inici en aquesta pàgina */
a.brand {
  color: inherit;
  text-decoration: none;
}

.headline--compact {
  font-size: clamp(2rem, 1.3rem + 3.2vw, 3.5rem);
}

.links {
  margin: clamp(2.25rem, 5vh, 3rem) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule-strong);
}
.links > li {
  border-bottom: 1px solid var(--rule);
}

/* Cada fila: número · nom · detall · fletxa */
.link {
  display: grid;
  grid-template-columns: 2.75rem 1fr auto 1rem;
  grid-template-areas: "num name detail arrow";
  align-items: center;
  column-gap: 1rem;
  min-height: 4.25rem;
  padding: 0.875rem 0.25rem;
  color: var(--paper);
  text-decoration: none;
  transition: background-color 160ms ease;
}
a.link:hover {
  background-color: color-mix(in srgb, var(--surface) 70%, transparent);
}

.link-num {
  grid-area: num;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
}

.link-name {
  grid-area: name;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.2;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  transition: text-decoration-color 160ms ease;
}
a.link:hover .link-name {
  text-decoration-color: var(--seal);
}

.link-detail {
  grid-area: detail;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
/* Adreces i noms d'usuari, en minúscules, com s'escriuen */
.link-detail--mail {
  text-transform: none;
  letter-spacing: 0.04em;
}

.link-arrow {
  grid-area: arrow;
  width: 1rem;
  height: 1rem;
  color: var(--seal-ink);
  transition: transform 160ms ease;
}
a.link:hover .link-arrow {
  transform: translate(2px, -2px);
}

.link--pending .link-name {
  color: var(--muted);
}

.stamp--small {
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
}

/* ─── Peu de pàgina ────────────────────────────────────────── */

.colophon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-block: 1.25rem clamp(1.25rem, 3vw, 2rem);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.6875rem;
}
.colophon-name {
  color: var(--paper);
}
.colophon-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.75rem; /* l'espai vertical ja el dona el farciment dels enllaços */
}
/* Contacte i xarxes (amb zona tàctil d'almenys 24 px) */
.colophon-meta {
  align-items: center;
}
.colophon a {
  display: inline-block;
  padding-block: 0.375rem;
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--seal);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}
.colophon a:hover {
  text-decoration-color: currentColor;
}
/* El correu, en minúscules, com s'escriu */
.colophon .mail {
  text-transform: none;
  letter-spacing: 0.04em;
}

/* ─── Mòbil ────────────────────────────────────────────────── */

@media (max-width: 34rem) {
  .brand-emblem {
    width: 2.75rem;
    height: 2.75rem;
  }
  .brand-name {
    font-size: 1rem;
    letter-spacing: 0.12em;
  }
  .ref {
    font-size: 0.6875rem;
  }
  .access {
    padding-block: 3rem 3.5rem;
  }
  .headline {
    margin-top: 1.375rem;
  }
  /* La fitxa passa a una sola columna: referència a dalt, estat a baix */
  .record {
    grid-template-columns: 1fr;
  }
  .record-cell--status {
    padding-left: 0;
    padding-bottom: 1.5rem;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .colophon {
    flex-direction: column;
    align-items: flex-start;
  }
  /* El detall de cada enllaç passa a sota del nom */
  .link {
    grid-template-columns: 2.25rem 1fr 1rem;
    grid-template-areas:
      "num name arrow"
      ". detail arrow";
    row-gap: 0.375rem;
  }
  .link-detail {
    justify-self: start;
  }
  .stamp--small {
    margin-top: 0.375rem;
  }
}

/* Pantalles molt estretes: el lema del peu cap en una sola línia */
@media (max-width: 22.5rem) {
  .colophon {
    letter-spacing: 0.06em;
  }
}

/* ─── Aparició ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: rise 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .reveal:nth-child(2) {
    animation-delay: 120ms;
  }
  .reveal:nth-child(3) {
    animation-delay: 260ms;
  }
  .reveal:nth-child(4) {
    animation-delay: 400ms;
  }
  /* El segell s'estampa un instant després que aparegui la fitxa */
  .stamp {
    animation: stamp 360ms cubic-bezier(0.3, 0.6, 0.3, 1) 950ms both;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
  @keyframes stamp {
    from {
      opacity: 0;
      transform: rotate(-6deg) scale(1.18);
    }
    to {
      opacity: 1;
      transform: rotate(-3.5deg);
    }
  }
}
