/* Payson Insider — mid-2000s minimal single page */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  overflow-x: hidden;
  background: #e8e8e8;
  color: #222;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: #06c;
}

a:hover,
a:focus {
  color: #039;
}

a:visited {
  color: #639;
}

:focus-visible {
  outline: 1px dotted #06c;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 100;
  padding: 6px 10px;
  background: #fff;
  color: #06c;
  font-weight: bold;
}

.skip-link:focus {
  top: 8px;
}

/* —— Header —— */
.site-header {
  position: sticky;
  top: 0;
  /* Above Leaflet panes/markers (they use high z-index inside the map). */
  z-index: 1100;
  background: #f7f7f7;
  border-bottom: 1px solid #bbb;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 14px;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 8px 10px;
  min-width: 0;
  color: #222;
  text-decoration: none;
}

.logo-name {
  font-size: 16px;
  font-weight: bold;
  white-space: nowrap;
}

.logo-tagline {
  max-width: 13rem;
  color: #555;
  font-size: 11px;
  font-weight: normal;
  line-height: 1.25;
}

.logo:visited {
  color: #222;
}

.logo:visited .logo-tagline {
  color: #555;
}

.logo:hover .logo-name,
.logo:focus .logo-name {
  color: #06c;
}

.site-header nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 2px 0;
}

.site-header nav .nav-divider {
  align-self: stretch;
  width: 1px;
  margin: 4px 6px;
  background: #bbb;
}

.site-header nav a {
  display: block;
  padding: 4px 8px;
  color: #06c;
  font-size: 12px;
  text-decoration: none;
}

.site-header nav a:visited {
  color: #06c;
}

.site-header nav a:hover,
.site-header nav a:focus {
  text-decoration: underline;
}

.nav-btn {
  display: block;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid #999;
  background: #eee;
  color: #222;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.nav-btn:hover,
.nav-btn:focus {
  background: #e0e0e0;
  color: #06c;
}

.nav-btn:active {
  background: #d4d4d4;
}

/* —— Main —— */
main {
  max-width: 900px;
  margin: 12px auto 24px;
  padding: 0 14px;
}

.section {
  margin-bottom: 18px;
  padding: 12px 14px 14px;
  background: #fff;
  border: 1px solid #bbb;
  scroll-margin-top: 48px;
}

.section h2 {
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ccc;
  color: #333;
  font-size: 15px;
  font-weight: bold;
}

.status {
  color: #666;
  font-size: 12px;
}

.credit {
  margin-top: 8px;
  font-size: 11px;
}

.credit a {
  text-decoration: none;
}

.credit a:hover,
.credit a:focus {
  text-decoration: underline;
}

/* —— Weather —— */
.weather-block {
  margin-bottom: 14px;
}

.weather-subhead {
  margin-bottom: 8px;
  color: #333;
  font-size: 13px;
  font-weight: bold;
}

.weather-legend {
  margin: -2px 0 8px;
  color: #555;
  font-size: 11px;
}

.weather-hourly,
.weather-hourly-chart {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 2px;
  background:
    linear-gradient(180deg, #eef5fb 0%, #f7fafc 55%, #ffffff 100%);
  border: 1px solid #c5d8ea;
  border-radius: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.weather-chart-svg {
  display: block;
  max-width: none;
}

.weather-chart-bg {
  fill: transparent;
}

.weather-chart-gridline {
  stroke: rgba(158, 182, 204, 0.45);
  stroke-width: 1;
}

.weather-chart-baseline {
  stroke: #9eb6cc;
  stroke-width: 1.25;
}

.weather-chart-hit {
  fill: transparent;
}

.weather-chart-now-band {
  fill: rgba(217, 119, 6, 0.14);
}

.weather-chart-temp {
  fill: #0f3d66;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-size: 9px;
  font-weight: bold;
  text-anchor: middle;
}

.weather-chart-temp.is-now {
  fill: #92400e;
}

.weather-chart-label {
  fill: #555;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-size: 9px;
  text-anchor: middle;
}

.weather-chart-label.is-now {
  fill: #92400e;
  font-weight: bold;
}

.weather-chart-bar {
  fill: #2f86c3;
}

.weather-chart-bar.is-rainy {
  fill: #1d4ed8;
}

.weather-chart-bar.is-now {
  fill: #d97706;
}

.weather-chart-bar.is-now.is-rainy {
  fill: #1d4ed8;
  stroke: #d97706;
  stroke-width: 1.25;
}

.weather-mark-sun {
  fill: #f59e0b;
  stroke: #b45309;
  stroke-width: 0.75;
}

.weather-mark-sunset {
  fill: #ea580c;
}

.weather-mark-rain {
  fill: #2563eb;
}

.weather-days {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.weather-day {
  padding: 8px;
  text-align: center;
  background: #f5f5f5;
  border: 1px solid #ddd;
}

.weather-day h3 {
  margin-bottom: 4px;
  color: #333;
  font-size: 12px;
  font-weight: bold;
}

.weather-day img {
  margin: 0 auto 4px;
  width: 48px;
  height: 48px;
}

.weather-day p {
  font-size: 11px;
  color: #444;
  line-height: 1.35;
}

.weather-temp {
  margin-bottom: 2px !important;
  color: #111 !important;
  font-size: 12px !important;
  font-weight: bold;
}

.weather-pop {
  margin-bottom: 2px !important;
  color: #2563a8 !important;
  font-size: 10px !important;
}

/* —— News —— */
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-list li {
  padding: 8px 0;
  border-bottom: 1px solid #ddd;
}

.news-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.news-headline {
  display: block;
  font-size: 13px;
  font-weight: bold;
}

.news-meta {
  display: block;
  margin-top: 2px;
  color: #666;
  font-size: 11px;
}

.news-link {
  display: block;
  margin-top: 2px;
  color: #666;
  font-size: 11px;
  word-break: break-all;
}

.news-link a {
  font-weight: normal;
  text-decoration: none;
}

.news-link a:hover,
.news-link a:focus {
  text-decoration: underline;
}

/* —— Community photos —— */
.community-photos-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.community-photo {
  margin: 0;
  padding: 6px;
  background: #f5f5f5;
  border: 1px solid #ddd;
}

.community-photo a {
  display: block;
}

.community-photo img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 1px solid #999;
  background: #222;
}

.community-photo figcaption {
  margin-top: 6px;
}

.community-photo-title {
  font-size: 12px;
  font-weight: bold;
  color: #222;
}

.community-photo-author {
  margin-top: 2px;
  color: #555;
  font-size: 11px;
}

.community-photo-caption {
  margin-top: 4px;
  color: #444;
  font-size: 11px;
  line-height: 1.35;
}

.photos-permission {
  margin-top: 10px;
  color: #666;
  font-size: 11px;
  font-style: italic;
}

@media (min-width: 560px) {
  .community-photos-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .community-photo img {
    max-height: 160px;
  }
}

/* —— Cameras —— */
.cameras-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.camera {
  padding: 6px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  text-align: center;
}

.camera h3 {
  margin-bottom: 6px;
  color: #333;
  font-size: 12px;
  font-weight: bold;
}

.camera a {
  display: block;
}

.camera img {
  width: 100%;
  border: 1px solid #999;
  background: #222;
}

/* —— Traffic map —— */
.traffic-map-frame {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  height: 300px;
  border: 1px solid #999;
  background: #eee;
  overflow: hidden;
}

#traffic-map-canvas,
.traffic-map-frame .leaflet-container {
  width: 100% !important;
  height: 100% !important;
  min-height: 100%;
  cursor: grab;
  background: #ddd;
}

.traffic-map-frame .leaflet-container.leaflet-drag-target,
.traffic-map-frame .leaflet-container:active {
  cursor: grabbing;
}

.traffic-map-frame .leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.85);
}

.traffic-map-legend {
  margin: 6px 0 0;
  color: #555;
  font-size: 11px;
}

.traffic-alerts {
  display: none;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.traffic-alerts li {
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  background: #fafafa;
  font-size: 12px;
  line-height: 1.35;
}

.traffic-alerts .traffic-alert-item {
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.traffic-alerts .traffic-alert-item:hover,
.traffic-alerts .traffic-alert-item:focus,
.traffic-alerts .traffic-alert-item.is-active {
  outline: none;
  border-color: #666;
  background: #fff8e6;
}

.traffic-alert-empty {
  color: #555;
}

.leaflet-tooltip.traffic-alert-tooltip {
  width: min(35ch, 90vw);
  max-width: min(35ch, 90vw);
  height: auto;
  padding: 8px 10px;
  border: 1px solid #777;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font: 12px/1.35 Verdana, Geneva, sans-serif;
  color: #222;
  background: #fff;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.leaflet-tooltip.traffic-alert-tooltip .leaflet-tooltip-content {
  margin: 0;
  width: auto;
  height: auto;
  white-space: normal;
}

.traffic-alert-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.traffic-alert-tooltip-detail,
.traffic-alert-tooltip-distance {
  display: block;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.traffic-alert-tooltip-distance {
  margin-top: 4px;
  color: #666;
}

.leaflet-marker-icon.is-active {
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.55));
  z-index: 1000 !important;
}

.traffic-alert-type {
  display: inline-block;
  margin-right: 4px;
  font-weight: bold;
}

.traffic-alert-type--incidents {
  color: #b00000;
}

.traffic-alert-type--closures {
  color: #8a4b00;
}

.traffic-alert-type--construction {
  color: #0b5ea8;
}

.traffic-alert-distance {
  display: inline-block;
  margin-left: 4px;
  color: #666;
  white-space: nowrap;
}

#traffic-map-status.is-error {
  color: #8a4b00;
}

/* —— Footer —— */
footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 14px 20px;
  color: #666;
  font-size: 11px;
  text-align: center;
}

/* —— Breakpoints —— */
@media (max-width: 719px) {
  .logo-tagline {
    display: none;
  }
}

@media (max-width: 559px) {
  .weather-chart-temp,
  .weather-chart-label {
    font-size: 10px;
  }

  .weather-days {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .weather-day {
    padding: 6px 4px;
  }

  .weather-day h3 {
    font-size: 11px;
  }

  .weather-day img {
    width: 40px;
    height: 40px;
  }

  .weather-temp {
    font-size: 11px !important;
  }

  .weather-pop {
    font-size: 9px !important;
  }

  .weather-day p {
    font-size: 10px;
  }

  .traffic-map-frame {
    height: 260px;
    min-height: 260px;
  }

  .site-header nav ul {
    gap: 0;
  }

  .site-header nav a,
  .nav-btn {
    padding: 6px 7px;
  }
}

@media (min-width: 560px) {
  .weather-days {
    grid-template-columns: repeat(4, 1fr);
  }

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

@media (min-width: 800px) {
  body {
    font-size: 13px;
  }

  .header-inner,
  main,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-header nav ul {
    flex-wrap: nowrap;
    align-items: center;
  }

  .site-header nav a,
  .nav-btn {
    padding: 4px 10px;
    font-size: 13px;
  }

  .weather-days {
    grid-template-columns: repeat(7, 1fr);
  }

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

  .traffic-map-frame {
    height: 440px;
  }
}

@media (min-width: 900px) {
  .cameras-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* —— Screensaver mode —— */
.screensaver-chrome {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: rgba(247, 247, 247, 0.92);
  border: 1px solid #bbb;
}

.screensaver-chrome[hidden],
.screensaver-gate[hidden] {
  display: none !important;
}

.screensaver-hint {
  color: #666;
  font-size: 11px;
}

.screensaver-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(232, 232, 232, 0.96);
  text-align: center;
}

.screensaver-gate p {
  font-size: 14px;
  color: #333;
}

.screensaver-gate .nav-btn {
  min-width: 160px;
  padding: 8px 14px;
  font-size: 13px;
}

body.screensaver-active {
  overflow: hidden;
  background: #111;
  height: 100%;
  height: 100dvh;
}

body.screensaver-active .skip-link,
body.screensaver-active .site-header,
body.screensaver-active footer,
body.screensaver-active .credit,
body.screensaver-active .status[hidden],
body.screensaver-active .traffic-map-legend {
  display: none !important;
}

body.screensaver-active main {
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100%;
}

body.screensaver-active .section {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: clamp(10px, 2vh, 20px) clamp(10px, 2vw, 24px);
  border: 0;
  background: #fff;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.screensaver-active .section.ss-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.screensaver-active .ss-stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 100%;
  box-sizing: border-box;
  transform-origin: center center;
}

body.screensaver-active .section h2 {
  flex: 0 0 auto;
  margin-bottom: clamp(6px, 1.2vh, 14px);
  padding-bottom: 4px;
  border-bottom: 1px solid #ccc;
  font-size: clamp(16px, 2.4vh, 24px);
}

body.screensaver-active .status:not([hidden]) {
  flex: 0 0 auto;
  margin-bottom: 8px;
}

/* Weather: compact, no inner scrolling */
body.screensaver-active .weather-block {
  margin-bottom: clamp(8px, 1.5vh, 16px);
  max-width: min(1200px, 100%);
  width: 100%;
}

body.screensaver-active .weather-block:last-of-type {
  margin-bottom: 0;
}

body.screensaver-active .weather-subhead {
  margin-bottom: clamp(4px, 0.8vh, 10px);
  font-size: clamp(12px, 1.8vh, 16px);
}

body.screensaver-active .weather-legend {
  margin-bottom: clamp(4px, 0.8vh, 10px);
  font-size: clamp(10px, 1.4vh, 13px);
}

body.screensaver-active .weather-hourly,
body.screensaver-active .weather-hourly-chart {
  overflow: hidden;
  max-width: 100%;
  padding: 4px 0 2px;
}

body.screensaver-active .weather-chart-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(28vh, 220px);
}

body.screensaver-active .weather-chart-temp,
body.screensaver-active .weather-chart-label {
  font-size: 11px;
}

body.screensaver-active .weather-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 10px);
  max-width: min(1200px, 100%);
  width: 100%;
  margin: 0 auto;
}

body.screensaver-active .weather-day {
  min-width: 0;
  padding: clamp(4px, 1vh, 12px) clamp(2px, 0.6vw, 8px);
}

body.screensaver-active .weather-day h3 {
  font-size: clamp(10px, 1.5vh, 13px);
}

body.screensaver-active .weather-day img {
  width: clamp(28px, 5vh, 48px);
  height: clamp(28px, 5vh, 48px);
}

body.screensaver-active .weather-day p {
  font-size: clamp(9px, 1.3vh, 12px);
}

body.screensaver-active .weather-temp {
  font-size: clamp(11px, 1.7vh, 15px) !important;
}

body.screensaver-active .weather-pop {
  font-size: clamp(9px, 1.2vh, 11px) !important;
}

/* News */
body.screensaver-active .news-list {
  max-width: min(900px, 100%);
  width: 100%;
  margin: 0 auto;
}

body.screensaver-active .news-list li {
  padding: clamp(6px, 1.2vh, 12px) 0;
}

body.screensaver-active .news-headline {
  font-size: clamp(13px, 2.2vh, 20px);
  line-height: 1.3;
}

body.screensaver-active .news-meta,
body.screensaver-active .news-link {
  margin-top: 2px;
  font-size: clamp(11px, 1.5vh, 14px);
}

body.screensaver-active .community-photos-grid {
  max-width: min(960px, 100%);
  width: 100%;
  margin: 0 auto;
  gap: clamp(8px, 1.2vh, 14px);
}

body.screensaver-active .community-photo img {
  max-height: clamp(90px, 18vh, 160px);
}

body.screensaver-active .community-photo-title {
  font-size: clamp(11px, 1.6vh, 14px);
}

body.screensaver-active .community-photo-author,
body.screensaver-active .community-photo-caption,
body.screensaver-active .photos-permission {
  font-size: clamp(10px, 1.3vh, 12px);
}

/* Cameras: fill the stage */
body.screensaver-active #cameras .ss-stage {
  width: 100%;
  height: 100%;
  max-height: 100%;
}

body.screensaver-active .cameras-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.2vh, 14px);
  width: 100%;
  max-width: min(1400px, 100%);
  margin: 0 auto;
  min-height: 0;
}

body.screensaver-active .camera {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: clamp(4px, 0.8vh, 10px);
}

body.screensaver-active .camera h3 {
  flex: 0 0 auto;
  font-size: clamp(11px, 1.6vh, 14px);
}

body.screensaver-active .camera a {
  flex: 1 1 auto;
  min-height: 0;
}

body.screensaver-active .camera img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #111;
}

/* Traffic: map fills remaining space; alerts clipped (no scroll) */
body.screensaver-active #traffic-map .ss-stage {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

body.screensaver-active .traffic-map-frame {
  flex: 1 1 auto;
  width: 100%;
  height: auto !important;
  min-height: 0;
  border-color: #666;
}

body.screensaver-active .traffic-alerts {
  display: block;
  flex: 0 0 auto;
  max-height: 18vh;
  margin-top: clamp(6px, 1vh, 12px);
  overflow: hidden;
}

body.screensaver-active .traffic-alerts li {
  font-size: clamp(10px, 1.4vh, 12px);
  padding: 4px 6px;
  margin-bottom: 4px;
}

@media (max-width: 900px) and (orientation: portrait) {
  body.screensaver-active .weather-days {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.screensaver-active .screensaver-hint {
    display: none;
  }
}

@media (max-width: 700px) {
  body.screensaver-active .weather-days {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  body.screensaver-active .weather-days {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.screensaver-active .cameras-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
}

@media (max-height: 500px) {
  body.screensaver-active .weather-legend {
    display: none;
  }

  body.screensaver-active .weather-chart-svg {
    max-height: 22vh;
  }

  body.screensaver-active .traffic-alerts {
    max-height: 14vh;
  }
}
