/*
 * MiraTuZona SEO pages
 * Inherits variables from styles.css (:root --primary, --bg-warm, etc.)
 * Adds only SEO-page-specific layout and components
 */

/* === Page-level overrides (SEO pages are scrollable, not fixed viewport) === */
.seo-page {
  height: auto;
  overflow: auto;
  display: block;
  flex-direction: unset;
}

.seo-page a { color: var(--primary); text-decoration: none; }
.seo-page a:hover { text-decoration: underline; }

/* === Header nav for SEO pages === */
.seo-page .header-nav {
  display: none;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}
@media (min-width: 768px) { .seo-page .header-nav { display: flex; } }

.seo-page .header-nav a {
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}
.seo-page .header-nav a:hover { color: var(--text-primary); text-decoration: none; }

.seo-page .header-nav-cta {
  background: var(--primary) !important;
  color: white !important;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-weight: 600 !important;
  transition: background 0.2s !important;
}
.seo-page .header-nav-cta:hover {
  background: var(--primary-dark) !important;
  text-decoration: none;
}

/* === Main content area === */
.seo-container {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}
@media (min-width: 640px) { .seo-container { padding: 2rem 1.5rem; } }
@media (min-width: 1024px) { .seo-container { padding: 2.5rem 2rem; } }

/* === Breadcrumb === */
.seo-breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}
.seo-breadcrumb a { color: var(--text-secondary); }
.seo-breadcrumb a:hover { color: var(--primary); }
.seo-breadcrumb span { margin: 0 0.35rem; opacity: 0.5; }

/* === Hero === */
.seo-hero { margin-bottom: 2rem; }
.seo-hero h1 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.35rem;
}
@media (min-width: 640px) { .seo-hero h1 { font-size: 2rem; } }

.seo-hero-sub {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.seo-summary {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text-primary);
}

/* === Metric cards === */
.seo-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.seo-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: box-shadow 0.2s;
}
.seo-card:hover {
  box-shadow: var(--shadow-soft);
}

.seo-card-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.seo-card-value {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}

.seo-card-note { font-size: 0.78rem; }
.seo-card-note.good { color: var(--success); }
.seo-card-note.bad { color: var(--error); }
.seo-card-note.neutral { color: var(--text-muted); }

/* === Content sections === */
.seo-section { margin-bottom: 2.5rem; }

.seo-section h2 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border-light);
}

.seo-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* === Data table === */
.seo-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 0.88rem;
}
.seo-table th, .seo-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.seo-table th {
  background: var(--bg-cream);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.seo-table td { color: var(--text-primary); }
.seo-table tr:last-child td { border-bottom: none; }
.seo-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* === Bar chart (CSS only) === */
.seo-bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}
.seo-bar-label {
  width: 55px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  font-weight: 500;
}
.seo-bar-track {
  flex: 1;
  height: 20px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
}
.seo-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  border-radius: 5px;
  min-width: 3px;
  transition: width 0.3s ease;
}
.seo-bar-value {
  width: 50px;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* === Links grid (other municipalities) === */
.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.seo-link-chip {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 500;
  transition: all 0.15s;
}
.seo-link-chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  text-decoration: none;
}

/* === CTA banner === */
.seo-cta {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  margin: 2.5rem 0;
  box-shadow: 0 4px 20px rgba(27, 67, 50, 0.25);
}
.seo-cta h3 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: white;
}
.seo-cta p {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 1.5rem;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}
.seo-cta-btn {
  display: inline-block;
  background: white;
  color: var(--primary-dark);
  padding: 0.8rem 2.25rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.seo-cta-btn:hover {
  text-decoration: none;
  background: var(--bg-cream);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* === Score badge === */
.seo-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: white;
}
.seo-score.high { background: var(--success); }
.seo-score.mid { background: #f59e0b; }
.seo-score.low { background: var(--error); }

/* === Risk badge === */
.seo-risk-badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.seo-risk-badge.alto { background: #fecaca; color: #991b1b; }
.seo-risk-badge.medio { background: #fef3c7; color: #92400e; }
.seo-risk-badge.bajo { background: #d1fae5; color: #065f46; }

/* === Footer (reuses landing footer structure) === */
.seo-page .lp-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.7);
  padding: 2.5rem 0;
}
.seo-page .lp-footer-logo {
  color: rgba(255,255,255,0.9) !important;
  margin-bottom: 1rem;
}
.seo-page .lp-footer-logo .logo-icon { stroke: var(--accent-light); }
.seo-page .lp-footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .seo-page .lp-footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 2rem; }
}
.seo-page .lp-footer-brand p {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 0.6rem;
  line-height: 1.5;
}
.seo-page .lp-footer-sources { font-size: 0.7rem; color: rgba(255,255,255,0.35); }
.seo-page .lp-footer h4 {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}
.seo-page .lp-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.seo-page .lp-footer a {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s;
}
.seo-page .lp-footer a:hover { color: white; text-decoration: none; }
.seo-page .lp-footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 2rem;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
@media (min-width: 768px) {
  .seo-page .lp-footer-bottom { flex-direction: row; justify-content: space-between; align-items: center; }
}
.seo-page .lp-footer-copyright { font-size: 0.8rem; color: rgba(255,255,255,0.5); }
.seo-page .lp-footer-disclaimer { font-size: 0.7rem; color: rgba(255,255,255,0.3); }

/* Inline content helpers */
.seo-page .seo-section p { margin-bottom: 0; font-size: 0.9rem; }
.seo-page .seo-section ul { list-style: none; padding: 0; }
.seo-page .seo-section li { padding: 0.35rem 0; font-size: 0.9rem; }
.seo-muted { color: var(--text-secondary); font-size: 0.88rem; }
.seo-source { margin-top: 0.5rem; font-size: 0.78rem; color: var(--text-muted); }

/* === Responsive === */
@media (max-width: 600px) {
  .seo-hero h1 { font-size: 1.35rem; }
  .seo-metrics { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .seo-card { padding: 0.75rem 1rem; }
  .seo-card-value { font-size: 1.2rem; }
  .seo-bar-label { width: 45px; font-size: 0.72rem; }
  .seo-container { padding: 1rem 0.75rem; }
  .seo-cta { padding: 1.5rem 1rem; }
}

/* Two-column grid for demographics */
.seo-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 400px) {
  .seo-grid-2 { grid-template-columns: 1fr; }
}

/* === Ranking pages === */

/* Key stats summary box */
.ranking-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.ranking-stats dt {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ranking-stats dd {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: var(--primary-dark);
}
@media (max-width: 600px) {
  .ranking-stats { grid-template-columns: 1fr; padding: 1rem; }
}

/* Horizontal bar chart */
.ranking-chart {
  margin-bottom: 2rem;
}
.ranking-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.ranking-bar-label {
  width: 140px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ranking-bar-track {
  flex: 1;
  height: 22px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.ranking-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  border-radius: 5px;
  min-width: 3px;
}
.ranking-bar-fill.top3 {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
/* Menor renta: top3 in table uses error color */
.seo-table .rank-num.bottom3 { color: var(--error); }
.ranking-bar-value {
  width: 65px;
  font-size: 0.78rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .ranking-bar-label { width: 90px; font-size: 0.7rem; }
  .ranking-bar-value { width: 55px; font-size: 0.72rem; }
  .ranking-bar-track { height: 18px; }
}

/* Ranking table number column */
.seo-table .rank-num {
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  width: 2rem;
  text-align: center;
}
.seo-table .rank-num.top3 { color: var(--primary); }

/* vs media column styling */
.seo-table .vs-above { color: var(--success); font-weight: 600; }
.seo-table .vs-below { color: var(--error); font-weight: 600; }

/* FAQ section */
.ranking-faq {
  margin-bottom: 2.5rem;
}
.ranking-faq h2 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border-light);
}
.ranking-faq-item {
  margin-bottom: 1.25rem;
}
.ranking-faq-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}
.ranking-faq-item p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Analysis section prose */
.ranking-analysis p {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
}

/* Related rankings links */
.ranking-related {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* === Ranking Hub Page === */

.ranking-hub-hero {
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 1.5rem 0;
}
.ranking-hub-hero h1 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
@media (min-width: 640px) { .ranking-hub-hero h1 { font-size: 2.4rem; } }

.ranking-hub-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 38rem;
  margin: 0 auto;
  line-height: 1.65;
}

.ranking-hub-topic {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-light);
}
.ranking-hub-topic:last-of-type { border-bottom: none; }

.ranking-hub-topic-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.ranking-hub-topic-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-muted);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.ranking-hub-topic-header h2 {
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.15rem;
  border-bottom: none;
  padding-bottom: 0;
}
.ranking-hub-topic-source {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ranking-hub-national {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 600px) { .ranking-hub-national { grid-template-columns: 1fr; } }

.ranking-hub-national-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all 0.15s;
  text-decoration: none;
}
.ranking-hub-national-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}
.ranking-hub-card-direction {
  font-size: 0.85rem;
  font-weight: 700;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ranking-hub-card-direction.up-green { background: #d1fae5; color: #065f46; }
.ranking-hub-card-direction.down-amber { background: #fef3c7; color: #92400e; }
.ranking-hub-card-direction.up-red { background: #fecaca; color: #991b1b; }
.ranking-hub-card-direction.down-green { background: #d1fae5; color: #065f46; }

.ranking-hub-card-arrow {
  margin-left: auto;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ranking-hub-topic h3 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ranking-hub-ccaa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.5rem;
}
@media (max-width: 700px) {
  .ranking-hub-ccaa-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .ranking-hub-ccaa-grid { grid-template-columns: 1fr; }
}
.ranking-hub-ccaa-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.ranking-hub-ccaa-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-right: 0.5rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-hub-ccaa-links {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
.ranking-hub-ccaa-links .seo-link-chip {
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
}
/* Color-coded chips: mayor = green bg, menor = amber bg */
.ranking-hub-ccaa-links .chip-mayor {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}
.ranking-hub-ccaa-links .chip-mayor:hover {
  background: #065f46;
  border-color: #065f46;
  color: white;
}
.ranking-hub-ccaa-links .chip-menor {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}
.ranking-hub-ccaa-links .chip-menor:hover {
  background: #92400e;
  border-color: #92400e;
  color: white;
}
/* Immigration: mayor = red bg, menor = green bg */
.ranking-hub-ccaa-links .chip-mayor-inm {
  background: #fecaca;
  border-color: #fca5a5;
  color: #991b1b;
}
.ranking-hub-ccaa-links .chip-mayor-inm:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: white;
}
.ranking-hub-ccaa-links .chip-menor-inm {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}
.ranking-hub-ccaa-links .chip-menor-inm:hover {
  background: #065f46;
  border-color: #065f46;
  color: white;
}

/* Cross-link section headings */
.ranking-crosslinks h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Light CTA (bottom of page, minimal) */
.seo-cta-light {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  margin-bottom: 1rem;
}
.seo-cta-light a {
  display: inline-block;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 1.5rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  transition: all 0.2s;
}
.seo-cta-light a:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}
