@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/silkscreen-latin-400.woff2") format("woff2");
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/silkscreen-latin-700.woff2") format("woff2");
}

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/vt323-latin.woff2") format("woff2");
}

:root {
  --bg: #ffffff;
  --fg: #000000;
  --blue: #0000cc;
  --blue-soft: #3457b0;
  --magenta: #b300b3;
  --violet: #7a3fb3;
  --cyan: #00e5e5;
  --yellow: #ffe600;
  --green: #00a000;
  --red: #cc0000;
  --panel-border: 4px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 125%; /* pixel fonts read smaller than typical monospace fonts at the same size */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "VT323", "Courier New", ui-monospace, "Consolas", monospace;
  letter-spacing: 0.02em;
}

.site-title,
.page-number,
.panel h2,
.panel-subsection h3 {
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--fg);
}

.site-title {
  margin: 0;
  font-size: 1.75rem;
  color: var(--cyan);
  letter-spacing: 0.05em;
}

.page-nav {
  display: flex;
  gap: 0.5rem;
}

.page-number {
  color: var(--yellow);
  font-size: 1.05rem;
  border: 2px solid var(--yellow);
  padding: 0.1rem 0.45rem;
  text-decoration: none;
}

.page-number.active {
  background: var(--yellow);
  color: var(--fg);
}

.ticker-wrap {
  background: var(--fg);
  border-top: 3px solid var(--yellow);
  border-bottom: 3px solid var(--yellow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.ticker-icon {
  flex-shrink: 0;
  font-size: 1.3rem;
  line-height: 1;
}

.ticker {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  padding: 0.5rem 0;
}

#ticker-track {
  display: inline-block;
  padding-left: 100%;
  color: var(--yellow);
  font-size: 1.1rem;
  animation: ticker-scroll 22s linear infinite;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.intro {
  margin: 1rem 1rem 0;
  border: var(--panel-border) solid var(--fg);
  border-left-width: 10px;
  border-left-color: var(--magenta);
  padding: 0.85rem 1rem;
}

.intro-lead {
  margin: 0 0 0.5rem;
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.85rem;
  color: var(--magenta);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro p {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.intro p:last-child {
  margin-bottom: 0;
}

.intro a {
  color: var(--blue);
  text-decoration: underline;
}

/* Happy golden labrador, bottom-right of the P127 intro block — wiggles at the rear like a
   dog wagging its tail. (An emoji can't animate its tail alone, so the whole pup wiggles.) */
.intro-dog {
  margin-top: 0.25rem;
  text-align: right;
  line-height: 1;
}

.wag-dog {
  display: inline-block;
  font-size: 2.8rem;
  transform-origin: 75% 90%;
  /* Deliberately not gated behind prefers-reduced-motion: this little wag is the whole point
     of the block, so it plays for everyone. */
  animation: wag 0.45s ease-in-out infinite alternate;
}

@keyframes wag {
  from { transform: rotate(-12deg); }
  to { transform: rotate(12deg); }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

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

.panel {
  border: var(--panel-border) solid var(--fg);
  min-height: 140px;
}

.panel h2 {
  display: flex;
  align-items: center;
  margin: 0;
  min-height: 3.2rem;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  background: var(--cyan);
  color: var(--fg);
  border-bottom: var(--panel-border) solid var(--fg);
}

.info-icon {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0;
  border: none;
  background: none;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.info-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.4rem;
  width: 200px;
  padding: 0.5rem 0.6rem;
  background: var(--fg);
  color: var(--bg);
  font-family: "VT323", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: normal;
  border: 2px solid var(--yellow);
  z-index: 10;
}

.info-icon:hover .info-popup,
.info-icon:focus .info-popup {
  display: block;
}

.panel-body {
  padding: 0.75rem 0.6rem;
  color: var(--blue);
}

.panel-whats-on h2,
.panel-times h2 {
  background: var(--yellow);
}

.panel-traffic h2,
.panel-news h2 {
  background: var(--green);
  color: var(--bg);
}

.panel-subsection {
  border-top: 1px dashed var(--fg);
}

.panel-subsection:first-of-type {
  border-top: none;
}

.panel-subsection h3 {
  margin: 0;
  padding: 0.3rem 0.6rem 0;
  font-size: 0.9rem;
  color: var(--magenta);
}

.panel-subsection .panel-body {
  padding-top: 0.3rem;
}

/* FEATURED panel — a funky little advertising slot (e.g. Wolfe & Castle). */
.panel-featured h2 {
  background: var(--violet);
  color: var(--bg);
}

.flash-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--fg);
}

/* Stack multiple featured cards with a dashed divider between them. */
.panel-featured .panel-body {
  display: flex;
  flex-direction: column;
}

.panel-featured .flash-card + .flash-card {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--fg);
}

.flash-tag {
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--violet);
  color: var(--bg);
  padding: 0.2rem 0.5rem;
}

.flash-title {
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--violet);
}

.flash-sub {
  font-size: 1.05rem;
}

.flash-card:hover .flash-title,
.flash-card:focus .flash-title {
  text-decoration: underline;
}

/* Party popper: pops twice on each page view, then settles. Not gated behind
   prefers-reduced-motion — it's a deliberate decorative flourish, like the P127 dog. */
.flash-pop {
  display: inline-block;
  transform-origin: bottom left;
  animation: pop 0.7s ease-out 0.25s 2 both;
}

@keyframes pop {
  0% { transform: scale(0.4) rotate(-25deg); opacity: 0.2; }
  55% { transform: scale(1.4) rotate(12deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.panel-shops .panel-subsection .panel-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  align-items: stretch;
}

.panel-shops .panel-subsection .panel-body .list-item {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .panel-shops .panel-subsection .panel-body {
    grid-template-columns: 1fr;
  }
}

.category-tagline {
  margin: 0.1rem 0 0;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--fg);
}

.road-status {
  padding: 0.4rem 0;
  border-top: 1px dashed var(--fg);
}

.road-status:first-child {
  border-top: none;
  padding-top: 0;
}

.road-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.road-name {
  color: var(--fg);
}

.road-badge {
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border: 2px solid var(--fg);
}

.road-badge-busy {
  background: var(--red);
  color: var(--bg);
}

.road-badge-normal {
  background: var(--cyan);
  color: var(--fg);
}

.road-badge-clear {
  background: var(--green);
  color: var(--bg);
}

.road-caption {
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.panel-body .value {
  color: var(--fg);
  letter-spacing: 0.05em;
}

.panel-body .alert {
  color: var(--red);
}

.list-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.5rem;
  border-left: 5px solid var(--cyan);
  transition: background 0.15s ease;
}

.list-icon {
  flex-shrink: 0;
  font-size: 1.3rem;
  line-height: 1.3;
}

.list-item:last-child {
  margin-bottom: 0;
}

.list-item:nth-child(4n+2) {
  border-left-color: var(--yellow);
}

.list-item:nth-child(4n+3) {
  border-left-color: var(--magenta);
}

.list-item:nth-child(4n+4) {
  border-left-color: var(--green);
}

.list-item a {
  color: var(--blue);
  text-decoration: none;
}

.list-item:hover {
  background: var(--fg);
}

.list-item:hover .value {
  color: var(--yellow);
}

.list-item:hover a {
  color: var(--cyan);
  text-decoration: underline;
}

/* --listing-accent-text picked per colour's actual contrast ratio against black/white
   (cyan/yellow/green are light enough for black text; magenta/red/blue are not). */
#shops-pubs-body { --listing-accent: var(--violet); --listing-accent-text: var(--bg); }
#shops-cafes-body { --listing-accent: var(--yellow); --listing-accent-text: var(--fg); }
#shops-restaurants-body { --listing-accent: var(--green); --listing-accent-text: var(--fg); }
#shops-speciality-body { --listing-accent: var(--blue-soft); --listing-accent-text: var(--bg); }
#shops-hairdressers-body { --listing-accent: var(--cyan); --listing-accent-text: var(--fg); }
#shops-beauty-body { --listing-accent: var(--red); --listing-accent-text: var(--bg); }
#shops-convenience-body { --listing-accent: var(--magenta); --listing-accent-text: var(--bg); }

/* P103 accents match each panel's existing h2 background for a consistent through-line. */
#events-body { --listing-accent: var(--yellow); --listing-accent-text: var(--fg); }
#community-events-body { --listing-accent: var(--cyan); --listing-accent-text: var(--fg); }
#news-body { --listing-accent: var(--green); --listing-accent-text: var(--fg); }

/* P101 HIGHSTREET TIMES has no h2 override, so its default header colour is cyan too. */
.panel-times { --listing-accent: var(--yellow); --listing-accent-text: var(--fg); }

/* Each listing is a self-contained "business card": accent header bar, contact body, and a
   maps link pinned to the bottom (margin-top:auto) so footers line up across a grid row. */
.panel-listing .list-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.85rem;
  border: 4px solid var(--listing-accent, var(--cyan));
}

.panel-listing .list-item:hover {
  background: none;
}

.panel-listing .list-item .value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.7rem;
  margin: -0.85rem -0.85rem 0.7rem;
  padding: 0.45rem 0.7rem;
  background: var(--listing-accent);
  color: var(--listing-accent-text, var(--fg));
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.9rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
}

.value-name {
  flex: 1 1 auto;
}

/* Social link (e.g. Instagram) — SVG icon sitting in the card body, below the times. */
.list-item a.value-social {
  display: inline-flex;
  align-items: center;
  color: var(--magenta);
  text-decoration: none;
}

.list-item a.value-social:hover {
  transform: scale(1.12);
  text-decoration: none;
}

/* USEFUL INFO items reuse the weather panel's subsection layout (dashed dividers, magenta
   headings), with the maps pin pushed to the right of each heading. */
.panel-times .panel-subsection h3 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Google Maps pin pushed to the right of a USEFUL INFO item's heading. */
.map-pin {
  margin-left: auto;
  flex: 0 0 auto;
  padding-left: 0.5rem;
  line-height: 1;
  text-decoration: none;
}

.map-pin:hover {
  transform: scale(1.15);
  text-decoration: none;
}

/* Phone on its own line in the white card body (body font, black/blue on white) so it reads
   the same regardless of the category's accent colour, rather than on the coloured header bar. */
.listing-phone {
  font-size: 1.05rem;
  line-height: 1.4;
  margin-top: 0.15rem;
}

.listing-phone a {
  color: var(--blue);
  text-decoration: none;
  white-space: nowrap;
}

.listing-phone a:hover {
  text-decoration: underline;
}

/* Card body split into a left content column and the opening hours stacked on the right. */
/* Two columns: content on the left, opening hours locked to the top-right. A grid (rather
   than a wrapping flexbox) keeps the hours in the right column for every card, however much
   text sits on the left, so they never drop below the content. */
.list-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem 0.8rem;
  align-items: start;
}

.list-cols-main {
  min-width: 0;
}

.listing-hours-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.15rem;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--fg);
}

.panel-listing .list-item:hover .value {
  color: var(--listing-accent-text, var(--fg));
}

a.value:hover {
  text-decoration: underline;
}

.panel-listing .list-item:hover a:not(.value):not(.value-social):not(.map-pin) {
  color: var(--blue);
  text-decoration: underline;
}

.listing-meta {
  font-size: 0.85rem;
  line-height: 1.45;
}

/* Opening hours: black (max contrast on white) so the practical info stands out from the
   blue address line. */
.listing-hours {
  color: var(--fg);
}

/* Address (left) and opening hours (pushed right) share one row, wrapping on narrow cards. */
.listing-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 1rem;
}

.listing-hours {
  margin-left: auto;
  text-align: right;
}

/* Pinned to the bottom of the card so footers align across a row. */
.listing-link {
  margin-top: auto;
  padding-top: 0.55rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.listing-link .value-social {
  margin-left: auto;
}

.listing-detail {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--magenta);
}

/* Teletext-style error page (P172). */
.error-page {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
}

.error-message {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  line-height: 1.3;
  color: var(--magenta);
}

.error-code {
  margin: 0.5rem 0;
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: clamp(4rem, 22vw, 11rem);
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--red);
}

.error-sub {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  color: var(--blue);
}

.error-back a {
  color: var(--blue);
  font-size: 1.15rem;
}

.site-footer {
  padding: 0.5rem 1rem;
  background: var(--fg);
  color: var(--bg);
  border-top: 3px solid var(--cyan);
  font-family: "VT323", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 1rem;
  text-align: center;
}

/* Teletext-style status row. */
.status-line {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.1rem 0.55rem;
  letter-spacing: 0.03em;
}

.status-brand {
  color: var(--cyan);
}

#status-version,
#status-updated {
  color: var(--yellow);
}

.status-ok {
  color: var(--green);
}

.status-sep {
  color: var(--cyan);
  opacity: 0.55;
}

/* ==========================================================================
   Responsive & accessibility — mobile-first tuning
   ========================================================================== */

/* Stop iOS/Android inflating text unpredictably in landscape. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Fluid title so the wide Silkscreen logo never overflows narrow phones. */
.site-title {
  font-size: clamp(1.25rem, 5.5vw, 1.75rem);
}

/* Keep the black header/footer bars flush to the edges on notched phones
   (paired with viewport-fit=cover), without losing the base padding elsewhere. */
@supports (padding: max(0px)) {
  .site-header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .ticker-wrap { padding-right: max(0.5rem, env(safe-area-inset-right)); }
  .site-footer { padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
}

/* Touch devices: give the interactive bits a comfortable vertical tap area without
   widening the buttons (4 nav pages have to fit one narrow row — see below). */
@media (pointer: coarse) {
  .page-number { padding: 0.4rem 0.45rem; }
  .info-icon { min-width: 44px; min-height: 44px; }
}

/* Narrow screens: drop the nav onto its own full-width row of equal, easily
   tappable page buttons instead of crowding it beside the logo. min-width:0 lets the
   four buttons shrink to share the row instead of overflowing off the right edge. */
@media (max-width: 560px) {
  .site-header { flex-wrap: wrap; gap: 0.5rem 0.75rem; }
  .page-nav { width: 100%; gap: 0.4rem; }
  .page-number {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: 0.95rem;
    padding: 0.4rem 0.2rem;
  }
}

/* On tap, info popups can sit off the right edge on small screens — clamp them. */
@media (max-width: 400px) {
  .info-popup { max-width: calc(100vw - 2rem); }
}

/* Reduced-motion: drop the incidental hover fade and the smooth jump-scroll. The ticker is
   intentionally left scrolling — it's the site's primary "live" cue and is expected to move. */
@media (prefers-reduced-motion: reduce) {
  .list-item { transition: none; }
  html { scroll-behavior: auto; }
}

/* P102 category index — jump-links to each shop subsection. */
html { scroll-behavior: smooth; }

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem;
  border-bottom: var(--panel-border) solid var(--fg);
}

.category-nav a {
  font-family: "Silkscreen", "Courier New", ui-monospace, "Consolas", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg);
  text-decoration: none;
  padding: 0.4rem 0.55rem;
  border: 2px solid var(--fg);
  white-space: nowrap;
}

.category-nav a:hover,
.category-nav a:focus {
  background: var(--fg);
  color: var(--yellow);
}

/* Small offset so a jumped-to heading isn't flush against the viewport top. */
.panel-subsection[id] { scroll-margin-top: 0.75rem; }
