/* ==========================================================================
   Christian Oviedo — Portafolio
   Concepto: "Paper & Ink / Lamplight"
   Día: papelería fina (papel cálido, tinta, latón)
   Noche: el mismo escritorio bajo la lámpara (carbón cálido, marfil, latón)
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --paper: #FAF7F1;
  --surface: #F1ECE3;
  --ink: #1C1917;
  --ink-soft: #6B635A;
  --brass: #8C6D2F;
  --brass-strong: #6F5620;
  --hairline: #E3DCD0;

  --ivory: #F5F1E8;               /* texto sobre imágenes (ambos temas) */
  --scrim: rgba(22, 18, 13, 0.82);

  --grain-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-opacity: 0.05;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;

  --wrap: 1140px;
  --radius: 18px;
  --header-h: 68px;
  --ease-out: cubic-bezier(0.22, 0.61, 0.21, 1);
}

[data-theme="dark"] {
  --paper: #161310;
  --surface: #201B16;
  --ink: #F1EBE0;
  --ink-soft: #A89B8A;
  --brass: #D9AE5F;
  --brass-strong: #E8C37E;
  --hairline: #332C24;

  --grain-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-opacity: 0.07;
}

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

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

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  transition: background-color 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}

/* Grano de papel sobre todo el sitio */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  background-image: var(--grain-url);
  opacity: var(--grain-opacity);
}

body.modal-open { overflow: hidden; }

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 550;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }

a { color: inherit; }

::selection { background: var(--brass); color: var(--paper); }

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

.wrap {
  width: min(100% - 48px, var(--wrap));
  margin-inline: auto;
}

.section-pad { padding-block: clamp(72px, 10vw, 128px); }

section { scroll-margin-top: calc(var(--header-h) + 16px); }

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 3000;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.25s ease;
}
.skip-link:focus-visible { top: 12px; }

/* ---------- Piezas tipográficas ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-strong);
  display: flex;
  align-items: center;
  gap: 12px;
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--brass);
  flex: none;
  transition: background-color 0.35s ease;
}
.eyebrow--center { justify-content: center; }
.eyebrow--center::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--brass);
}
.eyebrow__sep { color: var(--ink-soft); }

.section-title { font-size: clamp(2rem, 4.5vw, 3.2rem); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.25s ease, color 0.25s ease,
              border-color 0.25s ease, transform 0.25s var(--ease-out);
}
.btn:hover { transform: translateY(-2px); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--brass-strong); color: #FBF8F2; }
.btn--ghost { border-color: var(--hairline); color: var(--ink); background: transparent; }
.btn--ghost:hover { border-color: var(--brass); color: var(--brass-strong); }
.btn__arrow { font-family: var(--font-mono); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--hairline); }

.header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  font-style: italic;
  text-decoration: none;
  letter-spacing: 0;
}
.brand__dot { color: var(--brass); }

.nav { display: flex; gap: 30px; }
.nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  position: relative;
  padding-block: 4px;
  transition: color 0.25s ease;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--brass);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); }

.header__controls { display: flex; align-items: center; gap: 14px; }

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.lang-toggle button {
  background: none;
  border: 0;
  padding: 4px 2px;
  font: inherit;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.25s ease;
}
.lang-toggle button[aria-pressed="true"] {
  color: var(--brass-strong);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--brass);
}
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle__sep { color: var(--hairline); }

.theme-toggle, .icon-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.25s var(--ease-out);
}
.theme-toggle:hover, .icon-link:hover {
  border-color: var(--brass);
  color: var(--brass-strong);
  transform: translateY(-1px);
}
.theme-toggle svg, .icon-link svg { width: 18px; height: 18px; }
.icon-link svg { width: 20px; height: 20px; }

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero {
  min-height: calc(100svh - var(--header-h));
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: clamp(40px, 6vw, 90px);
  padding: clamp(24px, 1vw, 48px) 0;
}

.hero__title {
  font-size: clamp(3rem, 8vw, 6.2rem);
  line-height: 0.98;
  margin-top: 22px;
}
.hero__title em {
  font-style: italic;
  font-weight: 450;
  color: var(--brass-strong);
  transition: color 0.35s ease;
}

.hero__role {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-style: italic;
  font-weight: 450;
  color: var(--ink);
  margin-top: 26px;
  max-width: 34ch;
}

.hero__intro {
  color: var(--ink-soft);
  margin-top: 16px;
  max-width: 46ch;
  transition: color 0.35s ease;
}

.hero__ctas { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 14px; 
  margin-top: 34px; 
}

.hero__visual { 
  position: relative; 
  justify-self: center; 
}

.portrait {
  width: min(400px, 100%);
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  transition: background-color 0.35s ease;
  border: var(--brass) 2px solid;
}
.portrait img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
}

.seal {
  position: absolute;
  left: -34px;
  bottom: -30px;
  width: 128px;
  height: 128px;
  color: var(--brass);
  transition: color 0.35s ease;
}
.seal__spin { width: 100%; height: 100%; animation: seal-rotate 24s linear infinite; }
.seal__ring { fill: var(--paper); stroke: currentColor; stroke-width: 1; transition: fill 0.35s ease; }
.seal__text {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2.6px;
  fill: currentColor;
}
.seal__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.7rem;
  color: var(--ink);
  transition: color 0.35s ease;
}

@keyframes seal-rotate { to { transform: rotate(360deg); } }

/* ---------- Ticker ---------- */
.ticker {
  border-block: 1px solid var(--hairline);
  padding-block: 15px;
  overflow: hidden;
  transition: border-color 0.35s ease;
}
.ticker__track {
  display: flex;
  width: max-content;
  white-space: nowrap;
  animation: ticker-scroll 32s linear infinite;
}
.ticker:hover .ticker__track { animation-play-state: paused; }
.ticker__item {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 52px;
  padding-right: 52px;
  transition: color 0.35s ease;
}
.ticker__item::after { content: "✳"; color: var(--brass); letter-spacing: 0; }

@keyframes ticker-scroll { to { transform: translateX(-50%); } }

/* ---------- Proyectos ---------- */
.section-head { margin-bottom: clamp(36px, 5vw, 60px); }
.section-head .section-title { margin-top: 18px; }
#project-count { color: var(--ink-soft); }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 22px;
}

.card {
  position: relative;
  grid-column: span 12;
  min-height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  isolation: isolate;
  transition: background-color 0.35s ease;
}
.card--w7 { grid-column: span 7; }
.card--w5 { grid-column: span 5; }

.card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease-out);
}
.card__scrim {
  position: absolute;
  inset: 0;
  /* Gradiente más alto y progresivo para que descripción/stack no compitan con la imagen */
  background: linear-gradient(
    180deg,
    rgba(22, 18, 13, 0) 8%,
    rgba(22, 18, 13, 0.18) 32%,
    rgba(22, 18, 13, 0.52) 54%,
    var(--scrim) 86%
  );
  transition: opacity 0.5s ease;
  opacity: 0.96;
}
/* Blur solo en la zona baja — enmascarado para no empañar la parte superior; fallback sin blur si no hay soporte */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .card__scrim {
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    -webkit-mask-image: linear-gradient(180deg, transparent 18%, black 60%);
    mask-image: linear-gradient(180deg, transparent 18%, black 60%);
  }
}
.card__body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 26px;
  color: var(--ivory);
}
.card__title { font-size: clamp(1.4rem, 2.2vw, 1.75rem); color: var(--ivory); text-shadow: 0 1px 12px rgba(0,0,0,0.38); }
.card__tagline {
  margin-top: 8px;
  font-size: 0.95rem;
  color: color-mix(in srgb, var(--ivory) 88%, transparent);
  max-width: 52ch;
  text-shadow: 0 1px 10px rgba(0,0,0,0.38);
}
.card .chips { margin-top: 14px; }
.card .chips li {
  border-color: color-mix(in srgb, var(--ivory) 35%, transparent);
  color: var(--ivory);
  background: color-mix(in srgb, var(--ivory) 12%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.card__arrow {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ivory) 45%, transparent);
  color: var(--ivory);
  font-family: var(--font-mono);
  opacity: 0;
  transform: translate(8px, -8px);
  transition: opacity 0.35s ease, transform 0.35s var(--ease-out);
}
.card:hover .card__img,
.card:focus-within .card__img { transform: scale(1.045); }
.card:hover .card__scrim,
.card:focus-within .card__scrim { opacity: 1; }
.card:hover .card__arrow,
.card:focus-within .card__arrow { opacity: 1; transform: translate(0, 0); }

.card__hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: inherit;
}
.card:focus-within { box-shadow: 0 0 0 2px var(--brass); }

/* ---------- Chips ---------- */
.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.chips li {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  transition: border-color 0.35s ease, color 0.35s ease, background-color 0.35s ease;
}

/* ---------- About ---------- */
.about { border-top: 1px solid var(--hairline); transition: border-color 0.35s ease; }
.about__grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: clamp(40px, 6vw, 90px);
}
.about__head .section-title { margin-top: 18px; }
.about__body p { color: var(--ink-soft); max-width: 58ch; transition: color 0.35s ease; }
.about__body p + p { margin-top: 16px; }

.stack-list { margin: 34px 0 0; }
.stack-list__row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  padding-block: 14px;
  border-top: 1px solid var(--hairline);
  transition: border-color 0.35s ease;
}
.stack-list dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-strong);
  padding-top: 3px;
}
.stack-list dd { margin: 0; color: var(--ink); transition: color 0.35s ease; }

/* ---------- Contacto ---------- */
.contact { border-top: 1px solid var(--hairline); transition: border-color 0.35s ease; }
.contact__inner { text-align: center; }
.contact__title { font-size: clamp(2.4rem, 6vw, 4.6rem); margin-top: 22px; }
.contact__sub {
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 18px auto 0;
  transition: color 0.35s ease;
}
.contact__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 34px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  padding-block: 26px;
  transition: border-color 0.35s ease;
}
.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.to-top { text-decoration: none; transition: color 0.25s ease; }
.to-top:hover { color: var(--brass-strong); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 14, 10, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal.is-open .modal__backdrop { opacity: 1; }

.modal__panel {
  position: relative;
  width: min(100%, 980px);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 8px;
  padding: clamp(18px, 3vw, 28px);
  opacity: 0;
  transform: translateY(20px) scale(0.985);
  transition: opacity 0.35s ease, transform 0.35s var(--ease-out),
              background-color 0.35s ease, border-color 0.35s ease;
}
.modal.is-open .modal__panel { opacity: 1; transform: translateY(0) scale(1); }

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.modal__close:hover { background: var(--brass); border-color: var(--brass); color: #FBF8F2; }
.modal__close svg { width: 16px; height: 16px; }

.modal__main-img {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--surface);
}
.modal__main-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}
.modal__main-img img.is-switching { opacity: 0; }

.modal__thumbs { display: flex; gap: 10px; margin-top: 12px; }
.modal__thumb {
  width: 84px;
  height: 60px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.25s ease, transform 0.25s var(--ease-out);
}
.modal__thumb:hover { transform: translateY(-2px); }
.modal__thumb.is-active { border-color: var(--brass); }
.modal__thumb img { width: 100%; height: 100%; object-fit: cover; }

.modal__content { padding: 6px 6px 6px 14px; display: flex; flex-direction: column; }
.modal__title { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.modal__content .chips { margin-top: 16px; }
.modal__details { margin-top: 20px; color: var(--ink-soft); transition: color 0.35s ease; }
.modal__details p + p { margin-top: 14px; }
.modal__links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: auto; padding-top: 28px; }

/* ---------- Reveal on scroll ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s var(--ease-out);
  transition-delay: var(--d, 0s);
}
[data-reveal].is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; text-align: left; }
  .hero__visual { order: -1; margin-top: 12px; }
  .portrait { width: min(300px, 78vw); }
  .seal { width: 104px; height: 104px; left: -18px; bottom: -20px; }
  .card--w7, .card--w5 { grid-column: span 12; }
  .card { min-height: 330px; }
  .about__grid { grid-template-columns: 1fr; }
  .modal__panel { grid-template-columns: 1fr; }
  .modal__content { padding: 14px 4px 4px; }
}

@media (max-width: 640px) {
  .nav { display: none; }
  .header__inner { gap: 12px; }
  .card { min-height: 300px; }
  .footer__inner { flex-direction: column; gap: 8px; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .seal__spin, .ticker__track { animation: none; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .card__img, .btn, .card__arrow { transition: none; }
  body, body::after { transition: none; }
}
