/* =========================================================
   RESPONSIVE OVERRIDES
   Desktopul rămâne controlat de fișierele principale CSS.
   Aici sunt doar reguli pentru tabletă și mobil.
   ========================================================= */

@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }

  .wrap {
    width: min(100% - 32px, var(--wrap, 1120px));
  }

  /* ---------- HEADER ---------- */
  .hero {
    padding-top: 20px;
  }

  .hero-logo {
    position: static;
    display: block;
    width: 280px;
    max-width: min(58vw, 280px);
    margin: -4px 0 18px auto;
  }

  h1,
  .hero-title {
    max-width: 100%;
    font-size: clamp(32px, 8vw, 44px);
    line-height: 1.05;
  }

  .hero-title-main {
    white-space: normal;
  }

  .hero-title-sub {
    display: block;
    margin-top: 4px;
  }

  .hero p.lede {
    max-width: 100%;
    font-size: 15px;
  }

  .nat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nat-cell {
    border-bottom: 1px solid rgba(255,255,255,.16);
  }

  /* ---------- NAV ---------- */
  nav .wrap {
    width: 100%;
    padding: 0 16px;
    gap: 0;
  }

  nav a {
    padding: 14px 12px;
  }

  /* ---------- STRUCTURĂ GENERALĂ ---------- */
  .sec-head h2 {
    font-size: clamp(26px, 6vw, 36px);
  }

  .card {
    min-width: 0;
  }

  /* ---------- COMPONENTA 1: PROFIL ORAȘ ---------- */
  .city-profile-hero {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .city-profile-hero::after {
    width: 72%;
    opacity: .18;
  }

  .city-badges {
    justify-content: flex-start;
    min-width: 0;
  }

  .city-bar {
    align-items: stretch;
  }

  .city-bar select {
    width: 100%;
    min-width: 0;
  }

  #profil .profile {
    grid-template-columns: 1fr !important;
  }

  #profil .profile > .card,
  #scoreCard,
  #filieraCard,
  #distCard,
  #peerCard,
  #evoCard,
  #concCard,
  #diagCard,
  #interpCard {
    grid-column: 1 / -1 !important;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filiera-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diag-wrap {
    grid-template-columns: 1fr;
  }

  .conc-row {
    grid-template-columns: minmax(96px, 120px) minmax(0, 1fr) 44px;
  }

  /* Graficele/cardurile de grafic rămân unul sub altul pe mobil.
     Pentru grafice dense, păstrăm informația prin scroll orizontal în interiorul cardului. */
  #distChart,
  #evoChart,
  #diagScores,
  #concBars {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #distChart svg,
  #evoChart svg,
  #diagScores svg {
    max-width: none;
  }

  .peer-table,
  .card table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .peer-table th,
  .peer-table td,
  .card table th,
  .card table td {
    white-space: nowrap;
  }

  /* ---------- COMPONENTA 2: TOPURI ---------- */
  .top-dashboard {
    grid-template-columns: 1fr !important;
  }

  .top-main,
  .top-rank-card,
  .top-question-card,
  .top-info-card {
    min-width: 0;
  }

  .top-scope-tabs {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-info-col {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-metric-nav,
  .top-indicator-strip .top-metric-nav {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .top-metric-btn,
  .top-indicator-strip .top-metric-btn {
    flex: 0 0 170px;
  }

  .top-filter-row {
    gap: 10px;
  }

  .top-filter-field,
  .top-filter-field.wide {
    width: 100%;
    justify-content: space-between;
  }

  .top-filter-field select,
  .top-filter-field.wide select {
    min-width: 0;
    width: min(100%, 320px);
  }

  .top-rank-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .top-rank-head,
  .top-rank-row {
    min-width: 620px;
  }

  .top-rank-head.progress,
  .top-rank-row.progress {
    min-width: 680px;
  }

  .top-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  /* ---------- COMPONENTA 3: HARTĂ ---------- */
  .education-map-indicator-bar {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .map-indicator-button {
    flex: 0 0 auto;
  }

  .education-map-shell {
    grid-template-columns: 1fr !important;
  }

  .education-map-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .romania-education-map {
    min-width: 560px;
  }

  .education-map-city-card {
    position: static;
  }

  /* ---------- COMPONENTA 4: METODOLOGIE ---------- */
  .methodology-hero-card,
  .methodology-card-grid,
  .diagnostic-dimensions-grid,
  .meta-grid,
  .pot-grid {
    grid-template-columns: 1fr !important;
  }

  .case {
    position: static;
  }
}

@media (max-width: 640px) {
  .wrap {
    width: min(100% - 24px, var(--wrap, 1120px));
  }

  .kicker {
    font-size: 10px;
    letter-spacing: .16em;
  }

  .hero-logo {
    width: 220px;
    max-width: 72vw;
    margin-top: 0;
  }

  .nat-strip {
    grid-template-columns: 1fr;
  }

  .nat-cell {
    padding: 16px 0 18px;
    border-right: none;
  }

  .nat-cell .val {
    font-size: 24px;
  }

  .pilot-tag {
    max-width: 100%;
    white-space: normal;
  }

  .city-profile-hero::after {
    width: 92%;
    opacity: .12;
  }

  .city-badges,
  .city-bar {
    flex-direction: column;
  }

  .city-badge,
  .cluster-chip {
    width: fit-content;
    max-width: 100%;
  }

  .kpis,
  .filiera-grid,
  .top-scope-tabs {
    grid-template-columns: 1fr;
  }

  .conc-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .conc-row > *:last-child {
    justify-self: start;
  }

  .top-metric-btn,
  .top-indicator-strip .top-metric-btn {
    flex-basis: 155px;
  }

  .top-rank-head,
  .top-rank-row {
    min-width: 560px;
  }

  .top-rank-head.progress,
  .top-rank-row.progress {
    min-width: 600px;
  }

  .romania-education-map {
    min-width: 500px;
  }

  .methodology-final-note,
  .methodology-card,
  .methodology-hero-card,
  .methodology-deep-dive {
    padding-left: 18px;
    padding-right: 18px;
  }

  footer,
  .site-footer {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .wrap {
    width: min(100% - 20px, var(--wrap, 1120px));
  }

  h1,
  .hero-title {
    font-size: clamp(30px, 10vw, 38px);
  }

  .hero p.lede {
    font-size: 14px;
  }

  .sec-head p,
  .hint {
    font-size: 13px;
  }

  .card {
    padding-left: 16px;
    padding-right: 16px;
  }

  #distChart svg,
  #evoChart svg,
  #diagScores svg {
    min-width: 460px;
  }

  .top-metric-btn,
  .top-indicator-strip .top-metric-btn {
    flex-basis: 145px;
  }

  .romania-education-map {
    min-width: 460px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
