/* Mobile presentation only. The approved desktop rules and data stay in their B files. */
@media (max-width: 1040px) {
  body:has(.hero-b):not(.dialog-open) {
    overflow-x: visible;
  }

  .site-header-b .menu-toggle {
    width: 44px;
    height: 44px;
  }

  .site-header-b .header-navigation {
    max-height: calc(100dvh - 66px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .site-header-b .primary-nav {
    gap: 0;
  }

  .hero-b .globe-canvas {
    /* Vertical swipes scroll the page; horizontal drags still rotate the globe. */
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: auto;
  }

  .site-header-b :is(a, button):focus-visible,
  .hero-b :is(a, button):focus-visible,
  .login-dialog :is(a, button):focus-visible {
    outline: 3px solid var(--amber);
    outline-offset: -3px;
  }

  .login-dialog {
    max-height: calc(100dvh - 28px);
    overscroll-behavior: contain;
    scroll-padding-block: 80px 20px;
  }

  .login-dialog .dialog-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--paper);
  }

  .login-dialog .dialog-close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
  }

  .login-dialog .admin-entry {
    min-height: 44px;
    font-size: 16px;
  }

  .login-dialog .dialog-body > p:not(.eyebrow) {
    font-size: 16px;
  }
}

@media (max-width: 1023px) {
  #live-data.history-b .timeline-controls {
    grid-template-columns: 1fr;
  }

  #live-data.history-b .timeline-control-group:last-child {
    grid-column: auto;
    max-width: none;
  }

  #live-data.history-b .timeline-controls button {
    font-size: 14px;
  }

  #live-data.history-b .chart-column {
    display: grid;
    padding-bottom: 24px;
  }

  #live-data.history-b .chart-scale {
    bottom: auto;
    height: 250px;
    font-size: 12px;
  }

  #live-data.history-b .chart-axis {
    position: relative;
    display: block;
    grid-row: 2;
    inset: auto;
    height: 36px;
    margin-top: 16px;
    font-size: 12px;
    line-height: 1.4;
  }

  #live-data.history-b .chart-axis > span {
    width: 48px;
    white-space: normal;
    text-align: center;
  }

  #live-data.history-b .chart-axis > .is-start {
    text-align: left;
  }

  #live-data.history-b .chart-axis > .is-end {
    text-align: right;
  }

  #live-data.history-b .chart-tooltip {
    position: static;
    grid-row: 3;
    min-width: 0;
    max-width: 100%;
    margin-top: 16px;
    transform: none;
    overflow-wrap: anywhere;
  }

  #live-data.history-b .chart-tooltip :is(span, small) {
    font-size: 13px;
    line-height: 1.5;
  }

  #live-data.history-b .chart-tooltip strong {
    font-size: 16px;
    line-height: 1.5;
  }

  #live-data.history-b :is(.monitor-footer, .chart-scale-explanation) {
    font-size: 14px;
  }
}

@media (max-width: 700px) {
  #technology.technology-b .observation-step {
    grid-template-rows: 44px 1fr auto;
    min-height: 0;
    gap: 14px;
  }

  #technology.technology-b .observation-step-number,
  #technology.technology-b .observation-step.is-active .observation-step-number {
    width: 44px;
    height: 44px;
  }

  #technology.technology-b .observation-step-copy small {
    font-size: 16px;
  }

  #technology.technology-b
    :is(
      .observation-step-output,
      .observation-stage-topline > span:last-child,
      .observation-stage-facts span
    ) {
    font-size: 13px;
  }

  #technology.technology-b .observation-stage {
    min-height: 0;
  }

  #technology.technology-b .observation-stage-visual {
    width: min(100%, 160px);
  }

  #technology [data-final-families] :is(.sensor-kicker, .sensor-status, .sensor-scale-note) {
    font-size: 13px;
  }

  #technology [data-final-families] .sensor-metadata :is(dt, dd) {
    font-size: 14px;
  }

  #technology [data-final-families] .sensor-distribution > div {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    font-size: 14px;
  }

  #technology [data-final-families] .sensor-distribution > div > span:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #technology [data-final-families] .sensor-distribution strong {
    grid-column: 2;
    grid-row: 1;
    font-size: 14px;
  }

  #about.providence-b .providence-landscape small {
    font-size: 14px;
  }

  #about.providence-b .text-link {
    min-height: 44px;
  }

  [data-final-footer] nav a,
  [data-final-footer] .footer-bottom button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

@media (max-width: 600px) {
  #snapshot .metric-value {
    font-size: clamp(42px, 14vw, 56px);
  }

  #snapshot .snapshot-focus-value {
    font-size: clamp(48px, 15vw, 64px);
  }

  #technology [data-final-families] .sensor-reading strong {
    font-size: clamp(38px, 12vw, 54px);
  }

  .hero-b h1 {
    font-size: clamp(84px, 24vw, 136px);
  }

  .hero-b .globe-stage {
    inset: 0 12px 48px;
  }

  .hero-b :is(.globe-map-mode, .globe-rotation-toggle) {
    font-size: 12px;
  }

  .hero-b .network-sources {
    flex-wrap: wrap;
    gap: 4px 16px;
  }

  .hero-b .network-row > span {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .hero-b
    :is(
      .network-row strong,
      .network-row small,
      .network-sources button,
      .station-popover-label,
      .station-location,
      .station-measurement,
      .station-popover-footer small,
      .station-members,
      .station-meta dt,
      .station-meta dd
    ) {
    font-size: 14px;
  }

  .hero-b .station-heading-row {
    padding-right: 32px;
  }

  #snapshot
    :is(.metric-change, .snapshot-focus-meta dt, .snapshot-focus-topline, .snapshot-focus-kicker) {
    font-size: 13px;
    line-height: 1.5;
  }

  #live-data.history-b :is(.timeline-series, .timeline-range, .timeline-scaling) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  #live-data.history-b .timeline-series button:first-child,
  #live-data.history-b .timeline-scaling button:last-child {
    grid-column: 1 / -1;
  }

  #live-data.history-b .chart-scale {
    height: 230px;
  }

  .login-dialog .dialog-body {
    padding: 24px 20px;
  }
}

@media (max-width: 360px) {
  .hero-b .globe-viewport {
    height: 430px;
  }

  .hero-b .globe-stage {
    inset: 0 12px 98px;
  }

  .hero-b .globe-map-modes {
    bottom: 48px;
  }

  .hero-b .globe-rotation-toggle {
    top: 382px;
  }

  #technology [data-final-families] .sensor-selector {
    grid-template-columns: 1fr;
  }

  #technology [data-final-families] .sensor-selector button {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 64px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #technology [data-final-families] .sensor-selector button > strong {
    margin-left: 0;
  }

  #technology [data-final-families] .sensor-selector button > span {
    font-size: 14px;
  }

  #technology.technology-b .observation-stage-facts {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  #technology.technology-b .observation-stage-facts > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 0 0;
  }

  [data-final-footer] .footer-contact a {
    font-size: 25px;
  }
}

/* Only the mobile Snapshot presentation changes; its original controls and data nodes are reused. */
@media (max-width: 1023px) {
  #snapshot [data-layout="accordion"] {
    gap: 0;
    overflow-anchor: none;
  }

  #snapshot [data-layout="accordion"] .metric-grid {
    display: block;
  }

  #snapshot .snapshot-mobile-item {
    min-width: 0;
    border-bottom: 1px solid var(--line);
  }

  #snapshot .snapshot-mobile-item:first-child {
    border-top: 1px solid var(--line);
  }

  #snapshot .snapshot-mobile-item > .metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-content: center;
    align-items: center;
    gap: 6px 16px;
    width: 100%;
    min-height: 104px;
    border: 0;
    border-radius: 0;
    padding: 16px 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
  }

  #snapshot .snapshot-mobile-item .metric-label {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
  }

  #snapshot .snapshot-mobile-item .metric-value {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    font-family: var(--font-body);
    font-size: 32px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.035em;
  }

  #snapshot .snapshot-mobile-item > .metric.is-active {
    background: transparent;
    color: var(--teal-dark);
    box-shadow: none;
  }

  #snapshot .snapshot-mobile-item > .metric.is-active .metric-label {
    text-decoration: underline;
    text-underline-offset: 4px;
  }

  #snapshot .snapshot-mobile-item > .metric:focus-visible {
    outline-offset: -3px;
  }

  #snapshot .snapshot-toggle-sign {
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
  }

  #snapshot .snapshot-mobile-panel {
    min-width: 0;
  }

  #snapshot .snapshot-mobile-panel:not([hidden]) {
    animation: snapshot-mobile-open 120ms ease-out;
  }

  #snapshot .snapshot-mobile-summary {
    padding: 16px 20px;
  }

  #snapshot .snapshot-mobile-summary :is(.metric-index, .snapshot-metric-icon, .metric-value) {
    display: none;
  }

  #snapshot .snapshot-mobile-summary .metric-change {
    margin: 0;
    border: 0;
    padding: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    margin-bottom: 16px;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-number,
  #snapshot .snapshot-mobile-panel .snapshot-focus-copy {
    padding: 20px;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-number {
    border-right: 0;
    border-bottom: 4px solid var(--amber);
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-topline {
    gap: 10px;
    letter-spacing: 0.13em;
    line-height: 1.5;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-number .snapshot-focus-topline {
    margin-bottom: 16px;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-value {
    display: none;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-exact {
    font-size: 16px;
    line-height: 1.5;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus h3 {
    font-size: 30px;
    line-height: 1.15;
  }

  #snapshot .snapshot-mobile-panel .snapshot-focus-meta {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
}

@keyframes snapshot-mobile-open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  #snapshot .snapshot-mobile-panel:not([hidden]) {
    animation: none;
  }
}

/* History refinement: compact controls below desktop, with the original chart intact. */
@media (max-width: 1023px) {
  #live-data.history-b {
    padding-top: 40px;
    padding-bottom: 48px;
  }

  #live-data.history-b .live-heading {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 0;
  }

  #live-data.history-b .live-heading .eyebrow {
    margin-bottom: 12px;
  }

  #live-data.history-b .live-heading-side > p {
    line-height: 1.5;
  }

  #live-data.history-b .monitor-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 20px;
  }

  #live-data.history-b .monitor-kpi-card {
    padding: 24px;
  }

  #live-data.history-b .monitor-reading {
    padding-bottom: 56px;
  }

  #live-data.history-b .monitor-ocean {
    height: 44px;
  }

  #live-data.history-b [data-throughput-date] {
    margin-top: 16px;
    font-size: 16px;
  }

  #live-data.history-b [data-throughput] {
    margin-top: 12px;
    font-size: clamp(36px, 16cqi, 48px);
  }

  #live-data.history-b .monitor-provenance {
    margin-top: 20px;
  }

  #live-data.history-b .history-chart-panel {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #live-data.history-b .monitor-header {
    padding: 0;
  }

  #live-data.history-b .timeline-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  #live-data.history-b .timeline-control-group {
    border: 0;
    padding-left: 0;
  }

  #live-data.history-b :is(.timeline-series, .timeline-range, .timeline-scaling) {
    display: grid;
    gap: 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
  }

  #live-data.history-b .timeline-series {
    grid-template-columns: minmax(max-content, 1.2fr) repeat(2, minmax(0, 1fr));
  }

  #live-data.history-b .timeline-range {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #live-data.history-b .timeline-scaling {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #live-data.history-b .timeline-series button:first-child,
  #live-data.history-b .timeline-scaling button:last-child {
    grid-column: auto;
  }

  #live-data.history-b .timeline-controls button {
    min-height: 44px;
    padding: 8px 4px;
    font-size: 14px;
    line-height: 1.35;
  }

  #live-data.history-b .timeline-scale-toggle {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-inline: 0;
    font-weight: 500;
    text-align: left;
  }

  #live-data.history-b .timeline-scale-toggle > span:first-child {
    text-decoration: underline;
    text-underline-offset: 4px;
  }

  #live-data.history-b .timeline-control-group.timeline-scale-controls {
    grid-column: 1 / -1;
    max-width: none;
  }

  #live-data.history-b .timeline-scale-controls > span {
    display: none;
  }

  #live-data.history-b .chart-column:has(.timeline-empty:not([hidden])) {
    padding: 16px 0;
  }

  #live-data.history-b .timeline-empty {
    position: static;
    border: 0;
    padding: 16px 0;
    text-align: left;
  }

  #live-data.history-b .timeline-empty span {
    font-size: 14px;
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #live-data.history-b .timeline-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Technology process only: retain the buttons, descriptions and selection events. */
@media (max-width: 1023px) {
  #technology.technology-b .observation-flow-workspace {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 16px;
  }

  #technology.technology-b .observation-flow-steps {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    gap: 0;
    overflow: visible;
    padding: 0;
  }

  #technology.technology-b .observation-step,
  #technology.technology-b .observation-step:is(:hover, :focus-visible, .is-active) {
    grid-template-columns: 2ch minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    gap: 3px 14px;
    min-height: 80px;
    border: 0;
    border-bottom: 1px solid rgba(143, 195, 208, 0.26);
    border-radius: 0;
    background: transparent;
    padding: 5px 0;
    box-shadow: none;
  }

  #technology.technology-b .observation-step-number,
  #technology.technology-b .observation-step.is-active .observation-step-number {
    display: block;
    grid-column: 1;
    grid-row: 1 / span 2;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--teal-light, #6de2d3);
    font-size: 16px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    line-height: 1.6;
  }

  #technology.technology-b .observation-step.is-active .observation-step-number {
    font-weight: 700;
  }

  #technology.technology-b .observation-step-copy {
    grid-column: 2;
    grid-row: 1;
    gap: 3px;
  }

  #technology.technology-b .observation-step-copy strong {
    color: var(--paper);
    font-size: 23px;
    line-height: 1.1;
  }

  #technology.technology-b .observation-step.is-active .observation-step-copy strong {
    color: var(--teal-light, #6de2d3);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
  }

  #technology.technology-b .observation-step-copy small {
    font-size: 14px;
    line-height: 1.4;
  }

  #technology.technology-b .observation-step-output {
    grid-column: 2;
    grid-row: 2;
    padding: 0;
    font-size: 12px;
    line-height: 1.4;
  }

  #technology.technology-b .observation-step-output::before {
    content: none;
  }

  #technology.technology-b .observation-stage {
    min-height: 0;
    row-gap: 16px;
    padding-block: 20px;
  }

  #technology.technology-b .observation-stage-copy p {
    margin-top: 12px;
  }

  #technology.technology-b .observation-stage-facts {
    padding-top: 16px;
  }
}
