/* ==========================================================================
 * EcoRadar Urbà · Portal Nacional d'Intel·ligència Climàtica Municipal
 * Disseny SaaS Premium / B2G en MODO CLAR per a ajuntaments i tècnics
 * ========================================================================== */

/* Sense @import de Google Fonts: bloquejava el renderitzat i enviava la IP de cada visitant a Google
 * (RGPD). Plus Jakarta Sans no s'usava; on es demana «Inter» el navegador fa servir system-ui. */

:root {
  --brand-primary: #0f5132;
  --brand-primary-light: #198754;
  --brand-accent: #10b981;
  --brand-accent-glow: rgba(16, 185, 129, 0.16);
  --brand-dark: #09261a;
  
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-subtle: #64748b;
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --border-light: rgba(15, 81, 50, 0.12);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(15, 81, 50, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px -4px rgba(15, 81, 50, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 20px 40px -6px rgba(15, 81, 50, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@font-face {
  font-family: 'AvenirNextLTPro';
  src: url('../fonts/AvenirNextLTPro-Demi.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
  min-height: 100vh;
  background-color: #f8fafc;
  background-image: 
    radial-gradient(at 85% 10%, rgba(16, 185, 129, 0.08) 0px, transparent 55%),
    radial-gradient(at 15% 90%, rgba(14, 165, 233, 0.06) 0px, transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--text-main);
  font-family: 'AvenirNextLTPro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
 * Cabecera y Navegación Principal (Modo Claro)
 * ========================================================================== */
.portal-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(15, 81, 50, 0.12);
  box-shadow: 0 2px 12px rgba(15, 81, 50, 0.04);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #0f172a;
}

.portal-brand img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.portal-brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.1;
}

.portal-brand-text span {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.portal-nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #0f5132;
  background: #ffffff;
  border: 1px solid rgba(15, 81, 50, 0.2);
  border-radius: var(--radius-full);
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-secondary:hover {
  background: #f0fdf4;
  border-color: #10b981;
  color: #044e2b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  /* Verd fosc: el blanc sobre #10b981 només donava 2,5:1 de contrast (WCAG AA demana 4,5:1). */
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-full);
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #065f46 0%, #064e3b 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
}

/* ==========================================================================
 * Hero Section (Modo Claro)
 * ========================================================================== */
.portal-hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 24px 36px;
  text-align: center;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  margin-bottom: 24px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.08);
}

.portal-badge-dot {
  width: 8px;
  height: 8px;
  background: var(--brand-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--brand-accent-glow);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.portal-hero h2 {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
  line-height: 1.15;
  max-width: 880px;
  margin: 0 auto 20px;
}

.portal-hero h2 span {
  color: #0f5132;
  background: linear-gradient(135deg, #0f5132 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.portal-hero p {
  font-size: 18px;
  color: #475569;
  max-width: 720px;
  margin: 0 auto 40px;
  font-weight: 400;
  line-height: 1.6;
}

/* ==========================================================================
 * Barra d'Estadístiques Clau (Modo Claro)
 * ========================================================================== */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  max-width: 1040px;
  margin: 0 auto 52px;
  padding: 24px 28px;
  background: #ffffff;
  border: 1px solid rgba(15, 81, 50, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(15, 81, 50, 0.06);
}

.portal-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
}

.portal-stat-item:not(:last-child) {
  border-right: 1px solid #e2e8f0;
}

.portal-stat-val {
  font-size: 32px;
  font-weight: 800;
  color: #0f5132;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 4px;
}

.portal-stat-lbl {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

/* ==========================================================================
 * Buscador i Filtres (Modo Claro)
 * ========================================================================== */
.portal-controls {
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.portal-search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
  max-width: 460px;
}

.portal-search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #64748b;
  pointer-events: none;
}

.portal-search-box input {
  width: 100%;
  padding: 12px 18px 12px 46px;
  font-size: 15px;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid rgba(15, 81, 50, 0.2);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  outline: none;
  transition: all 0.25s ease;
}

.portal-search-box input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.portal-select {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(15, 81, 50, 0.2);
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.portal-select:hover {
  border-color: #10b981;
}

.portal-select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.portal-filter-count {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
}

/* ==========================================================================
 * Grid de Municipis (Tarjetas SaaS en Modo Claro)
 * ========================================================================== */
.portal-grid {
  max-width: 1180px;
  margin: 0 auto 72px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: 28px;
}

.portal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid rgba(15, 81, 50, 0.12);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: #0f172a;
  box-shadow: 0 4px 20px rgba(15, 81, 50, 0.06);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 36px rgba(15, 81, 50, 0.14);
  border-color: rgba(16, 185, 129, 0.6);
}

.portal-card-header {
  position: relative;
  height: 160px;
  background: linear-gradient(135deg, #0f5132 0%, #1e3a8a 100%);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.portal-card-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 40%),
    linear-gradient(45deg, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
  pointer-events: none;
}

.portal-card-badge-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.95);
  color: var(--brand-dark);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.portal-card-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(16, 185, 129, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}

.portal-card-status::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
}

.portal-card-title-block {
  position: relative;
  z-index: 2;
}

.portal-card-title-block h3 {
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.portal-card-title-block p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  margin-top: 4px;
}

.portal-card-body {
  padding: 24px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 20px;
}

.portal-card-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.portal-feat {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}

.portal-feat span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.portal-feat strong {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.portal-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.portal-card-foot-note {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.portal-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #0f5132;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: #f0fdf4;
  border: 1px solid rgba(15, 81, 50, 0.2);
  text-decoration: none;
  transition: all 0.25s ease;
}

.portal-card:hover .portal-card-btn,
.portal-card-btn:focus-visible {
  background: #047857;
  color: #ffffff;
  border-color: #047857;
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.portal-card-btn.is-disponible {
  color: #0369a1;
  background: #f0f9ff;
  border-color: #bae6fd;
}

.portal-card:hover .portal-card-btn.is-disponible,
.portal-card-btn.is-disponible:focus-visible {
  background: #0369a1;
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

/* ==========================================================================
 * Banner d'Adhesió per a Ajuntaments (Modo Claro Premium)
 * ========================================================================== */
.portal-cta {
  max-width: 1180px;
  margin: 0 auto 80px;
  padding: 0 24px;
}

.portal-cta-card {
  background: linear-gradient(135deg, #09261a 0%, #0f5132 100%);
  border-radius: var(--radius-lg);
  padding: 48px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  box-shadow: 0 12px 36px rgba(15, 81, 50, 0.15);
  position: relative;
  overflow: hidden;
}

.portal-cta-card::before {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.portal-cta-content {
  position: relative;
  z-index: 2;
  max-width: 640px;
}

.portal-cta-content h3 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  line-height: 1.2;
}

.portal-cta-content p {
  font-size: 16px;
  color: #cbd5e1;
  line-height: 1.5;
}

.portal-cta-action {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.portal-cta-action .btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 700;
  color: #09261a;
  background: #10b981;
  border-radius: var(--radius-full);
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  transition: all 0.2s ease;
}

.portal-cta-action .btn-cta:hover {
  background: #34d399;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}

/* ==========================================================================
 * Peu de Pàgina (Modo Claro)
 * ========================================================================== */
.portal-footer {
  background: #ffffff;
  border-top: 1px solid rgba(15, 81, 50, 0.1);
  padding: 40px 24px;
}

.portal-footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #64748b;
}

.portal-footer-links {
  display: flex;
  gap: 20px;
}

.portal-footer-links span {
  color: #64748b;
}

.portal-footer-links a {
  color: #475569;
  text-decoration: none;
  transition: color 0.2s;
}

.portal-footer-links a:hover {
  color: #0f5132;
}

/* ==========================================================================
 * Responsive
 * ========================================================================== */
@media (max-width: 768px) {
  .portal-hero h2 {
    font-size: 32px;
  }
  .portal-grid {
    grid-template-columns: 1fr;
  }
  .portal-cta-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 32px 24px;
  }
  .portal-stat-item:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 12px;
  }
}


/* Mòbil: la graella de 360 px mínims, la cerca de 280 px i la barra sense regla pròpia desbordaven a 390 px. */
.eu-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }
.portal-search-box, .portal-search-box input { min-width: 0 !important; }
@media (max-width: 640px) {
  .portal-navbar { flex-wrap: wrap; gap: 10px; padding-left: 14px; padding-right: 14px; }
  .portal-navbar > * { min-width: 0; }
  .portal-controls { flex-direction: column; align-items: stretch; }
  .portal-search-box { width: 100%; }
  .portal-filter-dropdowns { width: 100%; }
  .portal-select { flex: 1 1 140px; min-width: 0; }
  .portal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  h1, .portal-hero h1 { overflow-wrap: anywhere; }

  /* Capçalera en dues files: a 360 px els tres botons (amb «Accés Clients / Entitats») no hi cabien al costat
   * de la marca, el darrer sortia 6 px de la pantalla i la pàgina es desplaçava de costat. */
  .portal-navbar { position: relative; padding-top: 10px; padding-bottom: 10px; }
  .portal-brand { flex: 1 1 100%; gap: 10px; }
  .portal-brand-text span { font-size: 10px; letter-spacing: 0.03em; }
  .portal-brand-kawaru { margin-left: auto !important; }
  .portal-nav-actions { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
  .portal-nav-actions > * { flex: 1 1 auto; justify-content: center; white-space: nowrap; padding: 8px 12px; font-size: 13px; line-height: 1.2; }
  #btn-portal-open-auth > span[aria-hidden="true"] { display: none; }
  .portal-hero { padding: 36px 16px 28px; }
  .portal-grid, .portal-cta { padding-left: 16px; padding-right: 16px; }
  .portal-grid { gap: 20px; }
  /* Capçalera de la fitxa amb alçada fixa: «Madrid (Centre - Retiro)» en dues línies tapava la línia de l'INE. */
  .portal-card-header { height: auto; min-height: 160px; gap: 12px; }
  .portal-card-title-block h3 { font-size: 23px; }
  .portal-cta-card { padding: 28px 20px; gap: 20px; }
  .portal-cta-content h3 { font-size: 26px; }
  .portal-cta-action, .portal-cta-action .btn-cta { width: 100%; justify-content: center; }
}
@media (max-width: 380px) {
  .portal-brand-kawaru { display: none; }
}

/* Teclat: focus visible a enllaços, botons i controls (abans només hi havia estils :hover). */
.portal-brand:focus-visible,
.btn-secondary:focus-visible,
.btn-primary:focus-visible,
.portal-card-btn:focus-visible,
.portal-cta-action .btn-cta:focus-visible,
.portal-select:focus-visible {
  outline: 3px solid #10b981;
  outline-offset: 2px;
}
.portal-cta-action .btn-cta:focus-visible { outline-color: #ffffff; }

@media (prefers-reduced-motion: reduce) {
  .portal-badge-dot { animation: none; }
  .btn-secondary, .btn-primary, .portal-card, .portal-card-btn, .portal-cta-action .btn-cta { transition: none; }
  .btn-secondary:hover, .btn-primary:hover, .portal-card:hover, .portal-card:hover .portal-card-btn, .portal-cta-action .btn-cta:hover { transform: none; }
}

