/* ===========================================================
   Jesús Sierra — Shared site styles
   =========================================================== */

/* ===========  LIGHT MODE ========= */
:root {
  --cream:               #F4EEE1;
  --cream-soft:          #F8F3E8;
  --cream-warm:          #EDE4D0;
  --ink:                 #14110E;
  --ink-soft:            #2C2924;
  --ink-muted:           #6B6457;
  --accent:              #FF4D1A;
  --accent-dark:         #D93500;
  --accent-soft:         #FFB59B;
  --line:                #D9CDB0;
  /* Inverted panel (stays dark on light mode, becomes light on dark mode) */
  --contrast-bg:         #14110E;
  --contrast-text:       #F4EEE1;
  --contrast-text-soft:  #D9D1BF;
  --contrast-text-muted: #A69E8A;
  --contrast-line:       #3A362E;
  --nav-bg:              rgba(244,238,225,0.85);
  --grain:               rgba(20,17,14,0.035);
}

/* =========== DARK MODE =========== */
html.dark {
  --cream:               #14110E;
  --cream-soft:          #1C1814;
  --cream-warm:          #241F18;
  --ink:                 #F0E9DB;
  --ink-soft:            #CFC6B0;
  --ink-muted:           #8C8470;
  --accent:              #FF7A45;
  --accent-dark:         #FF4D1A;
  --accent-soft:         #FFC4A3;
  --line:                #2F2B24;
  --contrast-bg:         #EDE4D0;
  --contrast-text:       #14110E;
  --contrast-text-soft:  #2C2924;
  --contrast-text-muted: #6B6457;
  --contrast-line:       #C4B898;
  --nav-bg:              rgba(20,17,14,0.85);
  --grain:               rgba(240,233,219,0.04);
}

html { scroll-behavior: smooth; }
body {
  background-color: var(--cream);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: "ss01", "ss02", "cv01";
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
}

/* Utility classes using CSS variables */
.font-display     { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; }
.font-mono        { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.bg-cream         { background-color: var(--cream); }
.bg-cream-soft    { background-color: var(--cream-soft); }
.bg-cream-warm    { background-color: var(--cream-warm); }
.text-ink         { color: var(--ink); }
.text-ink-soft    { color: var(--ink-soft); }
.text-ink-muted   { color: var(--ink-muted); }
.text-accent      { color: var(--accent); }
.bg-accent        { background-color: var(--accent); }
.border-ink       { border-color: var(--ink); }
.border-line      { border-color: var(--line); }
.bg-contrast      { background-color: var(--contrast-bg); }
.text-contrast    { color: var(--contrast-text); }
.text-contrast-soft  { color: var(--contrast-text-soft); }
.text-contrast-muted { color: var(--contrast-text-muted); }
.border-contrast  { border-color: var(--contrast-line); }
.tab-nums         { font-variant-numeric: tabular-nums; }

.underline-accent {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 6px;
  text-decoration-thickness: 3px;
}

/* Grain overlay */
.grain::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--grain) 1px, transparent 1px);
  background-size: 4px 4px;
  pointer-events: none;
}

/* CTA buttons */
.btn-primary {
  background: var(--ink);
  color: var(--cream);
  transition: all .2s ease;
}
.btn-primary:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}
.btn-ghost {
  color: var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transition: all .2s ease;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

/* KPI animations */
.kpi-bar   { transform-origin: left; animation: grow 1.8s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.blink     { animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Main marquee (services) */
.marquee-track {
  display: flex; gap: 4rem; white-space: nowrap;
  animation: marquee 40s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Nav bg with alpha */
.nav-bg {
  background-color: var(--nav-bg);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}

/* Section divider */
.hr-line { height: 1px; background: var(--line); border: 0; }

/* Service row hover — bloque entero en naranja acento */
.service-row { transition: background-color .25s ease, color .25s ease; }
.service-row:hover               { background-color: var(--accent); }
.service-row:hover,
.service-row:hover .font-display,
.service-row:hover .text-ink     { color: #fff; }
.service-row:hover .text-ink-soft  { color: rgba(255,255,255,.92); }
.service-row:hover .text-ink-muted { color: rgba(255,255,255,.72); }
.service-row:hover .border-line    { border-color: rgba(255,255,255,.35); color: rgba(255,255,255,.92); }

/* Quote mark */
.quote-mark {
  font-family: 'Fraunces', serif;
  font-size: 7rem;
  line-height: 0.8;
  color: var(--accent);
  opacity: .35;
}

/* Form inputs */
.field {
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  padding: .9rem 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  color: var(--ink);
  font-family: inherit;
  font-size: 1.05rem;
}
.field:focus { outline: none; border-color: var(--accent); }
.field::placeholder { color: var(--ink-muted); font-style: italic; }
textarea.field {
  resize: vertical;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: clamp(.9rem, 2.5vw, 1.05rem);
}

/* Nav link underline */
.nav-link { position: relative; }
.nav-link::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -6px;
  height: 1.5px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease;
}
.nav-link:hover::after,
.nav-link.is-active::after { transform: scaleX(1); }
.nav-link.is-active { color: var(--accent); }

/* Scroll progress — filo acento bajo el header */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 70;
  box-shadow: 0 0 12px 0 var(--accent);
  transition: width .08s linear;
  pointer-events: none;
}

/* Scroll-up button */
.scroll-up {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease, background-color .2s ease, visibility 0s linear .25s;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.35);
  z-index: 80;
  cursor: pointer;
  border: 0;
}
.scroll-up.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity .25s ease, transform .25s ease, background-color .2s ease;
}
.scroll-up:hover { background: var(--accent); color: #fff; }
.scroll-up:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Burger button (mobile) */
.burger-btn {
  display: inline-flex;
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.burger-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (min-width: 1024px) { .burger-btn { display: none; } }

/* Mobile sheet nav */
.mobile-sheet {
  position: fixed;
  top: 64px; /* debajo del header sticky (h-16) */
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: var(--cream);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
  overflow-y: auto;
  padding: 20px 22px 40px;
}
.mobile-sheet.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .25s ease;
}
.mobile-sheet a {
  display: block;
  padding: 14px 0;
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.mobile-sheet a:hover { color: var(--accent); }
.mobile-sheet .sheet-cta {
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: .95rem;
  border: 0;
  padding: 14px 20px;
  margin-top: 22px;
  display: block;
}
.mobile-sheet .sheet-cta:hover { background: var(--accent); color: #fff; }
body.no-scroll { overflow: hidden; }

/* Toggle button (theme / linkedin) */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  transition: all .18s ease;
}
.toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.theme-btn { width: 34px; padding: 0; }
.linkedin-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.linkedin-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
}

/* Lang toggle — on/off segmented pill */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  gap: 2px;
}
.lang-opt {
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  border: 0;
  line-height: 1;
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px -2px var(--accent);
}

/* Logo mark (favicon como avatar junto al nombre) */
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #F4EEE1;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Foto personal — circular portrait con fallback */
.portrait {
  width: clamp(88px, 12vw, 128px);
  height: clamp(88px, 12vw, 128px);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background-color: var(--accent);
  background-image: url('photo.png');
  background-size: cover;
  background-position: center 20%;
  box-shadow: 0 8px 32px -8px rgba(20,17,14,.25);
  border: 3px solid var(--cream);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.portrait .portrait-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(2rem, 4vw, 3rem);
  color: #F4EEE1;
  z-index: -1;
}
.portrait-xl {
  width: clamp(140px, 18vw, 220px);
  height: clamp(140px, 18vw, 220px);
}

/* Top bar — manifesto marquee */
.topbar {
  background: var(--accent);
  color: #fff;
  overflow: hidden;
  contain: paint; /* fuerza clip GPU en iOS Safari */
  border-bottom: 1px solid rgba(255,255,255,.15);
  position: relative;
  z-index: 60;
}
.topbar-track {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  white-space: nowrap;
  animation: topbarMarquee 20s linear infinite;
  padding: 9px 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.01em;
}
.topbar-track .tb-sep {
  opacity: .55;
  font-family: 'Fraunces', serif;
  font-size: 16px;
  line-height: 1;
}
@keyframes topbarMarquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.topbar:hover .topbar-track { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .topbar-track, .marquee-track { animation: none; }
}

/* Display sizes */
.h-display-xl { font-size: clamp(2.25rem, 7.5vw, 7rem);  line-height: 0.98; letter-spacing: -0.025em; }
.h-display-l  { font-size: clamp(1.9rem, 5.2vw, 4.5rem); line-height: 1.04; letter-spacing: -0.02em; }
.h-display-m  { font-size: clamp(1.6rem, 3.6vw, 3rem);   line-height: 1.1;  letter-spacing: -0.015em; }
.h-num        { font-size: clamp(3rem, 8vw, 7rem);       line-height: 1;    letter-spacing: -0.04em; }

/* Theme icons */
html:not(.dark) .icon-moon { display: none; }
html.dark     .icon-sun  { display: none; }

/* --- Global responsive safety --- */
/* overflow-x: hidden en body (no html) — no rompe position:sticky en iOS Safari */
/* touch-action: pan-y — bloquea swipe horizontal en iOS */
html { touch-action: pan-y; }
body { overflow-x: hidden; touch-action: pan-y; }
h1, h2, h3, blockquote, p {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
img, svg { max-width: 100%; height: auto; }
.marquee-track { white-space: nowrap; }

@media (max-width: 380px) {
  .toggle-btn { padding: 0 8px; height: 32px; }
  .theme-btn, .linkedin-btn { width: 32px; padding: 0; }
}
@media (max-width: 480px) {
  .h-num { font-size: clamp(2.5rem, 14vw, 4rem); }
  .quote-mark { font-size: 4rem !important; }
}
@media (max-width: 600px) {
  .topbar-track { gap: 1.6rem; font-size: 11.5px; padding: 7px 0; animation-duration: 8s; }
  .marquee-track { gap: 2.25rem; animation-duration: 6s; }
}

/* --- Legal / long-form text pages --- */
.prose-legal { max-width: 68ch; }
.prose-legal h2 {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: var(--ink);
}
.prose-legal h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: .5rem;
  color: var(--ink);
  font-weight: 600;
}
.prose-legal p, .prose-legal li {
  color: var(--ink-soft);
  line-height: 1.7;
  margin-bottom: 1rem;
  font-size: 1rem;
}
.prose-legal ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}
.prose-legal a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose-legal a:hover { color: var(--accent-dark); }
.prose-legal strong { color: var(--ink); font-weight: 600; }

/* --- Long-form note/article --- */
.prose-note { max-width: 88ch; }
.prose-note > * + * { margin-top: 1.25rem; }
.prose-note h2 {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-top: 3rem;
  margin-bottom: .75rem;
  color: var(--ink);
  font-weight: 500;
}
.prose-note h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  margin-top: 2.25rem;
  margin-bottom: .4rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.prose-note p, .prose-note li {
  color: var(--ink-soft);
  line-height: 1.75;
  font-size: 1.05rem;
}
.prose-note ul, .prose-note ol {
  padding-left: 1.3rem;
  margin-top: 1rem;
}
.prose-note ul { list-style: disc; }
.prose-note ol { list-style: decimal; }
.prose-note a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose-note a:hover { color: var(--accent-dark); }
.prose-note strong { color: var(--ink); font-weight: 600; }
.prose-note blockquote {
  border-left: 3px solid var(--accent);
  padding: .3rem 0 .3rem 1.25rem;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--ink);
  margin: 2rem 0;
}
.prose-note .callout {
  border: 1px solid var(--line);
  background: var(--cream-warm);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  margin: 2rem 0;
  font-size: .98rem;
  color: var(--ink-soft);
}
.prose-note .callout strong { display: block; margin-bottom: .3rem; font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }

/* --- Podcast player --- */
.podcast-block { display: none; }  /* shown by JS when SpeechSynthesis is available */
.podcast-block {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  max-width: 88ch;
}
.podcast-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  background: var(--cream-warm);
}
.dark .podcast-inner { background: rgba(255,255,255,.04); }

.podcast-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

.podcast-body { flex: 1; min-width: 0; }
.podcast-eye {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: .25rem;
}
.podcast-title {
  font-family: 'Fraunces', serif;
  font-size: .95rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .55rem;
}

.podcast-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.podcast-play-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .15s;
}
.podcast-play-btn:hover { opacity: .85; transform: scale(1.05); }

.podcast-track { flex: 1; min-width: 0; }
.podcast-bar-wrap {
  position: relative;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  cursor: pointer;
  margin-bottom: .3rem;
}
.podcast-bar-fill {
  position: absolute;
  left: 0; top: 0; height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  transition: width .1s linear;
}
.podcast-scrubber {
  position: absolute;
  inset: -6px 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  height: 16px;
}
.podcast-times {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: .04em;
}

.podcast-subscribe {
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: .3rem .65rem;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.podcast-subscribe:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 600px) {
  .podcast-subscribe { display: none; }
  .podcast-inner { gap: .75rem; }
}
