@font-face {
  font-family: "Paper Mono";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/paper-mono-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/newsreader-display-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/newsreader-display-italic-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader Fallback";
  src: local("Georgia"), local("Times New Roman"), local("Noto Serif");
  size-adjust: 92.3%;
}
@font-face {
  font-family: "Newsreader Fallback";
  font-style: italic;
  src: local("Georgia Italic"), local("Georgia-Italic"), local("Times New Roman Italic"), local("Noto Serif Italic");
  size-adjust: 89.8%;
}

:root {
  --paper: #f6f2ea;
  --ink: #1f1b16;
  --body: #3b352d;
  --muted: #686157;
  --rule: rgba(31, 27, 22, 0.22);
  --sage: #6d7f66;
  --rust: #b0462a;
  --serif: "Newsreader", "Newsreader Fallback", Georgia, serif;
  --mono: "Paper Mono", ui-monospace, monospace;
  --gut: clamp(18px, 3vw, 44px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--paper); }
body {
  padding: 14px;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--paper);
  background-image:
    radial-gradient(1400px 800px at 50% -12%, #fcfaf5, rgba(252, 250, 245, 0) 70%),
    radial-gradient(rgba(31, 27, 22, 0.07) 0.5px, transparent 0.9px);
  background-size: auto, 4px 4px;
}
::selection { background: var(--rust); color: var(--paper); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 1px solid var(--rust); outline-offset: 4px; }
h1, h2 { font-weight: 400; }
em, .it { font-style: italic; color: var(--rust); }

.mono {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.5;
}
.f { text-transform: none; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The sheet: a printed page with a double keyline */
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - 28px);
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -6px;
}
.strip, .contents {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 6px;
  padding: 0 calc(var(--gut) - 6px);
}
.strip { padding-top: 15px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.strip .c { position: absolute; left: 50%; transform: translateX(-50%); }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand svg { width: 34px; height: auto; color: var(--ink); }
.contents { padding-top: 9px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.contents nav { display: flex; gap: 26px; }
.contents a { position: relative; padding: 4px 0; }
.contents a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 0;
  height: 1px;
  background: var(--rust);
  transition: width 0.3s;
}
.contents a:hover::after { width: 100%; }
.contents .f { color: var(--rust); font-size: 0.7rem; }

/* Lámina I: the plate fills the first screen */
.stage {
  position: relative;
  height: calc(100svh - 28px - 82px);
  min-height: 560px;
  margin: 0 6px;
  border-bottom: 1px solid var(--ink);
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.stage::before { left: 12px; top: 12px; border-left: 1px solid var(--ink); border-top: 1px solid var(--ink); }
.stage::after { right: 12px; bottom: 12px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.stage #plate { position: absolute; inset: 0; height: 100%; }
.head { position: absolute; left: var(--gut); top: clamp(24px, 4.4vh, 52px); z-index: 1; pointer-events: none; }
.kicker { display: flex; align-items: center; gap: 12px; color: var(--rust); margin-bottom: 18px; }
.kicker::before { content: ""; width: 30px; height: 1px; background: var(--rust); }
h1 { font-size: clamp(3.2rem, min(9.6vw, 15.5vh), 10.4rem); line-height: 0.84; letter-spacing: -0.05em; }
.side {
  position: absolute;
  right: var(--gut);
  top: clamp(28px, 4.8vh, 56px);
  width: min(25rem, 34vw);
  text-align: right;
  z-index: 1;
  pointer-events: none;
}
.side p { font-size: clamp(1.05rem, 1.45vw, 1.35rem); line-height: 1.38; color: var(--body); }
.ro {
  display: inline-grid;
  grid-template-columns: auto auto;
  column-gap: 16px;
  row-gap: 2px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
}
.ro b {
  display: inline-block;
  min-width: 7ch;
  font-weight: 400;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pfoot {
  position: absolute;
  left: var(--gut);
  right: var(--gut);
  bottom: 18px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}
.pfoot .hold { pointer-events: auto; }
.pfoot .f { white-space: nowrap; }
.hold {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.hold:hover { border-color: var(--ink); color: var(--ink); }
.hold.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* The plate itself */
#plate { display: block; width: 100%; overflow: hidden; touch-action: pan-y; cursor: crosshair; }
#plate:focus-visible { outline: 1px solid var(--rust); outline-offset: -8px; }
.pl-axis, .pl-tan, .pl-circle {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: pl-draw 1.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
.pl-axis { stroke: var(--ink); stroke-width: 1; }
.pl-tan { stroke: var(--sage); stroke-width: 1; animation-delay: 0.25s; }
.pl-circle { fill: none; stroke: var(--sage); stroke-width: 1.1; animation-delay: 0.45s; }
.pl-yaxis { stroke: var(--sage); stroke-width: 0.8; stroke-dasharray: 2 4; }
.pl-c { stroke: var(--sage); stroke-width: 0.9; }
.pl-tick { stroke: var(--ink); stroke-width: 0.8; }
.pl-num { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; fill: var(--muted); }
.pl-edge { transition: opacity 0.4s; }
.pl-edge.off { opacity: 0; }
.pl-lab { font-family: var(--serif); font-style: italic; font-size: 20px; fill: var(--ink); }
.pl-small { font-size: 15px; fill: var(--muted); }
.pl-o { fill: var(--ink); }
.pl-glow { transform-box: fill-box; transform-origin: center; animation: pl-breathe 3.2s ease-in-out infinite alternate; }
.pl-f { opacity: 0; transition: opacity 1s; }
.pl-f.on { opacity: 1; }
.pl-f line { stroke: var(--sage); stroke-width: 0.6; opacity: 0.38; }
.pl-f circle { fill: var(--ink); opacity: 0.75; }
.pl-ghost { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 0.5 5; stroke-linecap: round; opacity: 0.4; }
.pl-trace { fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pl-ray { stroke: var(--rust); stroke-width: 1; }
.pl-proj { stroke: var(--ink); stroke-width: 0.8; stroke-dasharray: 3 3; opacity: 0.6; }
.pl-drop { stroke: var(--rust); stroke-width: 0.8; stroke-dasharray: 1 3; opacity: 0.55; }
.pl-arc { fill: none; stroke: var(--rust); stroke-width: 1; }
.pl-th { font-size: 16px; fill: var(--rust); }
.pl-pt { fill: var(--paper); stroke: var(--ink); stroke-width: 1.2; }
.pl-ring {
  fill: none;
  stroke: var(--rust);
  stroke-width: 0.8;
  stroke-dasharray: 2 3;
  transform-box: fill-box;
  transform-origin: center;
  animation: pl-spin 14s linear infinite;
}
.pl-lp { fill: var(--rust); }
@keyframes pl-draw { to { stroke-dashoffset: 0; } }
@keyframes pl-spin { to { transform: rotate(360deg); } }
@keyframes pl-breathe { from { transform: scale(0.82); } to { transform: scale(1.08); } }

/* Explicación de la lámina */
.legend { display: grid; grid-template-columns: 0.8fr 1fr 1fr 1fr; margin: 0 6px; border-bottom: 1px solid var(--ink); }
.legend > div { padding: 26px clamp(16px, 2.2vw, 30px) 32px; border-right: 1px solid var(--rule); }
.legend > div:first-child { padding-left: calc(var(--gut) - 6px); }
.legend > div:last-child { border-right: 0; }
.legend h2 { margin-top: 14px; font-style: italic; font-size: clamp(1.6rem, 2.4vw, 2.2rem); line-height: 1.02; }
.legend .n { display: block; margin-bottom: 12px; font-style: italic; color: var(--rust); font-size: 2.6rem; line-height: 1; }
.legend p:not(.mono) { font-size: 1.18rem; line-height: 1.36; }
.legend .tag { display: block; margin-top: 14px; }

/* Tabla y contacto */
.close { display: grid; grid-template-columns: 0.8fr 3fr; margin: 0 6px; border-bottom: 3px double var(--ink); }
.close > div { padding: 30px clamp(16px, 2.2vw, 30px) 30px; }
.close > div:first-child { padding-left: calc(var(--gut) - 6px); border-right: 1px solid var(--rule); }
.vals { width: 100%; max-width: 15rem; margin-top: 12px; border-collapse: collapse; font-family: var(--mono); font-size: 0.72rem; }
.vals th { padding: 0 0 6px; font-weight: 400; font-size: 0.6rem; letter-spacing: 0.1em; text-align: left; color: var(--muted); }
.vals td { padding: 4px 0; border-top: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.vals td:last-child, .vals th:last-child { text-align: right; }
.vals .hl td { color: var(--rust); }
.mail {
  display: inline-block;
  margin-top: 10px;
  font-style: italic;
  font-size: clamp(2rem, 6.2vw, 6.4rem);
  line-height: 1;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
  transition: color 0.25s;
}
.mail:hover { color: var(--rust); }
.close .note { margin-top: 18px; }

footer { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 14px var(--gut) 16px; color: var(--muted); }
footer a { border-bottom: 1px solid var(--rule); }
footer .eq { font-family: var(--serif); font-style: italic; font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--ink); }

/* Aviso legal */
.page { flex: 1; margin: 0 6px; padding: clamp(40px, 9vh, 96px) calc(var(--gut) - 6px) clamp(48px, 10vh, 110px); border-bottom: 3px double var(--ink); }
.page h1 { font-size: clamp(3rem, 8vw, 7.6rem); }
.page p.lead { margin-top: 26px; font-size: clamp(1.15rem, 1.6vw, 1.45rem); line-height: 1.4; color: var(--body); }
.page .mail { font-size: clamp(1.4rem, 3vw, 2.6rem); margin-top: 28px; }

@media (max-width: 900px) {
  .stage { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .stage::before, .stage::after { display: none; }
  .stage #plate { position: static; margin-top: 8px; }
  .head, .side { position: static; display: block; width: auto; text-align: left; }
  .head { padding: 30px calc(var(--gut) - 6px) 0; }
  .side { padding: 20px calc(var(--gut) - 6px) 0; max-width: 36rem; }
  .ro { margin-top: 14px; }
  .pfoot { position: static; padding: 8px calc(var(--gut) - 6px) 18px; }
  .legend { grid-template-columns: 1fr 1fr; }
  .legend > div:nth-child(2n) { border-right: 0; }
  .legend > div:nth-child(-n + 2) { border-bottom: 1px solid var(--rule); }
  .legend > div:nth-child(3) { padding-left: calc(var(--gut) - 6px); }
}

@media (max-width: 640px) {
  body { padding: 8px; }
  .mono, .hold { font-size: 0.75rem; letter-spacing: 0.1em; }
  .pl-num { font-size: 12px; }
  .sheet { min-height: calc(100svh - 16px); }
  :root { --gut: 22px; }
  .strip .c, .contents .f, .hide-s { display: none; }
  .contents nav { gap: 18px; }
  .head { padding: 26px 16px 0; }
  .side { padding: 18px 16px 0; }
  .side p { font-size: 1.12rem; }
  h1 { font-size: clamp(3.2rem, 15vw, 4.6rem); }
  .pfoot { padding: 6px 16px 16px; }
  .hide-m { display: none; }
  .legend, .close { grid-template-columns: 1fr; }
  .legend > div, .close > div { padding: 22px 16px !important; border-right: 0 !important; border-bottom: 1px solid var(--rule); }
  .legend > div:last-child, .close > div:last-child { border-bottom: 0; }
  .mail { font-size: clamp(1.5rem, 7.4vw, 2.4rem); }
  footer { padding: 12px 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .pl-axis, .pl-tan, .pl-circle, .pl-ring, .pl-glow { animation: none; stroke-dashoffset: 0; }
  .pl-f, .pl-edge, .hold, .mail, .contents a::after { transition: none; }
}
