/* fernandodilland.com */

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dm-sans.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #ffffff;
  --cream: #f5efe9;
  --tile: #faf6f2;
  --tile-hover: #f3ece5;
  --line: #ebe3dc;
  --text: #1f1a17;
  --muted: #6f6660;
  --accent: #b95c40;        /* botones con texto blanco */
  --accent-soft: #c96f52;   /* franja y texto grande */
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 10; background: var(--bg); padding: 6px 10px; border: 1px solid var(--line); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Etiquetas en mayúsculas */
.label, .link-label, .btn, .site-header nav a, .tags, .band-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.label { font-size: .78rem; font-weight: 500; color: var(--text); }
.link-label { font-size: .74rem; font-weight: 500; color: var(--muted); }
.link-label:hover { color: var(--text); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 22px; border-radius: 999px;
  font-size: .74rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background-color .2s, border-color .2s, color .2s;
}
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover { background: #3a332e; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #a24f36; }
.btn-outline { background: transparent; color: var(--text); border-color: #cfc5bc; }
.btn-outline:hover { border-color: var(--text); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, .97);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 72px; }
.brand { font-family: var(--serif); font-size: 1.55rem; line-height: 1; }
.site-header nav { display: flex; align-items: center; gap: 32px; }
.site-header nav a:not(.btn) { font-size: .74rem; font-weight: 500; }
.site-header nav a:not(.btn):hover { color: var(--accent); }

/* Hero: escena 3D fija mientras se hace scroll (alto = recorrido de la animación) */
:root { --hh: 72px; --night: #120e0c; }
.hero { position: relative; height: 650svh; background: var(--night); color: #f6efe9; }
.hero-stage {
  position: sticky; top: var(--hh); height: calc(100vh - var(--hh)); height: calc(100svh - var(--hh));
  overflow: hidden; contain: layout paint;
  background: radial-gradient(ellipse at 70% 50%, #2a1a14 0%, var(--night) 60%);
}
.hero-stage::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg, rgba(18, 14, 12, .8), rgba(18, 14, 12, .45) 40%, transparent 65%); }
.hero-stage canvas { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .8s; }
.has3d .hero-stage canvas { opacity: 1; }
.chapter {
  position: absolute; inset: 0; display: flex; align-items: center;
  opacity: 0; visibility: hidden; will-change: opacity, transform; pointer-events: none; z-index: 2;
}
.chapter.c0 { opacity: 1; visibility: visible; }
.chapter a { pointer-events: auto; }
.chapter .wrap { width: 100%; }
.chapter-body { max-width: 36rem; }
.chapter .label { color: #e4967c; }
.chapter.c0 h1 { margin-top: 0; }
.chapter h1, .chapter h2 {
  margin-top: 18px; font-family: var(--serif); line-height: 1.02; letter-spacing: -.015em;
  font-size: clamp(2.5rem, 6.4vw, 5.6rem);
}
.chapter h2 { font-size: clamp(2.1rem, 4.8vw, 4rem); line-height: 1.06; }
.chapter h1 em { display: block; font-style: italic; color: #e4967c; }
.hero-sub { margin-top: 24px; max-width: 30em; color: #c9bdb4; font-size: clamp(1rem, 1.5vw, 1.18rem); }
.hero-sub strong { color: #fff; font-weight: 500; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; margin-top: 32px; }
.hero .link-label { color: #f6efe9; }
.hero .link-label:hover { color: #e4967c; }
.chapter.c4 .hero-sub { max-width: 24em; }
.scroll-cue {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 20px; margin: 0; text-align: center; pointer-events: none;
  color: #a39489; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
}
.scroll-cue::after { content: ""; display: block; width: 1px; height: 32px; margin: 10px auto 0; background: linear-gradient(#e4967c, transparent); animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
.city {
  position: absolute; z-index: 2; left: 0; top: 0; opacity: 0; pointer-events: none; white-space: nowrap;
  padding: 3px 8px; margin: -30px 0 0 10px; border: 1px solid rgba(228, 150, 124, .45); border-radius: 4px;
  background: rgba(18, 14, 12, .7); color: #f6efe9; font: 500 .7rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  will-change: transform, opacity;
}
.part {
  position: absolute; z-index: 2; left: 0; top: 0; opacity: 0; pointer-events: none; white-space: nowrap;
  padding: 2px 7px; margin: -26px 0 0 12px; border: 1px solid rgba(95, 216, 232, .45); border-radius: 4px;
  background: rgba(10, 18, 22, .72); color: #bfeef5; font: 500 .66rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  will-change: transform, opacity;
}
.term {
  position: absolute; z-index: 2; right: 5%; bottom: 7%; margin: 0; padding: 12px 16px; max-width: 90%;
  border: 1px solid rgba(95, 216, 232, .3); border-radius: 8px; background: rgba(10, 14, 16, .75);
  color: #9fe6ee; font: .72rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none;
}
.term i { display: inline-block; width: .55em; height: 1em; vertical-align: -.15em; background: #9fe6ee; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.rail { list-style: none; margin: 0; padding: 0; position: absolute; z-index: 4; right: 10px; top: 50%; translate: 0 -50%; display: grid; gap: 2px; }
.rail button { position: relative; width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.rail button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #5a4c44; transition: background .3s, transform .3s; }
.rail button:hover::before, .rail button:focus-visible::before { background: #c9bdb4; transform: scale(1.5); }
.rail li.on button::before { background: #e4967c; transform: scale(1.5); }
.rail button::after {
  content: attr(data-label); position: absolute; right: 30px; top: 50%; translate: 6px -50%; opacity: 0; pointer-events: none; white-space: nowrap;
  padding: 3px 9px; border-radius: 4px; background: rgba(18, 14, 12, .85); color: #f6efe9; font-size: .72rem; letter-spacing: .02em; transition: opacity .2s, translate .2s;
}
.rail button:hover::after, .rail button:focus-visible::after { opacity: 1; translate: 0 -50%; }
/* Interacción con el mouse */
.tip {
  position: absolute; z-index: 5; left: 0; top: 0; opacity: 0; pointer-events: none; white-space: nowrap;
  padding: 4px 10px; border: 1px solid rgba(228, 150, 124, .5); border-radius: 6px; background: rgba(18, 14, 12, .88);
  color: #f6efe9; font: 500 .74rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; transition: opacity .15s; will-change: transform;
}
.tie { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; opacity: 0; overflow: visible; }
.tie line { stroke: #e4967c; stroke-width: 1.5; stroke-dasharray: 5 6; animation: dash 1s linear infinite; }
.tie .a { fill: #fff; }
.tie .b { fill: none; stroke: #e4967c; stroke-width: 1.5; }
.tie .pk { fill: #fff; opacity: 0; }
@keyframes dash { to { stroke-dashoffset: -22; } }
.ripple {
  position: absolute; z-index: 2; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 1.5px solid #e4967c; border-radius: 50%;
  pointer-events: none; animation: rip .7s ease-out forwards;
}
@keyframes rip { from { transform: scale(.2); opacity: .9; } to { transform: scale(1); opacity: 0; } }
html.paged .hero { touch-action: none; }
.fader { position: absolute; inset: 0; z-index: 3; background: var(--night); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
/* Sin WebGL o con ahorro de datos: portada simple, sin recorrido */
.no3d .hero { height: auto; }
.no3d .hero-stage { position: static; height: auto; padding: 88px 0; }
.no3d .tip, .no3d .tie, .no3d .fader, .no3d .scroll-cue, .no3d .hero-stage canvas, .no3d .city, .no3d .part, .no3d .term, .no3d .rail { display: none; }
.no3d .chapter { position: static; opacity: 1; visibility: visible; display: block; padding: 0; }
.no3d .chapter:not(.c0) { display: none; }

/* Franja de tecnologías */
.band { background: var(--accent-soft); color: #fff; overflow: hidden; padding: 22px 0; }
.band-track { display: flex; width: max-content; animation: band 50s linear infinite; }
.band ul { display: flex; align-items: center; }
.band li {
  display: flex; align-items: center; white-space: nowrap;
  font-family: var(--serif); font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1;
}
.band li::after { content: "✦"; font-family: var(--sans); font-size: .9rem; margin: 0 32px; opacity: .85; }
@keyframes band { to { transform: translateX(-50%); } }

/* Secciones */
.section { padding-top: 96px; padding-bottom: 32px; }
.section h2 { font-family: var(--serif); font-size: clamp(2.3rem, 4.2vw, 3.1rem); line-height: 1.05; margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-sub { color: var(--muted); margin: -18px 0 32px; }
.subhead { font-family: var(--serif); font-size: 1.75rem; margin: 64px 0 24px; }

/* Tarjetas */
.tiles { display: grid; gap: 16px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 26px 24px; background: var(--tile); border-radius: 6px; }
.tile h3 { font-size: 1.02rem; font-weight: 600; letter-spacing: -.005em; }
.tile p { color: var(--muted); font-size: .94rem; line-height: 1.55; }
.tile .tags { margin-top: auto; padding-top: 14px; font-size: .66rem; font-weight: 500; color: var(--text); line-height: 1.8; }
.tile-link { transition: background-color .2s; }
.tile-link:hover { background: var(--tile-hover); }
.tile-link:hover h3 { color: var(--accent); }

/* YouTube */
.videos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px 20px; }
.video { display: flex; flex-direction: column; gap: 12px; }
.video img, .video iframe { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 0; border-radius: 6px; background: var(--tile); }
.video-title { font-weight: 500; }
.video:hover .video-title { color: var(--accent); }

/* Certificaciones */
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.badges li { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 14px 22px; background: var(--tile); border-radius: 6px; }
.badges a { display: flex; flex-direction: column; align-items: center; gap: 14px; font-weight: 500; line-height: 1.3; }
.badges a:hover { color: var(--accent); }
.badges img { width: 80px; height: 80px; object-fit: contain; }
.badges .meta { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.all-badges { margin-top: 28px; }
.all-badges summary { cursor: pointer; list-style: none; display: inline-block; }
.all-badges summary::-webkit-details-marker { display: none; }
.all-badges summary::after { content: " +"; }
.all-badges[open] summary::after { content: " −"; }
.all-badges h3 { font-family: var(--serif); font-size: 1.4rem; margin: 32px 0 14px; }
.all-badges h3 span { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.badge-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 28px; font-size: .9rem; }
.badge-list li { display: flex; align-items: center; gap: 12px; line-height: 1.35; }
.badge-list img { width: 32px; height: 32px; flex: none; object-fit: contain; }
.badge-list a:hover { color: var(--accent); }
.badge-list .meta { display: block; color: var(--muted); font-size: .8rem; }

/* Contacto */
.contact { margin-top: 96px; background: var(--cream); text-align: center; padding: 96px 0; }
.contact h2 { margin-top: 18px; font-family: var(--serif); font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 1.05; }
.contact h2 em { font-style: italic; color: var(--accent-soft); }
.contact-email { margin-top: 16px; color: var(--muted); font-size: 1.1rem; }
.contact-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 30px; }

/* Footer */
.site-footer { color: var(--muted); font-size: .85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 28px; padding-bottom: 36px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 20px; }
.footer-links a:hover { color: var(--text); }

/* 404 */
.not-found { padding: 18vh 32px; text-align: center; }
.not-found h1 { font-family: var(--serif); font-size: 3rem; }
.not-found p { margin-top: 12px; color: var(--muted); }
.not-found a { color: var(--accent); }

/* Responsive */
@media (max-width: 1000px) {
  .tiles-4 { grid-template-columns: repeat(2, 1fr); }
  .badge-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .site-header { transition: transform .25s ease; }
  .hdr-off { --hh: 0px !important; }
  .hdr-off .site-header { transform: translateY(-100%); }
  .site-header nav a:not(.btn) { display: none; }
  .chapter { align-items: flex-end; padding-bottom: calc(64px + 8svh); }
  .scroll-cue { bottom: 64px; font-size: .64rem; }
  .scroll-cue::after { height: 20px; margin-top: 4px; }
  .chapter::before { content: ""; position: absolute; inset: 20% 0 0; background: linear-gradient(transparent, rgba(18, 14, 12, .88) 55%); z-index: -1; }
  .chapter-body { position: relative; }
  .chapter.c4::before { inset: 42% 0 0; }
  .term, .part, .tie { display: none; }
  /* puntos grandes abajo para cambiar de escena con el dedo (áreas táctiles de 44 px) */
  .rail { top: auto; right: auto; bottom: 6px; left: 50%; translate: -50% 0; display: flex; gap: 0; }
  .rail button { width: 44px; height: 44px; }
  .rail button::before { width: 11px; height: 11px; transition: background .3s, width .3s; }
  .rail li.on button::before { width: 28px; border-radius: 6px; transform: none; }
  .rail button::after { display: none; }
  .hero-stage::before { display: none; }
  .tiles-3 { grid-template-columns: repeat(2, 1fr); }
  .videos { grid-template-columns: repeat(2, 1fr); }
  .section { padding-top: 72px; }
}

@media (max-width: 560px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
  :root { --hh: 64px; }
  .site-header .wrap { height: 64px; }
  .brand { font-size: 1.35rem; }
  .tiles-3, .tiles-4, .badge-list { grid-template-columns: 1fr; }
  .badges { grid-template-columns: repeat(2, 1fr); }
  .band { padding: 16px 0; }
  .band li::after { margin: 0 22px; }
  .contact { padding: 72px 0; margin-top: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .band-track, .scroll-cue::after, .term i, .tie line, .ripple { animation: none; }
}
