/* =====================================================================
   HABITAT — Tema Ghost para Domotily v1.0
   Nunito 700/800 (display) + Inter 400/500/600 (body)
   ===================================================================== */

/* ---- TOKENS ---- */
:root {
  /* Variables de fuente reconocidas por Ghost Admin */
  --gh-font-heading: 'Nunito', sans-serif;
  --gh-font-body:    'Inter', sans-serif;

  --amber:   #df9a2a;
  --amber-h: #c7871f;
  --blue:    #2ac2de;
  --dark:    #12131a;
  --dark2:   #1c1e2a;
  --bg:      #f7f8fa;
  --surface: #ffffff;
  --text:    #2d2d2d;
  --muted:   #666666;
  --light:   #999999;
  --border:  #e4e7eb;
  --shadow:  0 2px 16px rgba(0, 0, 0, .07);
  --shadow-h:0 8px 28px rgba(0, 0, 0, .13);
  --radius:  12px;
  --fn-d: 'Nunito', sans-serif;
  --fn-b: 'Inter', sans-serif;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

body {
  font-family: var(--fn-b);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#site-main { flex: 1; }

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* =====================================================================
   HEADER
   ===================================================================== */
.site-header {
  background: var(--dark);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-main {
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  height: 64px;
}

/* LED de estado */
.led-wrap {
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.site-led {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  animation: led-breath 2.8s ease-in-out infinite;
}

.site-led.off {
  animation: none;
  opacity: .2;
}

@keyframes led-breath {
  0%, 100% { opacity: 1; }
  50%       { opacity: .18; }
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.logo-img {
  height: 34px;
  width: auto;
}

.logo-word {
  font-family: var(--fn-d);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -.02em;
  color: #fff;
}

.c-amber { color: var(--amber); }
.c-blue  { color: var(--blue); }

/* Nav principal */
.site-nav { margin-left: auto; }

.site-nav > ul {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}

.site-nav > ul > li > a {
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .65);
  transition: color .15s;
}

.site-nav > ul > li > a:hover { color: var(--amber); }

/* Botón Categorías */
.nav-cats-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .65);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--fn-b);
  transition: color .15s;
}

.nav-cats-btn:hover,
.nav-cats-btn.active { color: var(--amber); }

.nav-cats-btn svg { transition: transform .2s; }
.nav-cats-btn.active svg { transform: rotate(180deg); }

/* Subheader de categorías */
.cats-subheader {
  max-height: 0;
  overflow: hidden;
  transition: max-height .22s ease;
}

.cats-subheader.open {
  max-height: 48px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.cats-subheader-inner {
  display: flex;
  align-items: stretch;
  height: 46px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.cats-subheader-inner::-webkit-scrollbar { display: none; }

.cats-subheader a {
  display: flex;
  align-items: center;
  padding: 0 1.125rem;
  font-size: .8125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, .5);
  transition: color .15s, background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.cats-subheader a:hover {
  color: var(--amber);
  background: rgba(255, 255, 255, .03);
}

.cats-subheader a + a {
  border-left: 1px solid rgba(255, 255, 255, .05);
}

/* =====================================================================
   HERO (solo en home)
   ===================================================================== */
.hero {
  background: var(--dark);
  padding: 3rem 0 2.75rem;
}

.hero-tagline { margin-bottom: 1.1rem; }

.hero-line {
  display: block;
  font-family: var(--fn-d);
  font-weight: 800;
  font-size: clamp(2rem, 3.8vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -.03em;
}

.hero-line-1 { color: #fff; }
.hero-line-2 { color: var(--amber); }

.hero-sub {
  font-size: .9375rem;
  color: rgba(255, 255, 255, .44);
  max-width: 520px;
  margin-bottom: 1.75rem;
  line-height: 1.7;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  padding: .75rem 1.625rem;
  background: var(--amber);
  color: #fff;
  font-weight: 600;
  font-size: .9375rem;
  border-radius: 8px;
  transition: background .2s, transform .15s;
}

.hero-cta:hover {
  background: var(--amber-h);
  transform: translateY(-2px);
}

/* =====================================================================
   SECCIÓN DE POSTS (HOME)
   ===================================================================== */
.posts-section { padding: 2.25rem 0 3.5rem; }

.section-label {
  font-family: var(--fn-d);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.posts-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.posts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

/* =====================================================================
   POST CARD — stretched link (toda la tarjeta es clicable)
   ===================================================================== */
.post-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .22s, transform .22s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.post-card:hover {
  box-shadow: var(--shadow-h);
  transform: translateY(-3px);
}

/* El enlace del título estira un pseudo-elemento sobre toda la card */
.card-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* El tag de categoría queda por encima del stretched link */
.card-tag {
  position: relative;
  z-index: 2;
  font-size: .6375rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: .35rem;
  display: inline-block;
  transition: color .15s;
}

.card-tag:hover { color: var(--amber-h); }

/* Imagen */
.card-img {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  flex-shrink: 0;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.post-card:hover .card-img img { transform: scale(1.03); }

/* Cuerpo */
.card-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-family: var(--fn-d);
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: .5rem;
}

.card-title a { transition: color .15s; }
.post-card:hover .card-title a { color: var(--amber); }

.card-excerpt {
  font-size: .8125rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
  margin-bottom: .75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: .75rem;
  color: var(--light);
  display: flex;
  gap: .4rem;
  align-items: center;
}

/* =====================================================================
   FEATURED CARD — horizontal, dominante
   ===================================================================== */
.post-card-featured {
  display: grid;
  grid-template-columns: 42% 1fr;
  min-height: 280px;
}

.card-img-featured {
  aspect-ratio: unset;
  height: 100%;
}

.card-body-featured {
  padding: 1.75rem 2rem;
  justify-content: center;
}

.featured-eyebrow {
  display: block;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--amber);
  opacity: .6;
  margin-bottom: .2rem;
}

.card-title-featured {
  font-size: 1.375rem;
  line-height: 1.28;
  margin-bottom: .875rem;
}

.card-excerpt-featured {
  font-size: .9375rem;
  -webkit-line-clamp: 4;
  margin-bottom: 1rem;
}

/* =====================================================================
   PAGINACIÓN
   ===================================================================== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0 1rem;
  font-size: .875rem;
  color: var(--muted);
}

.newer-posts,
.older-posts {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--amber);
  font-weight: 500;
  transition: color .15s;
}

.newer-posts:hover,
.older-posts:hover { color: var(--amber-h); }

.page-number {
  font-size: .8125rem;
  color: var(--light);
}

/* =====================================================================
   PÁGINAS DE TAG / ARCHIVO
   ===================================================================== */
.tag-header,
.archive-header {
  background: var(--dark);
  padding: 2.5rem 0 2.25rem;
}

.tag-eyebrow {
  display: block;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: .75rem;
}

.tag-name,
.archive-title {
  font-family: var(--fn-d);
  font-weight: 800;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  color: #fff;
  letter-spacing: -.025em;
  line-height: 1.15;
  margin-bottom: .5rem;
}

.tag-description {
  font-size: .9375rem;
  color: rgba(255, 255, 255, .44);
  max-width: 520px;
}

.tag-section,
.archive-section { padding: 2.25rem 0 3.5rem; }

/* Grid 3x3 para páginas de tag */
.tag-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

/* =====================================================================
   ARTÍCULO INDIVIDUAL
   ===================================================================== */

/* Cabecera oscura */
.post-header {
  background: var(--dark);
  padding: 4rem 0 3rem;
}

.post-header-inner {
  max-width: 760px;
  margin: 0 auto;
}

.post-eyebrow {
  display: block;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.125rem;
  transition: color .15s;
}

.post-eyebrow:hover { color: var(--amber-h); }

.post-title {
  font-family: var(--fn-d);
  font-size: clamp(1.875rem, 4vw, 2.875rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -.025em;
  margin-bottom: 1.25rem;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: rgba(255, 255, 255, .36);
}

/* Imagen de cabecera — contenida (max 1140px, no full bleed) */
.post-feature-wrap {
  background: var(--dark);
  padding-bottom: 2rem;
}

.post-feature-image {
  overflow: hidden;
  border-radius: var(--radius);
  max-height: 480px;
}

.post-feature-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-height: 480px;
  display: block;
}

/* Cuerpo del artículo — fondo claro */
.post-body {
  background: var(--surface);
  padding: 2.75rem 0 3.5rem;
}

/* =====================================================================
   CONTENIDO GHOST (gh-content)
   ===================================================================== */
.gh-content {
  max-width: 720px;
  margin: 0 auto;
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text);
}

.gh-content p { margin-bottom: 1.4rem; }

.gh-content h2 {
  font-family: var(--fn-d);
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  letter-spacing: -.02em;
}

.gh-content h3 {
  font-family: var(--fn-d);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 2rem 0 .75rem;
}

.gh-content h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.5rem 0 .5rem;
}

.gh-content a {
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(223, 154, 42, .4);
  transition: text-decoration-color .15s;
}

.gh-content a:hover { text-decoration-color: var(--amber); }

.gh-content ul,
.gh-content ol {
  margin: 0 0 1.4rem 1.5rem;
}

.gh-content li { margin-bottom: .4rem; }

.gh-content blockquote {
  border-left: 3px solid var(--amber);
  padding: .5rem 0 .5rem 1.5rem;
  margin: 1.75rem 0;
  color: var(--muted);
  font-style: italic;
}

.gh-content blockquote p { margin-bottom: 0; }

.gh-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Código inline */
.gh-content code {
  font-family: 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;
  font-size: .875em;
  background: #f0f2f5;
  padding: .15em .4em;
  border-radius: 4px;
  color: #c0392b;
}

/* Bloques de código */
.gh-content pre {
  background: var(--dark);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  font-size: .875rem;
  line-height: 1.7;
}

.gh-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: #e2e8f0;
  font-size: inherit;
}

/* Tablas */
.gh-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  font-size: .9375rem;
}

.gh-content th,
.gh-content td {
  text-align: left;
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--border);
}

.gh-content th {
  font-family: var(--fn-d);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Imágenes y figuras */
.gh-content img { border-radius: 8px; margin: 1.5rem auto; }

.gh-content figure { margin: 1.75rem 0; }

.gh-content figcaption {
  font-size: .8125rem;
  color: var(--light);
  text-align: center;
  margin-top: .5rem;
}

/* =====================================================================
   KOENIG — CLASES OBLIGATORIAS (GScan)
   ===================================================================== */
.kg-image-card,
.kg-gallery-card,
.kg-embed-card,
.kg-bookmark-card,
.kg-callout-card,
.kg-code-card,
.kg-header-card,
.kg-product-card,
.kg-toggle-card,
.kg-signup-card,
.kg-audio-card,
.kg-video-card,
.kg-file-card,
.kg-nft-card {
  margin: 1.75rem 0;
}

.kg-image { max-width: 100%; border-radius: 8px; }

/* Galería */
.kg-gallery-container { display: flex; flex-direction: column; gap: .5rem; }
.kg-gallery-row { display: flex; gap: .5rem; }

.kg-gallery-image {
  flex: 1;
  overflow: hidden;
  border-radius: 6px;
}

.kg-gallery-image img { width: 100%; height: 100%; object-fit: cover; }

/* Callout */
.kg-callout-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #f0f7ff;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
}

.kg-callout-emoji { font-size: 1.25rem; flex-shrink: 0; }

/* Bookmark */
.kg-bookmark-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.kg-bookmark-container {
  display: flex;
  color: inherit;
  text-decoration: none;
}

.kg-bookmark-content {
  flex: 1;
  padding: 1rem;
}

.kg-bookmark-title {
  font-weight: 600;
  font-size: .9375rem;
  margin-bottom: .25rem;
}

.kg-bookmark-description {
  font-size: .8125rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kg-bookmark-metadata {
  font-size: .75rem;
  color: var(--light);
  margin-top: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.kg-bookmark-icon { width: 16px; height: 16px; }

.kg-bookmark-thumbnail {
  width: 160px;
  flex-shrink: 0;
  overflow: hidden;
}

.kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

/* Embeds */
.kg-embed-card iframe {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

/* Toggle */
.kg-toggle-heading-text { font-weight: 600; }

/* =====================================================================
   KOENIG — ANCHOS ESPECIALES (obligatorio GScan)
   ===================================================================== */

/* Contenido extendido — sale del column de 720px pero no va a viewport completo */
.gh-content .kg-width-wide {
  position: relative;
  width: 85vw;
  max-width: 1040px;
  left: 50%;
  transform: translateX(-50%);
}

/* Ancho completo — viewport 100% */
.gh-content .kg-width-full {
  position: relative;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
}

.kg-width-wide img,
.kg-width-full img { width: 100%; border-radius: 0; }

/* =====================================================================
   PÁGINA ESTÁTICA
   ===================================================================== */
.page-header {
  background: var(--dark);
  padding: 3.5rem 0 3rem;
}

.page-title {
  font-family: var(--fn-d);
  font-size: clamp(1.875rem, 4vw, 2.75rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -.025em;
  line-height: 1.15;
}

.page-body {
  background: var(--surface);
  padding: 2.75rem 0 3.5rem;
}

.page-content {
  max-width: 720px;
  margin: 0 auto;
}

/* =====================================================================
   PÁGINA DE ERROR
   ===================================================================== */
.error-section {
  background: var(--dark);
  min-height: 60vh;
  display: flex;
  align-items: center;
}

.error-inner {
  padding: 4rem 0;
  text-align: center;
}

.error-code {
  font-family: var(--fn-d);
  font-size: 7rem;
  font-weight: 800;
  color: var(--amber);
  line-height: 1;
  margin-bottom: 1rem;
}

.error-title {
  font-family: var(--fn-d);
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .75rem;
}

.error-msg {
  font-size: .9375rem;
  color: rgba(255, 255, 255, .44);
  margin-bottom: 2rem;
}

.error-btn {
  display: inline-flex;
  align-items: center;
  padding: .75rem 1.625rem;
  background: var(--amber);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  transition: background .2s;
}

.error-btn:hover { background: var(--amber-h); }

/* =====================================================================
   FOOTER
   ===================================================================== */
.site-footer {
  background: var(--dark);
  padding: 2.75rem 0 1.75rem;
  margin-top: auto;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  padding-bottom: 1.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.footer-tagline {
  font-size: .875rem;
  color: rgba(255, 255, 255, .32);
  line-height: 1.6;
}

.footer-social {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-social a {
  color: rgba(255, 255, 255, .34);
  display: flex;
  align-items: center;
  transition: color .15s;
}

.footer-social a:hover { color: var(--amber); }

.footer-nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.footer-nav a {
  font-size: .875rem;
  color: rgba(255, 255, 255, .46);
  transition: color .15s;
}

.footer-nav a:hover { color: var(--amber); }

.footer-bottom {
  font-size: .8125rem;
  color: rgba(255, 255, 255, .24);
}

/* =====================================================================
   ACCESIBILIDAD
   ===================================================================== */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

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

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 860px) {
  .post-card-featured {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .card-img-featured {
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .posts-row { grid-template-columns: 1fr 1fr; }
  .tag-grid { grid-template-columns: 1fr 1fr; }

  .kg-bookmark-thumbnail { display: none; }
}

@media (max-width: 580px) {
  .posts-row { grid-template-columns: 1fr; }
  .tag-grid { grid-template-columns: 1fr; }

  .site-nav > ul { gap: 1rem; }

  .footer-top {
    flex-direction: column;
  }
}
