@import url('fonts.css');

:root {
  --page: #F7E4D4;
  --paper: #FBEFE4;
  --ink: #14110F;
  --muted: #6B5F55;
  --accent: #1F3FD1;
  --positive: #0F6B4F;

  --font-head: 'Bodoni Moda', Georgia, serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --hairline: 1px solid var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body.scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* ---------- paper grain ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- progress line ---------- */

.progress-line {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 1200;
  transition: width 0.1s linear;
}

/* ---------- mini masthead (after scroll) ---------- */

.mini-mast {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 700;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.mini-mast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mini-mast img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- masthead hero ---------- */

.masthead {
  position: relative;
  min-height: 94svh;
  padding: 20px 20px 36px;
  display: flex;
  flex-direction: column;
}

.masthead__dateline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: auto;
}

.masthead__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(2.2rem, 12.4vw, 5.4rem);
  line-height: 0.98;
  margin: 28px 0 0;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

.masthead__standfirst {
  font-family: var(--font-body);
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  color: var(--muted);
  max-width: 30ch;
  margin: 18px 0 0;
}

.masthead__logo-frame {
  align-self: flex-end;
  margin-top: 28px;
  border: 1px solid var(--ink);
  padding: 8px;
  background: var(--paper);
}

.masthead__logo-frame img {
  width: 108px;
  height: 108px;
  object-fit: cover;
  display: block;
}

.masthead__rule {
  margin-top: 24px;
  border-top: 1px solid var(--ink);
}

/* ---------- section header ---------- */

.section {
  padding: 48px 16px 8px;
  max-width: 720px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 30px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
}

.section-header__numeral {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(3.6rem, 16vw, 5rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
  text-stroke: 1.5px var(--ink);
}

.section-header__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.6rem, 6.5vw, 2.1rem);
  margin: 0;
}

/* ---------- reveal on scroll (ink-wipe) ---------- */

.fade-in {
  opacity: 0;
  clip-path: inset(0 100% 0 0);
  transition: opacity 0.5s ease, clip-path 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.is-visible {
  opacity: 1;
  clip-path: inset(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    clip-path: none;
    transition: none;
  }
}

.card-btn {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: block;
}

/* ---------- FINANZA: ledger rows ---------- */

.finanza-ledger {
  border-top: 1px solid var(--ink);
}

.ledger-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--ink);
}

.ledger-row__index {
  flex: none;
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--positive);
  width: 2.4ch;
}

.ledger-row__body {
  flex: 1;
  min-width: 0;
}

.ledger-row__headline {
  display: block;
  font-family: var(--font-head);
  font-size: 1.1rem;
  line-height: 1.25;
  margin: 0 0 6px;
}

.ledger-row__preview {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.ledger-row__thumb {
  flex: none;
  width: 64px;
  height: 64px;
  border: 1px solid var(--ink);
  overflow: hidden;
}

.ledger-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.ledger-row--lead {
  padding: 26px 0 30px;
}

.ledger-row--lead .ledger-row__index {
  font-size: 1.6rem;
}

.ledger-row--lead .ledger-row__headline {
  font-size: 1.5rem;
}

.ledger-row--lead .ledger-row__preview {
  font-size: 0.94rem;
}

.ledger-row--lead .ledger-row__thumb {
  width: 96px;
  height: 96px;
}

.reading-time {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- ECONOMIA: staggered grid ---------- */

.economia-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.eco-card {
  border: 1px solid var(--ink);
  background: var(--paper);
}

.eco-card--offset {
  margin-top: 34px;
}

.eco-card__media {
  display: block;
  position: relative;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
  aspect-ratio: 3 / 4;
}

.eco-card--short .eco-card__media {
  aspect-ratio: 1 / 1;
}

.eco-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.eco-card__body {
  display: block;
  padding: 12px;
}

.eco-card__tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page);
  background: var(--accent);
  padding: 3px 7px;
  margin-bottom: 8px;
}

.eco-card__headline {
  display: block;
  font-family: var(--font-head);
  font-size: 1rem;
  line-height: 1.22;
  margin: 0;
}

/* ---------- TECNOLOGIA: full-bleed cards ---------- */

.tecnologia-stack {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.tec-card {
  position: relative;
}

.tec-card__media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--ink);
}

.tec-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.tec-card__label {
  display: block;
  position: relative;
  margin: -22px 20px 0 0;
  max-width: 86%;
  background: var(--page);
  border: 1px solid var(--ink);
  padding: 12px 14px;
}

.tec-card__headline {
  display: block;
  font-family: var(--font-head);
  font-size: 1.15rem;
  line-height: 1.22;
  margin: 0 0 6px;
}

.tec-card__preview {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  padding: 56px 20px 44px;
  border-top: 1px solid var(--ink);
  margin-top: 48px;
}

.site-footer__tagline {
  font-family: var(--font-head);
  font-size: 1.3rem;
  margin: 0 0 10px;
}

.site-footer__meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0 0 14px;
}

.site-footer__email {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- overlay reader ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--page);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay.open {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .overlay { transition: none; }
}

.overlay__top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--page);
  border-bottom: 1px solid var(--ink);
}

.overlay__tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page);
  background: var(--accent);
  padding: 4px 9px;
}

.overlay__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.overlay__close svg {
  width: 18px;
  height: 18px;
  color: var(--ink);
}

.overlay__hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
}

.overlay__hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay__body {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 72px;
}

.overlay__headline {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1.18;
  margin: 0 0 10px;
}

.overlay__meta {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 26px;
}

.overlay__text p {
  color: var(--ink);
  line-height: 1.7;
  font-size: 1rem;
  margin: 0 0 18px;
}

/* ---------- utility ---------- */

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

@media (min-width: 640px) {
  .masthead__title { font-size: clamp(3.6rem, 9vw, 6.6rem); }
}

.ledger-row__thumb img.loaded,
.eco-card__media img.loaded,
.tec-card__media img.loaded {
  opacity: 1;
}
