/* ─────────────────────────────────────────────
   FUTURS POLICIES · Mobile Layer v1
   L'app pensada primer per al polze.
───────────────────────────────────────────── */

/* ══ Sensació d'app nativa ══ */
html {
  overscroll-behavior-y: none;      /* sense rebot / pull-to-refresh */
  -webkit-tap-highlight-color: transparent;
}
body {
  overscroll-behavior-y: none;
  touch-action: pan-y;              /* elimina el retard del doble-tap-zoom */
}
button, a, .boto, .tk-btn, .tk-opt, .option-card, input, select, textarea {
  touch-action: manipulation;
}
input, textarea { user-select: text; -webkit-user-select: text; }

/* ══ Base tàctil (tots els dispositius touch) ══ */
@media (pointer: coarse) {

  /* Objectius tàctils mínims 44px (Apple HIG / Material) */
  button, .boto, .tk-btn, .pill, a.pill,
  .us-btn, .md-act, .el-fil, .us-fil,
  input[type="submit"], input[type="button"] {
    min-height: 42px;
  }
  .faq-q, .option-card, .tn-dlink, .mega-item {
    min-height: 46px;
  }

  /* Sense hover al mòbil: estats actius clars en tocar */
  .boto:active, .tk-btn:active, .pill:active {
    transform: scale(.97);
    transition-duration: .06s;
  }
  .card.card-interactive:active,
  .option-card:active {
    transform: scale(.985);
    border-color: var(--bd-cyan, rgba(56,189,248,.28));
    transition-duration: .08s;
  }

  /* El cursor-glow no té sentit en touch */
  #cursor { display: none !important; }
}

/* ══ Pantalles petites ══ */
@media (max-width: 640px) {

  /* iOS fa zoom si l'input té menys de 16px: mai més */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], input[type="tel"],
  input[type="url"], textarea, select, .input, .lg-input, .us-hours {
    font-size: 16px !important;
  }

  /* Cap element pot forçar scroll horitzontal */
  html, body { overflow-x: hidden !important; max-width: 100vw; }
  img, video, svg, canvas, iframe { max-width: 100%; }
  pre, code { white-space: pre-wrap; word-break: break-word; }

  /* Taules: scroll intern amb inèrcia, mai desbordar la pàgina */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Contenidors i seccions: respirar sense malbaratar píxels */
  .seccio { padding: 1.4rem .85rem 2.2rem; }
  .contenidor { width: 100%; padding: 0 .15rem; }
  .card { padding: 1rem .95rem; border-radius: 16px; }
  .panel-body { padding: 1rem .95rem; }

  /* Botons d'acció principals: amplada completa, fàcils de prémer */
  .boto.lg, .boto-final { width: 100%; }
  .exam-actions { flex-direction: column; gap: .6rem; }
  .exam-actions > * { width: 100%; }
  .exam-right { justify-content: stretch; }
  .exam-right > * { width: 100%; }

  /* Grups de KPIs en graella 2x2 en lloc de fila apretada */
  .kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi { min-width: 0; }
  .kpi-num { font-size: 1.45rem; }

  /* Modals i overlays: sempre dins de pantalla */
  .fp-pal { width: 94vw; top: 6vh; }
  .fp-pal-list { max-height: 52vh; }

  /* Formularis: camps apilats i còmodes */
  .row { flex-direction: column; }
  .field { gap: .35rem; }

  /* Títols: mida continguda perquè no mengin mitja pantalla */
  .titol { font-size: clamp(1.35rem, 6vw, 1.9rem); }
  .us-title, .md-title { font-size: clamp(1.4rem, 6.5vw, 1.9rem); }

  /* Footer compacte */
  .minimal-footer { padding: 1rem .8rem calc(1rem + env(safe-area-inset-bottom)); font-size: .72rem; }

  /* Toast per sobre del polze, no sota */
  .g-toast { bottom: calc(1.4rem + env(safe-area-inset-bottom)); }
}

/* ══ Pantalles molt petites ══ */
@media (max-width: 380px) {
  .seccio { padding: 1.1rem .65rem 2rem; }
  .card { padding: .85rem .8rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .pills { gap: .3rem; }
  .pill { padding: .2rem .5rem; font-size: .66rem; }
}

/* ══ Alçades reduïdes (mòbil apaïsat) ══ */
@media (max-height: 480px) and (orientation: landscape) {
  .seccio { padding-top: .8rem; padding-bottom: 1.2rem; }
  .titol { font-size: 1.25rem; margin-bottom: .3rem; }
  .subtitol { margin-bottom: .6rem; }
}

/* ══ Utilitats de centrat vertical (per a pàgines d'una sola acció) ══ */
.fp-center-page {
  min-height: calc(100dvh - var(--nav-h, 62px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

/* ══ Barra d'accions fixa inferior (per a fluxos d'examen al mòbil) ══ */
.fp-sticky-actions {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 500;
  display: flex; gap: .6rem;
  padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom));
  background: rgba(2,5,9,.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(56,189,248,.18);
}
.fp-sticky-actions .boto { flex: 1; }
body.has-sticky-actions { padding-bottom: 90px; }

@media (min-width: 641px) {
  .fp-sticky-actions { display: none; }
  body.has-sticky-actions { padding-bottom: 0; }
}
