/* ============================================================
   Obra de Miguel — galería privada
   Paleta: marfil, negro de humo, dorado envejecido.
   ============================================================ */

:root {
  --ivory: #f3ede1;
  --ivory-deep: #e8dfcd;
  --paper: #faf6ec;
  --ink: #1b1712;
  --ink-soft: #3a3229;
  --muted: #6b6055;
  --gold: #7d5c1f;
  --gold-soft: #c9a45e;
  --rule: rgba(27, 23, 18, 0.16);
  --rule-strong: rgba(27, 23, 18, 0.32);
  --shadow: 0 24px 60px -32px rgba(27, 23, 18, 0.55);
  --bg: var(--ivory);
  --fg: var(--ink);
  --fg-soft: var(--ink-soft);
  --fg-muted: var(--muted);
  --surface: var(--paper);
  --accent: var(--gold);
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --body: "EB Garamond", Georgia, "Times New Roman", serif;
  --pad: clamp(1.25rem, 5vw, 5.5rem);
}

html[data-theme="dark"] {
  --bg: #14110d;
  --fg: #efe6d6;
  --fg-soft: #d8cdba;
  --fg-muted: #a89c8a;
  --surface: #1c1813;
  --accent: #e0bb78;
  --rule: rgba(239, 230, 214, 0.16);
  --rule-strong: rgba(239, 230, 214, 0.34);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.85);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: clamp(1.02rem, 0.55vw + 0.9rem, 1.14rem);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s ease, color 0.5s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.08; margin: 0; text-wrap: balance; }
p { margin: 0 0 1.1em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

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

/* ---------- grain overlay ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}
html[data-theme="dark"] .grain { opacity: 0.09; mix-blend-mode: screen; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.mark { text-decoration: none; display: flex; flex-direction: column; line-height: 1.1; }
.mark-name { font-family: var(--serif); font-size: 1.32rem; letter-spacing: 0.02em; }
.mark-sub {
  font-size: 0.66rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 0.18rem;
}
.nav {
  margin-left: auto;
  display: flex;
  gap: clamp(0.6rem, 1.8vw, 1.7rem);
  flex-wrap: wrap;
}
.nav a {
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-soft);
  padding: 0.55rem 0.15rem;
  border-bottom: 1px solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.nav a:hover { color: var(--fg); border-bottom-color: var(--accent); }
.theme-toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-size: 1rem;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}
.theme-toggle:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  gap: clamp(1.6rem, 4vw, 3.4rem);
  padding: clamp(2rem, 5vw, 4rem) var(--pad) clamp(2.5rem, 6vw, 5rem);
  align-items: center;
}
.hero-figure { position: relative; }
.hero-figure img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.03);
}
.hero-frame {
  position: absolute;
  inset: 0;
  border: 1px solid var(--rule-strong);
  transform: translate(10px, 10px);
  pointer-events: none;
}
.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.9rem;
}
.hero-text h1 {
  font-size: clamp(2.4rem, 6.4vw, 5rem);
  letter-spacing: -0.01em;
  margin-bottom: 1.1rem;
  min-height: 1.1em;
}
.lede {
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.24rem);
  color: var(--fg-soft);
  max-width: 34ch;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.6rem; }

.btn {
  display: inline-block;
  padding: 0.85rem 1.6rem;
  min-height: 44px;
  font-family: var(--body);
  font-size: 0.84rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #17130e; }
.btn-quiet { background: transparent; color: var(--fg); border-color: var(--rule-strong); }
.btn-quiet:hover { background: transparent; color: var(--accent); border-color: var(--accent); }

/* ---------- visualizer ---------- */
.viz {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
  margin: 0 0 1.4rem;
}
.viz span {
  flex: 1 1 auto;
  max-width: 6px;
  height: 100%;
  background: var(--accent);
  opacity: 0.55;
  transform-origin: bottom;
  animation: pulse 2.6s ease-in-out infinite;
}
.viz span:nth-child(3n) { animation-duration: 3.4s; opacity: 0.4; }
.viz span:nth-child(4n) { animation-duration: 2.1s; opacity: 0.7; }
.viz span:nth-child(5n) { animation-duration: 4.1s; opacity: 0.32; }
.viz span:nth-child(1) { animation-delay: -0.2s; }
.viz span:nth-child(2) { animation-delay: -0.9s; }
.viz span:nth-child(3) { animation-delay: -1.4s; }
.viz span:nth-child(4) { animation-delay: -0.5s; }
.viz span:nth-child(5) { animation-delay: -1.9s; }
.viz span:nth-child(6) { animation-delay: -0.7s; }
.viz span:nth-child(7) { animation-delay: -2.3s; }
.viz span:nth-child(8) { animation-delay: -1.1s; }
.viz span:nth-child(9) { animation-delay: -0.3s; }
.viz span:nth-child(10) { animation-delay: -1.6s; }
.viz span:nth-child(11) { animation-delay: -2.6s; }
.viz span:nth-child(12) { animation-delay: -0.8s; }
.viz span:nth-child(13) { animation-delay: -1.2s; }
.viz span:nth-child(14) { animation-delay: -2.0s; }
.viz span:nth-child(15) { animation-delay: -0.4s; }
.viz span:nth-child(16) { animation-delay: -1.7s; }
.viz span:nth-child(17) { animation-delay: -2.9s; }
.viz span:nth-child(18) { animation-delay: -0.6s; }
.viz span:nth-child(19) { animation-delay: -1.3s; }
.viz span:nth-child(20) { animation-delay: -2.2s; }
.viz span:nth-child(21) { animation-delay: -0.9s; }
.viz span:nth-child(22) { animation-delay: -1.8s; }
.viz span:nth-child(23) { animation-delay: -2.5s; }
.viz span:nth-child(24) { animation-delay: -0.5s; }
@keyframes pulse {
  0%, 100% { transform: scaleY(0.18); }
  50% { transform: scaleY(1); }
}

/* ---------- typed H1 ---------- */
.typed .ch { opacity: 0; animation: ink-in 0.5s ease forwards; }
@keyframes ink-in { to { opacity: 1; } }
.typed .caret {
  display: inline-block;
  width: 1px;
  height: 0.86em;
  margin-left: 0.06em;
  background: var(--accent);
  vertical-align: -0.06em;
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ---------- sections ---------- */
.section {
  padding: clamp(3rem, 7vw, 6.5rem) var(--pad);
  border-top: 1px solid var(--rule);
}
.section-head { max-width: 62ch; margin-bottom: clamp(2rem, 4vw, 3.4rem); }
.section-head h2, .split-text h2, .contact-text h2 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  margin-bottom: 1rem;
}
.section-intro { color: var(--fg-soft); }

/* ---------- gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.4rem, 3vw, 3rem);
  align-items: start;
}
.work { margin: 0; }
.work-full { grid-column: 1 / -1; }
.work img {
  width: 100%;
  object-fit: cover;
  filter: saturate(0.94) contrast(1.02);
  transition: filter 0.6s ease, transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.work-full img { aspect-ratio: 16 / 10; }
.work-half img { aspect-ratio: 4 / 5; }
.work:hover img { filter: saturate(1) contrast(1.04); transform: scale(1.008); }
.work figcaption {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  margin-top: 0.9rem;
}
.work-title { font-family: var(--serif); font-size: 1.24rem; }
.work-meta {
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.work-note { font-size: 0.95rem; color: var(--fg-soft); max-width: 52ch; }
.gallery-foot {
  margin-top: clamp(1.8rem, 3vw, 2.8rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--fg-muted);
  max-width: 62ch;
}

/* ---------- split (bio) ---------- */
.section-split {
  display: grid;
  gap: clamp(1.8rem, 4vw, 3.6rem);
  align-items: start;
}
.split-figure { margin: 0; }
.split-figure img { aspect-ratio: 4 / 3; object-fit: cover; }
.split-figure figcaption {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  padding-top: 0.6rem;
}
.facts {
  margin: 1.8rem 0 0;
  display: grid;
  gap: 0.7rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.2rem;
}
.facts > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.8rem; }
.facts dt {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-top: 0.18rem;
}
.facts dd { margin: 0; color: var(--fg-soft); font-size: 0.98rem; }

/* ---------- process ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(1.6rem, 3vw, 2.6rem);
  counter-reset: step;
}
.steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}
.step-num {
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1;
  padding-top: 0.15rem;
}
.steps h3 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.steps p { color: var(--fg-soft); margin: 0; max-width: 60ch; }

.quote-band {
  margin-top: clamp(2.4rem, 5vw, 4rem);
  padding: clamp(1.8rem, 4vw, 3rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}
.quote-band blockquote { margin: 0; }
.quote-band blockquote p {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.35;
  font-style: italic;
  color: var(--fg);
  max-width: 40ch;
}
.quote-note {
  margin-top: 1.1rem;
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* ---------- exposiciones ---------- */
.expo-list { list-style: none; margin: 0; padding: 0; }
.expo-list li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--rule);
  align-items: baseline;
}
.expo-list li:last-child { border-bottom: 1px solid var(--rule); }
.expo-year {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--accent);
}
.expo-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.9rem; }
.expo-body strong { font-family: var(--serif); font-weight: 500; font-size: 1.18rem; }
.expo-body em {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-style: normal;
}
.expo-next {
  margin-top: clamp(1.8rem, 3vw, 2.6rem);
  padding: 1.4rem 1.6rem;
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ---------- contacto ---------- */
.section-contact {
  display: grid;
  gap: clamp(1.8rem, 4vw, 3.6rem);
  align-items: start;
}
.contact-text p { color: var(--fg-soft); }
.contact-direct { font-size: 0.98rem; margin-top: 1.4rem; }
.contact-form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.field input,
.field select,
.field textarea {
  font-family: var(--body);
  font-size: 1rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: 0.75rem 0.85rem;
  min-height: 44px;
  width: 100%;
  transition: border-color 0.25s ease;
}
.field textarea { resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); outline: none; }
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.contact-form .btn { justify-self: start; margin-top: 0.4rem; }
.form-status {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg-soft);
  border-left: 2px solid var(--accent);
  padding-left: 0.8rem;
}

/* ---------- placeholders ---------- */
.ph {
  color: var(--fg-muted);
  border-bottom: 1px dotted var(--accent);
  text-decoration: none;
  font-style: italic;
}
a.ph:hover { color: var(--accent); }

/* ---------- footer ---------- */
.site-footer {
  padding: clamp(2.4rem, 5vw, 4rem) var(--pad) 3.4rem;
  border-top: 1px solid var(--rule);
  background: var(--surface);
}
.footer-name { font-family: var(--serif); font-size: 1.5rem; margin: 0 0 0.3rem; }
.footer-line { font-size: 0.9rem; color: var(--fg-muted); margin: 0 0 1.2rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin: 0 0 1.6rem; }
.footer-links a {
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fg-soft);
  padding: 0.4rem 0;
}
.footer-links a:hover { color: var(--accent); }
.attribution {
  position: static;
  margin: 0;
  font-size: 0.74rem;
  font-family: var(--body);
  opacity: 1;
  color: var(--fg-muted);
}
.attribution a { color: var(--fg-muted); text-decoration: underline; text-underline-offset: 3px; }
.attribution a:hover { color: var(--accent); }

/* ---------- reveal on scroll ---------- */
@supports (animation-timeline: view()) {
  .work, .steps li, .expo-list li, .quote-band, .split-figure {
    animation: rise linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 26%;
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- responsive ---------- */
@media (min-width: 720px) {
  .hero { grid-template-columns: 1.05fr 0.95fr; }
  .hero-text { order: -1; }
  .section-split { grid-template-columns: 1.15fr 0.85fr; }
  .section-contact { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps li { grid-template-columns: auto 1fr; }
}

@media (min-width: 1100px) {
  .hero { padding-top: clamp(3rem, 5vw, 5rem); }
  .hero-figure img { aspect-ratio: 3 / 4; }
  .section-split { grid-template-columns: 1.2fr 0.8fr; }
  .split-figure img { aspect-ratio: 3 / 4; }
}

@media (max-width: 719px) {
  .nav { order: 3; width: 100%; margin-left: 0; justify-content: flex-start; gap: 0.9rem; }
  .topbar { flex-wrap: wrap; }
  .theme-toggle { margin-left: auto; }
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .work-half { grid-column: 1 / -1; }
  .work-half img { aspect-ratio: 4 / 5; }
  .facts > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .expo-list li { grid-template-columns: 3.6rem 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .viz span { animation: none; transform: scaleY(0.35); }
  .typed .ch { opacity: 1; animation: none; }
  .typed .caret { animation: none; }
  .work img { transition: none; }
  .work:hover img { transform: none; }
  @supports (animation-timeline: view()) {
    .work, .steps li, .expo-list li, .quote-band, .split-figure { animation: none; }
  }
}
