/* ==========================================================================
   ¿Por Qué Actúo Así? — Sistema Editorial Orgánico y Multi-Página (RDK)
   Papel lino cálido, fotografía real 35mm y lectura humana sin plantillas SaaS.
   ========================================================================== */

:root {
  --bg: #FAF6F0;
  --bg-tint: #F3ECE1;
  --surface: #FFFFFF;
  --ink: #1C1917;
  --ink-soft: #44403C;
  --muted: #57534E;
  --line: #E2D9CB;
  --line-strong: #C8BCAE;

  --accent: #B44B2B;
  --accent-hover: #963A1F;
  --accent-soft: #F9ECE7;
  --on-accent: #FFFFFF;

  --sage: #2D4A43;
  --sage-soft: #EBF1EE;
  --amber-paper: #FEF6E4;
  --amber-line: #E6C782;
  --amber-ink: #8A530B;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --ease-ui: cubic-bezier(0.2, 0.8, 0.2, 1);
  --container: 1120px;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

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

button,
a,
input,
textarea {
  font-family: inherit;
}

button,
a {
  cursor: pointer;
}

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

.wrap {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(20px, 4.5vw, 44px);
}

.wrap-reading {
  width: 100%;
  max-width: 780px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4.5vw, 32px);
}

/* ==========================================================================
   Barra Superior
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 246, 240, 0.93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
}

.brand-mark-link {
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.06rem, 1.5vw, 1.24rem);
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.text-link {
  position: relative;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 500;
}

.text-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 150ms var(--ease-ui);
}

.text-link:hover {
  color: var(--ink);
}

.text-link:hover::after {
  transform: scaleX(1);
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 150ms var(--ease-ui),
    border-color 150ms var(--ease-ui),
    color 150ms var(--ease-ui),
    transform 150ms var(--ease-ui);
  will-change: transform;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-outline:hover {
  border-color: var(--ink);
  background: var(--bg-tint);
}

.btn-sage {
  background: var(--sage);
  color: #FFFFFF;
}

.btn-sage:hover {
  background: #213832;
}

.btn-sm {
  min-height: 44px;
  padding: 9px 18px;
  font-size: 0.88rem;
}

.btn-lg {
  min-height: 54px;
  padding: 15px 28px;
  font-size: 1.02rem;
}

.btn svg {
  width: 18px;
  height: 18px;
  transition: transform 150ms var(--ease-ui);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-1px);
  }
  .btn:hover svg {
    transform: translateX(3px);
  }
}

.btn:active {
  transform: translateY(1px) scale(0.985);
  transition-duration: 90ms;
}

/* ==========================================================================
   Hero Fotográfico
   ========================================================================== */
.hero {
  padding-block: clamp(36px, 5.5vh, 68px) clamp(52px, 7.5vh, 84px);
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: clamp(30px, 5vw, 56px);
  align-items: center;
}

.hero-title {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 72, "SOFT" 45;
  font-size: clamp(2.15rem, 4vw, 3.25rem);
  line-height: 1.09;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.hero-title em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}

.hero-copy {
  margin: 0 0 26px;
  font-size: clamp(1.04rem, 1.25vw, 1.14rem);
  color: var(--ink-soft);
  max-width: 49ch;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.byline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.byline img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  flex-shrink: 0;
}

.photo-frame {
  overflow: hidden;
  border-radius: 18px;
  background: var(--bg-tint);
}

.photo-frame img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 420ms var(--ease-ui);
}

.photo-frame--43 {
  aspect-ratio: 4 / 3;
}

.photo-frame--43 img {
  height: 100%;
}

.photo-frame--169 {
  aspect-ratio: 16 / 9;
}

.photo-frame--169 img {
  height: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .photo-frame:hover img {
    transform: scale(1.024);
  }
}

/* ==========================================================================
   Escenas Reales (Flujo Editorial Sin Cajitas)
   ========================================================================== */
.story-band {
  padding-block: clamp(52px, 7vh, 84px);
  border-top: 1px solid var(--line);
  scroll-margin-top: 74px;
}

.story-intro {
  max-width: 62ch;
  margin-bottom: clamp(36px, 6vh, 56px);
}

.story-intro h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.02em;
}

.story-intro p {
  margin: 0;
  font-size: 1.06rem;
  color: var(--ink-soft);
}

.story-flow {
  display: flex;
  flex-direction: column;
  gap: clamp(48px, 7.5vh, 80px);
}

.scene-row {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: clamp(28px, 5vw, 58px);
  align-items: center;
}

.scene-row--reverse .scene-media {
  order: 2;
}

.scene-text h3 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(1.42rem, 2.3vw, 1.88rem);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.015em;
}

.scene-text p {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 1.03rem;
  max-width: 52ch;
}

.scene-text p:last-child {
  margin-bottom: 0;
}

.scene-link {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.scene-link:hover {
  color: var(--accent-hover);
}

/* ==========================================================================
   Mapa Interactivo de 3 Preguntas (#mapeador)
   ========================================================================== */
.mapper-band {
  padding-block: clamp(56px, 8vh, 96px);
  background: var(--bg-tint);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 74px;
}

.mapper-header {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
  margin-bottom: clamp(30px, 5vh, 46px);
}

.mapper-header h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.2vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.mapper-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 50ch;
}

.notebook-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 4.5vw, 48px);
}

.step-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.progress-line {
  flex: 0 1 160px;
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-line-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0.36);
  transition: transform 280ms var(--ease-ui);
}

.question-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.38rem, 2.4vw, 1.85rem);
  font-weight: 600;
  line-height: 1.24;
}

.question-sub {
  margin: 0 0 22px;
  color: var(--muted);
}

.option-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 68px;
  padding: 18px 14px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition:
    background-color 150ms var(--ease-ui),
    padding-left 150ms var(--ease-ui);
}

.option-row:hover {
  background: var(--bg);
  padding-left: 20px;
}

.option-row:active {
  transform: scale(0.992);
  transition-duration: 90ms;
}

.option-row.is-selected {
  background: var(--accent-soft);
}

.option-title {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 1.45vw, 1.22rem);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}

.option-desc {
  display: block;
  font-size: 0.94rem;
  color: var(--muted);
  line-height: 1.45;
}

.option-arrow {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 150ms var(--ease-ui);
}

.option-row:hover .option-arrow {
  transform: translateX(4px);
}

.back-row {
  margin-top: 20px;
}

.back-btn {
  background: none;
  border: 0;
  min-height: 44px;
  padding: 8px 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.back-btn:hover {
  color: var(--ink);
}

.calculating-beat {
  padding: clamp(44px, 8vh, 80px) 16px;
  text-align: center;
}

.calculating-beat p {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.65rem);
  color: var(--ink);
}

.calculating-sub {
  margin-top: 8px !important;
  font-family: var(--font-sans) !important;
  font-size: 0.96rem !important;
  color: var(--muted) !important;
}

/* Resultado */
.result-split {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr);
  gap: clamp(28px, 4.5vw, 48px);
  align-items: start;
}

.result-kicker {
  display: inline-block;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.result-heading {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.9vw, 2.3rem);
  font-weight: 600;
  line-height: 1.16;
}

.result-lead {
  margin: 0 0 24px;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.letter-block {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.letter-block h4 {
  margin: 0 0 6px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--sage);
}

.letter-block p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.phrase-note {
  padding: 22px 24px;
  border-radius: 14px;
  background: var(--amber-paper);
  border: 1px solid var(--amber-line);
  margin-bottom: 22px;
}

.phrase-note-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.phrase-note-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--amber-ink);
}

.phrase-note-quote {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.14rem;
  line-height: 1.45;
  color: var(--ink);
}

/* Mini-Diario Local 3 días (sin login) */
.pocket-log {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pocket-log label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.pocket-log textarea {
  width: 100%;
  min-height: 84px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.pocket-log-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.pocket-status {
  font-size: 0.85rem;
  color: var(--sage);
  font-weight: 600;
}

/* Tarjeta visual + tamaños 4:5 y 9:16 */
.canvas-format-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.format-pill {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 600;
}

.format-pill[aria-pressed="true"] {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.canvas-preview {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 14px;
  background: var(--bg);
}

.canvas-preview canvas {
  width: 100%;
  height: auto;
  max-height: 460px;
  object-fit: contain;
}

.share-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.booking-nudge {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.booking-nudge p {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

/* ==========================================================================
   Directorio Claro de Guías Profundas (HTML Indexable + Enlaces Internos)
   ========================================================================== */
.guides-band {
  padding-block: clamp(52px, 7vh, 84px);
  border-bottom: 1px solid var(--line);
}

.guides-band h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 2.8vw, 2.25rem);
  font-weight: 600;
  line-height: 1.18;
}

.guides-band > .wrap > p {
  margin: 0 0 30px;
  color: var(--ink-soft);
  max-width: 58ch;
}

.guide-list {
  border-top: 1px solid var(--line);
}

.guide-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 8px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: background-color 150ms var(--ease-ui), padding-left 150ms var(--ease-ui);
}

.guide-item:hover {
  background: var(--bg-tint);
  padding-left: 16px;
}

.guide-item-title {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 1.6vw, 1.32rem);
  font-weight: 600;
  line-height: 1.28;
  margin-bottom: 4px;
}

.guide-item-desc {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ==========================================================================
   Páginas de Guías Pilar, /datos/ y /ricardo/
   ========================================================================== */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 18px;
}

.breadcrumb a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-header {
  padding-top: clamp(32px, 5vh, 56px);
  padding-bottom: 28px;
}

.article-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 22px;
}

.article-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 3.8vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.answer-lead {
  padding: 20px 24px;
  border-left: 4px solid var(--accent);
  background: var(--bg-tint);
  border-radius: 0 14px 14px 0;
  margin-bottom: 28px;
  font-size: 1.07rem;
  color: var(--ink);
}

.article-body {
  padding-bottom: clamp(48px, 7vh, 80px);
}

.article-body h2 {
  margin: 40px 0 14px;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.3vw, 1.9rem);
  font-weight: 600;
  line-height: 1.22;
}

.article-body p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 1.04rem;
}

.bisturi-quote {
  margin: 28px 0;
  padding: 20px 24px;
  border-left: 3px solid var(--sage);
  background: var(--sage-soft);
  border-radius: 0 14px 14px 0;
  font-family: var(--font-display);
  font-size: 1.16rem;
  line-height: 1.45;
  color: var(--ink);
}

.step-plus-one {
  margin: 34px 0;
  padding: 24px 26px;
  border-radius: 16px;
  background: var(--amber-paper);
  border: 1px solid var(--amber-line);
}

.step-plus-one h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.28rem;
  color: var(--amber-ink);
}

.inline-starter {
  margin: 36px 0;
  padding: 26px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.inline-starter h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.32rem;
}

.inline-starter p {
  margin: 0 0 16px;
  font-size: 0.96rem;
  color: var(--muted);
}

.starter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Tabla de Datos Abiertos (/datos/) */
.data-table-wrap {
  overflow-x: auto;
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  background: var(--bg-tint);
  font-weight: 700;
  color: var(--ink);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.cite-box {
  margin: 32px 0;
  padding: 22px 24px;
  background: var(--bg-tint);
  border-radius: 14px;
  border: 1px solid var(--line);
}

.cite-box pre {
  margin: 10px 0 14px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Cierre Ricardo y Footer
   ========================================================================== */
.ricardo-band {
  padding-block: clamp(56px, 8vh, 92px);
  scroll-margin-top: 74px;
}

.ricardo-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
}

.ricardo-photo {
  overflow: hidden;
  border-radius: 18px;
  background: var(--bg-tint);
}

.ricardo-photo img {
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: top center;
}

.ricardo-text h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 2.8vw, 2.25rem);
  font-weight: 600;
  line-height: 1.2;
}

.ricardo-text p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  max-width: 56ch;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 34px;
  font-size: 0.88rem;
  color: var(--muted);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-row a {
  color: var(--ink-soft);
  text-underline-offset: 3px;
}

.footer-row a:hover {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

@media (max-width: 920px) {
  .hero-layout,
  .scene-row,
  .mapper-header,
  .result-split,
  .ricardo-layout {
    grid-template-columns: 1fr;
  }

  .scene-row--reverse .scene-media {
    order: 0;
  }
}

@media (max-width: 640px) {
  .topbar-actions .text-link {
    display: none;
  }

  .btn {
    white-space: normal;
    text-align: center;
    max-width: 100%;
  }

  .share-buttons {
    grid-template-columns: 1fr;
  }

  .progress-line {
    flex-basis: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
