/*
 * Tokens de identidad visual de myhomly (docs/rediseno-2026-09.md §2).
 * Concepto "cercanía": titulares editoriales en serif sobre una interfaz sans
 * redondeada y tranquila, con la luz cálida del naranja Homly como único
 * acento fuerte. Los nombres de variables viejos (--clay, --dusk, --surface…)
 * se conservan: los componentes los usan y así toman la paleta nueva sin
 * tocarlos uno por uno.
 *
 * Fuentes autoalojadas, subset latino (español completo: á é í ó ú ñ ¿ ¡):
 * Figtree variable (texto/UI, 20 KB) e Instrument Serif (titulares, 21+22 KB).
 * Los fallbacks llevan `size-adjust` para que el cambio de fuente no mueva el
 * layout (CLS) cuando la web font llega después del primer paint.
 */

@font-face {
  font-family: 'Figtree';
  src: url('fonts/figtree-var-latin.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-italic-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* Fallbacks con métricas ajustadas: el texto ocupa casi lo mismo antes y
   después de que llegue la fuente real, así el swap no empuja el layout. */
@font-face {
  font-family: 'Figtree Fallback';
  src: local('Arial'), local('Helvetica'), local('Liberation Sans');
  size-adjust: 102%;
  ascent-override: 93%;
  descent-override: 25%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Instrument Serif Fallback';
  src: local('Georgia'), local('Times New Roman'), local('Liberation Serif');
  size-adjust: 88%;
  ascent-override: 98%;
  descent-override: 26%;
  line-gap-override: 0%;
}

:root {
  /* — Color — */
  --paper: #ffffff;
  --surface: #f7f5f2; /* secciones alternas, footer */
  --surface-2: #efece7; /* hover sobre surface, placeholders de foto */
  --ink: #1c1917;
  --ink-muted: #57534e;
  --ink-faint: #6b6560; /* 5.7:1 sobre blanco, 5.2:1 sobre --surface */
  --line: #e7e3dd;
  --line-strong: #d6d1c9;

  --brand: #ef5022; /* naranja del logo: acentos, texto grande, íconos */
  --clay: #cc3d17; /* botones con texto blanco (4.9:1) */
  --clay-ink: #a8360f; /* hover/active; enlaces en naranja sobre blanco */
  --clay-wash: #fff1eb;

  --night: #17131f; /* bloques oscuros: banda para asesores, pie del footer */
  --night-2: #231d2f;

  --dusk: #3d2f63; /* "Asesor verificado", foco */
  --dusk-wash: #eeecf5;

  --sun: #d99a2b; /* badges de amenidad (planta, pozo) */
  --sun-wash: #fbf1dc;

  --ok: #2f6e4f;
  --danger: #b3261e;

  /* Resplandor de atardecer, solo decorativo (hero, banda oscura). */
  --glow: radial-gradient(60% 60% at 70% 30%, rgba(239, 80, 34, 0.16) 0%, rgba(239, 80, 34, 0) 70%);
  --dusk-sky: linear-gradient(135deg, var(--sun) 0%, var(--brand) 45%, var(--dusk) 100%);

  /* — Tipografía — */
  --font-sans: 'Figtree', 'Figtree Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-display: 'Instrument Serif', 'Instrument Serif Fallback', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --text-xs: 0.8125rem; /* 13px */
  --text-sm: 0.9375rem; /* 15px */
  --text-md: 1rem; /* 16px */
  --text-lg: 1.25rem; /* 20px */
  --text-xl: 1.5rem; /* 24px */
  --text-2xl: 2rem; /* 32px */
  --text-3xl: 2.75rem; /* 44px */
  --text-display: clamp(2.75rem, 1.6rem + 4.6vw, 5.25rem); /* 44 → 84px */
  --text-section: clamp(2rem, 1.5rem + 2vw, 3rem); /* 32 → 48px */

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.55;

  /* — Espaciado — */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 6rem;

  /* — Radios y sombras — */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-card: 0 1px 2px rgba(28, 25, 23, 0.05), 0 8px 24px -12px rgba(28, 25, 23, 0.18);
  --shadow-card-hover: 0 2px 4px rgba(28, 25, 23, 0.06), 0 18px 40px -16px rgba(28, 25, 23, 0.3);
  --shadow-pill: 0 1px 2px rgba(28, 25, 23, 0.08), 0 2px 8px -4px rgba(28, 25, 23, 0.12);
  --shadow-popover: 0 4px 12px rgba(28, 25, 23, 0.06), 0 28px 60px -20px rgba(28, 25, 23, 0.35);

  --focus-ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--dusk);

  /* — Motion — */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 160ms;
  --dur: 240ms;
  --dur-slow: 560ms;

  --header-h: 72px;
  --container-max: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(239, 80, 34, 0.22);
  color: var(--ink);
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: var(--leading-tight);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* Titulares editoriales: serif, sin negrita (la fuerza viene del tamaño). */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.02;
}

.display em {
  font-style: italic;
  color: var(--brand);
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/*
 * Regla base de homly.js (`Homly._BASE_CSS`), copiada aquí a propósito: un
 * elemento `data-if` que empieza oculto (p. ej. el badge "Pozo" de una
 * tarjeta sin pozo, con `hidden` puesto por el propio SSR) depende de esta
 * regla para quedar realmente oculto — el atributo `hidden` nativo pierde
 * contra cualquier `display` explícito de una clase de autor, y sin esto se
 * ve un instante de más hasta que homly.js instala su hoja compartida
 * (layout shift real medido con Lighthouse). Por eso el layout marca `'*'`
 * como ya instalado en `Homly._stylesInstalled`.
 */
[data-if][hidden] {
  display: none !important;
}

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

@media (max-width: 640px) {
  .container {
    padding-inline: var(--space-4);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.pill:hover {
  border-color: var(--ink);
  box-shadow: var(--shadow-pill);
}

.pill:active {
  transform: scale(0.97);
}

.pill[aria-pressed='true'],
.pill.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--clay);
  color: var(--paper);
  font-weight: 700;
  font-size: var(--text-md);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--text-md);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn-secondary:hover {
  background: var(--surface);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-pill);
  padding: 3px var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.5;
}

.badge--sun {
  background: var(--sun-wash);
  color: #7a5412;
}

.badge--dusk {
  background: var(--dusk-wash);
  color: var(--dusk);
}

.badge--glass {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Revelado al entrar en pantalla (scroll-driven, sin JS). Sin soporte de
   `animation-timeline`, el contenido simplemente se ve quieto. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
  }
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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