/*
 * Mobiele interface voor Lightning Front.
 *
 * Houd nieuwe mobiele tekst op minimaal 13px en interactieve elementen op
 * minimaal 44px. Gebruik bestaande .ui-surface/.ui-card/.ui-field-klassen,
 * zodat nieuwe onderdelen ook het centrale kleurenthema blijven volgen.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
label,
select,
input {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ui-accent) 72%, white);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  button,
  select,
  summary,
  label:has(input) {
    min-height: 44px;
  }
}

@media (max-width: 768px) {
  :root {
    --mobile-gutter: 10px;
    --mobile-top: max(10px, env(safe-area-inset-top));
    --mobile-bottom: max(10px, env(safe-area-inset-bottom));
    --mobile-header-height: 64px;
    --mobile-timeline-height: 64px;
  }

  body {
    font-size: 18px;
  }

  .topbar {
    top: var(--mobile-top);
    left: var(--mobile-gutter);
    right: var(--mobile-gutter);
    height: var(--mobile-header-height);
    padding: 0 10px 0 12px;
    border-radius: 16px;
  }

  .brand {
    min-width: 0;
    gap: 9px;
  }

  .brand-bolt {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 11px;
    font-size: 27px;
  }

  .brand strong {
    overflow: hidden;
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand small {
    display: none;
  }

  .connection {
    flex: none;
    gap: 4px;
  }

  .connection > span:not(.pulse) {
    display: none;
  }

  .pulse {
    width: 10px;
    height: 10px;
    margin-right: 2px;
  }

  .header-button,
  .station-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin-left: 2px;
    padding: 0;
    place-content: center;
    border-radius: 12px;
    font-size: 19px;
  }

  .station-button {
    display: grid;
    font-size: 0;
  }

  .station-button .station-led {
    width: 10px;
    height: 10px;
    margin: auto;
  }

  .kicker {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.35;
    letter-spacing: .12em;
  }

  .collapse-button,
  .round-button,
  .detail-close,
  .close-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
  }

  .stats {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 10px);
    left: var(--mobile-gutter);
    width: min(310px, calc(100% - 78px));
    padding: 17px;
    border-radius: 16px;
  }

  .stats.collapsed {
    width: min(240px, calc(100% - 78px));
    padding: 12px 14px;
  }

  .panel-summary {
    font-size: 14px;
  }

  .panel-summary strong {
    font-size: 16px;
  }

  .stat-main strong {
    font-size: 46px;
  }

  .stat-main span,
  .stat-grid span,
  .source-row span {
    font-size: 14px;
  }

  .stat-grid strong,
  .source-row strong {
    font-size: 15px;
  }

  .stats .source-row {
    display: none;
  }

  .refresh-button,
  .layers-button {
    right: var(--mobile-gutter);
    width: 48px;
    height: 48px;
    min-height: 48px;
    justify-content: center;
    padding: 0;
    border-radius: 14px;
    font-size: 19px;
  }

  .refresh-button {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 10px);
  }

  .layers-button {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 66px);
  }

  .refresh-button span:last-child,
  .layers-button span:last-child {
    display: none;
  }

  .layers-panel {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 122px);
    right: var(--mobile-gutter);
    bottom: calc(var(--mobile-bottom) + var(--mobile-timeline-height) + 10px);
    left: var(--mobile-gutter);
    width: auto;
    max-height: none;
    padding: 18px;
    overflow: auto;
    border-radius: 20px;
  }

  .layers-panel .surface-titlebar {
    top: -18px;
    margin: -18px -18px 7px;
    padding: 18px;
    border-bottom: 1px solid var(--obs-border);
  }

  .layers-panel .surface-titlebar > div > strong {
    font-size: 16px;
  }

  .layers-panel label {
    min-height: 62px;
    padding: 12px 2px;
  }

  .layers-panel label span strong {
    font-size: 16px;
    line-height: 1.3;
  }

  .layers-panel label span small {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.4;
  }

  .layers-panel input,
  .detail-network-toggle input {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
  }

  .timeline,
  .timeline.collapsed {
    right: var(--mobile-gutter);
    bottom: var(--mobile-bottom);
    left: var(--mobile-gutter);
    width: auto;
    padding: 14px 15px;
    border-radius: 17px;
  }

  .timeline:not(.collapsed) {
    max-height: min(42dvh, 330px);
    overflow: auto;
  }

  .timeline-heading {
    min-height: 40px;
  }

  .timeline-heading strong {
    font-size: 17px;
  }

  .timeline-mode button {
    min-height: 40px;
    font-size: 14px;
  }

  .playback-control span {
    font-size: 15px;
  }

  .playback-control small,
  .playback-sources span,
  .range-labels,
  .legend {
    font-size: 13px;
  }

  input[type="range"] {
    min-height: 28px;
    margin: 14px 0 4px;
  }

  .legend {
    flex-wrap: wrap;
    gap: 9px 14px;
    margin-top: 12px;
    padding-top: 12px;
  }

  .dot {
    width: 9px;
    height: 9px;
  }

  .detail-panel,
  .detector-panel,
  .weather-context,
  .storm-legend {
    top: auto;
    right: var(--mobile-gutter);
    bottom: calc(var(--mobile-bottom) + var(--mobile-timeline-height) + 10px);
    left: var(--mobile-gutter);
    width: auto;
    max-height: min(62dvh, 590px);
    padding: 21px;
    overflow: auto;
    border-radius: 20px;
  }

  .detail-close {
    top: 5px;
    right: 6px;
    font-size: 29px;
  }

  .detail-panel h2,
  .detector-title h2 {
    font-size: 22px;
  }

  .detail-loading,
  .weather-loading {
    font-size: 15px;
    line-height: 1.5;
  }

  .detail-primary strong {
    font-size: 38px;
  }

  .detail-primary span,
  .detail-panel dt {
    font-size: 13px;
  }

  .detail-panel dd {
    font-size: 15px;
  }

  .detail-network-toggle {
    min-height: 64px;
    padding: 12px;
  }

  .detail-network-toggle strong {
    font-size: 15px;
  }

  .detail-network-toggle small,
  .detail-network-legend,
  .detail-station-list strong,
  .detail-station-list span,
  .detail-own-station,
  .detail-note {
    font-size: 13px;
    line-height: 1.5;
  }

  .detail-station-list span {
    max-height: 50px;
  }

  .detector-title p {
    font-size: 14px;
  }

  .detector-grid span,
  .detector-activity span,
  .detector-ranges span {
    font-size: 13px;
  }

  .detector-grid strong,
  .detector-activity strong {
    font-size: 14px;
  }

  .detector-ranges strong {
    font-size: 19px;
  }

  .detector-ranges small {
    font-size: 13px;
  }

  .storm-legend strong,
  .weather-location strong,
  .projection-distance strong {
    font-size: 17px;
  }

  .storm-legend p,
  .storm-legend small,
  .storm-legend-meta,
  .weather-location small,
  .weather-grid article > span,
  .weather-grid small,
  .projection-distance span,
  .projection-distance small,
  .weather-disclaimer {
    font-size: 13px;
    line-height: 1.5;
  }

  .storm-actions button {
    min-height: 46px;
    font-size: 14px;
  }

  .active-regions summary {
    min-height: 48px;
    font-size: 15px;
  }

  .active-regions summary span,
  .active-region-button span,
  .activity-totals span {
    font-size: 13px;
    line-height: 1.45;
  }

  .active-region-button {
    min-height: 58px;
    padding: 11px;
  }

  .active-region-button strong,
  .activity-totals strong {
    font-size: 15px;
  }

  .extreme-summary {
    padding: 13px;
  }

  .extreme-summary > div:first-child strong,
  #extreme-list strong {
    font-size: 15px;
  }

  .extreme-summary > small,
  #extreme-list span {
    font-size: 13px;
    line-height: 1.45;
  }

  .weather-grid strong {
    font-size: 18px;
  }

  .station-panel {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 8px);
    right: var(--mobile-gutter);
    bottom: var(--mobile-bottom);
    left: var(--mobile-gutter);
    width: auto;
    padding: 20px;
    border-radius: 21px;
    overscroll-behavior: contain;
  }

  .station-panel-head h2 {
    font-size: 27px;
  }

  .station-loading {
    font-size: 13px;
  }

  .station-hero {
    gap: 10px;
    margin-top: 18px;
    padding: 15px;
  }

  .station-status-dot {
    width: 13px;
    height: 13px;
  }

  .station-hero strong {
    font-size: 18px;
  }

  .station-hero small,
  .station-meta span,
  .local-health-grid span,
  .local-health-grid small,
  .gateway-privacy,
  .range-cards article > span,
  .range-cards article > small,
  .privacy-note,
  .legacy-intro,
  .legacy-periods small,
  .legacy-event small,
  .legacy-note {
    font-size: 13px;
    line-height: 1.5;
  }

  .signal-count strong {
    font-size: 27px;
  }

  .station-meta,
  .range-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .station-meta div,
  .range-cards article {
    padding: 11px 9px;
  }

  .station-meta strong {
    font-size: 14px;
  }

  .local-health {
    padding: 15px;
  }

  .local-health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .local-health-grid article {
    padding: 12px;
  }

  .local-health-grid strong {
    font-size: 16px;
  }

  .panel-heading {
    align-items: flex-end;
    gap: 12px;
  }

  .panel-heading h3 {
    font-size: 20px;
  }

  .panel-heading > span {
    font-size: 13px;
  }

  .range-cards article > strong {
    font-size: 24px;
  }

  .meter {
    height: 5px;
  }

  .station-history-section select {
    min-width: 110px;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 15px;
  }

  .station-summary-grid {
    gap: 7px;
  }

  .station-summary-grid article {
    padding: 11px 9px;
  }

  .station-summary-grid span,
  .station-summary-grid small {
    font-size: 13px;
    line-height: 1.35;
  }

  .station-summary-grid strong {
    font-size: 18px;
  }

  .history-chart-wrap {
    padding: 10px 6px;
  }

  .history-chart-wrap p {
    font-size: 14px;
  }

  .legacy-archive summary {
    min-height: 52px;
    align-items: center;
    font-size: 15px;
  }

  .legacy-archive summary span {
    font-size: 13px;
  }

  .legacy-periods {
    grid-template-columns: 1fr;
  }

  .legacy-periods span,
  .legacy-event span,
  .legacy-periods dt,
  .legacy-periods dd {
    font-size: 13px;
  }

  .legacy-periods strong,
  .legacy-event strong {
    font-size: 20px;
  }

  .settings-dialog,
  .location-search-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - var(--mobile-top) - var(--mobile-bottom));
    border-radius: 22px;
  }

  .settings-dialog form,
  .location-search-dialog form {
    padding: 20px;
  }

  .settings-header {
    margin-bottom: 20px;
  }

  .settings-header h2 {
    font-size: 26px;
  }

  .settings-dialog legend,
  .choice-card strong,
  .setting-row strong {
    font-size: 16px;
  }

  .choice-card small,
  .setting-row small {
    font-size: 14px;
    line-height: 1.45;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .choice-card {
    min-height: 72px;
    padding: 12px;
  }

  .map-swatch {
    width: 64px;
    height: 48px;
  }

  .setting-row {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 17px 0;
  }

  .setting-row select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 17px;
  }

  .switch-row {
    align-items: center;
    flex-direction: row;
  }

  .switch-row input {
    width: 46px;
    height: 26px;
    flex: 0 0 46px;
  }

  .settings-actions button,
  .install-row button {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
  }

  .search-intro,
  .location-search-status,
  .location-search-results span,
  .location-search-dialog .weather-disclaimer {
    font-size: 14px;
    line-height: 1.5;
  }

  .location-search-field {
    grid-template-columns: 1fr;
  }

  .location-search-field input,
  .location-search-field button {
    min-height: 48px;
    padding: 11px 13px;
    font-size: 16px;
  }

  .location-search-results button {
    min-height: 58px;
    padding: 13px;
  }

  .location-search-results strong {
    font-size: 16px;
  }

  .toast {
    bottom: calc(var(--mobile-bottom) + var(--mobile-timeline-height) + 12px);
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 13px 16px;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
  }

  .leaflet-bottom.leaflet-right {
    bottom: calc(var(--mobile-bottom) + var(--mobile-timeline-height) + 8px);
  }

  .leaflet-control-zoom a {
    width: 42px !important;
    height: 42px !important;
    font-size: 24px !important;
    line-height: 42px !important;
  }

  .leaflet-control-attribution {
    max-width: min(72vw, 310px);
    font-size: 9px !important;
  }
}

@media (max-width: 520px) {
  .station-meta,
  .range-cards {
    grid-template-columns: 1fr;
  }

  .station-meta div,
  .range-cards article {
    padding: 14px;
  }

  .station-meta span,
  .range-cards article > span {
    font-size: 13px;
  }

  .station-meta strong {
    font-size: 15px;
  }

  .station-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .topbar {
    padding-right: 8px;
  }

  .brand strong {
    max-width: 112px;
    font-size: 15px;
  }

  .station-button {
    display: none;
  }

  .station-hero {
    grid-template-columns: auto 1fr;
  }

  .signal-count {
    grid-column: 2;
    text-align: left;
  }

  .local-health-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    flex-direction: column-reverse;
  }

  .settings-actions button {
    width: 100%;
  }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  :root {
    --mobile-header-height: 54px;
    --mobile-timeline-height: 56px;
  }

  .topbar {
    height: var(--mobile-header-height);
  }

  .brand-bolt {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .station-panel {
    top: var(--mobile-top);
    left: calc(50% + 4px);
  }

  .layers-panel,
  .detail-panel,
  .detector-panel,
  .weather-context,
  .storm-legend {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 8px);
    right: var(--mobile-gutter);
    bottom: var(--mobile-bottom);
    left: 46%;
    max-height: none;
  }

  .timeline:not(.collapsed) {
    max-height: 58dvh;
  }
}
