/* Page layout. Colours, fonts and .sb-button come from brand.css. */

* { box-sizing: border-box; }

/* The full-bleed train line is 100vw wide; don't let a scrollbar turn that into sideways scroll */
html { overflow-x: clip; }

/* Make the hidden attribute win over display rules (tab panels, tab lists) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  /* Faint horizontal layer lines, like a 3D print up close */
  background:
    repeating-linear-gradient(0deg, rgb(27 31 35 / 0.025) 0 1px, transparent 1px 5px),
    var(--sb-paper);
}

.page {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1rem 2rem;
  text-align: center;
}

.hero-logo {
  width: min(260px, 70vw);
  height: auto;
  /* Builds up from the bottom in layers, like it's being printed */
  animation: print-in 1.4s steps(20, end) 0.2s both;
}

@keyframes print-in {
  from { clip-path: inset(100% 0 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* Station dot-matrix board in brand colours: green-tint LED text on ink, with a dot grid laid over it */
.tagline {
  position: relative;
  display: inline-block;
  margin: -2px 0 0;  /* wheels sit on the frame */
  padding: 0.6rem 1.1rem;
  border: 3px solid var(--sb-green);
  border-radius: 0.375rem;
  background: var(--sb-ink);
  color: #B8E6C9;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-shadow: 0 0 4px rgb(184 230 201 / 0.35);
  box-shadow: inset 0 0 12px rgb(0 0 0 / 0.8), 0 2px 6px rgb(0 0 0 / 0.15);
}

.tagline::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, transparent 65%, rgb(27 31 35 / 0.35) 100%) 0 0 / 2px 2px;
  pointer-events: none;
}

.shops { margin-bottom: 1.75rem; }

/* No shop cards yet (they're commented out): hide the empty section */
.shops:not(:has(li)) { display: none; }



.gallery { margin-top: 2.5rem; }

.gallery-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-list img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0.75rem;
}

.shop-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A single shop sits centred rather than stretched full width */
.shop-list:has(> li:only-child) {
  grid-template-columns: minmax(0, 20rem);
  justify-content: center;
}

.shop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  padding: 1.75rem 1.25rem;
  border: 1px solid #E2D6B8;
  border-radius: 1rem;
  background: #FBF4E2;
  color: var(--sb-ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.shop:hover,
.shop:focus-visible {
  color: var(--sb-ink);
  border-color: var(--sb-green);
  transform: translateY(-2px);
}

.shop:hover .sb-button,
.shop:focus-visible .sb-button { background: var(--sb-ink); }

.shop-name {
  font-family: var(--sb-font-display);
  font-weight: 700;
  font-size: 1.375rem;
}

.shop-logo {
  width: auto;
  height: 3rem;
  margin-bottom: 0.25rem;
}

.shop-desc {
  color: var(--sb-grey);
  margin-bottom: 0.75rem;
}

.shop .sb-button { margin-top: auto; }

.flap-word { white-space: nowrap; }
.flap { display: inline-block; text-align: center; }

/* Tabs (js/tabs.js): a segmented switch, active tab in brand green */
.tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid #E2D6B8;
  border-radius: 999px;
  background: #FBF4E2;
}

.tab {
  appearance: none;
  padding: 0.55rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--sb-ink);
  font: 700 1rem/1 var(--sb-font-display);
  cursor: pointer;
}

.tab:hover { background: #E2D6B8; }
.tab[aria-selected="true"] { background: var(--sb-green); color: var(--sb-white); }
.tab:focus-visible { outline: 2px solid var(--sb-green); outline-offset: 2px; }

/* Logo bar at the top of guide pages */
.guide-topbar {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem max(16px, env(safe-area-inset-left, 0px)) 0;
}

.guide-topbar img {
  display: block;
  width: auto;
  height: 36px;
}

/* Live eBay listings, cards in the same cream as the shop card */
.home-tabs { margin-top: 1.25rem; }
.tab-panel { margin-top: 1rem; }


.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.listing {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  height: 100%;
  padding: 0.625rem 0.625rem 0.875rem;
  border: 1px solid #E2D6B8;
  border-radius: 0.875rem;
  background: #FBF4E2;
  color: var(--sb-ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.listing:hover,
.listing:focus-visible {
  color: var(--sb-ink);
  border-color: var(--sb-green);
  transform: translateY(-2px);
}

.listing img,
.listing-art {
  display: block;
  width: 100%;
  height: auto;  /* let aspect-ratio win over the width/height attributes */
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.5rem;
  background: #EFE6CF;
}

/* Guide cards reuse the listing card (same square image area); the renders have transparent backgrounds */
.guide-card img,
.listing-art {
  object-fit: contain;
  background: none;
}

.listing-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.listing-price {
  margin-top: auto;
  color: var(--sb-green);
  font-family: var(--sb-font-display);
  font-weight: 700;
}

.footer {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--sb-grey);
  font-size: 0.875rem;
}

.footer p { margin: 0; }

/* Flying Scotsman that runs along the top of the tagline board every so often.
   Full screen width, so it enters and leaves at the screen edges. */
.train-line {
  position: relative;
  height: 52px;
  margin: -1.25rem calc(50% - 50vw) 0;  /* tuck up into the logo's bottom padding */
  overflow-x: clip;  /* no sideways scroll, but steam can rise above */
}

.train {
  position: absolute;
  left: 0;
  bottom: 0;
  overflow: visible;
  animation: train-run 24s linear 1s infinite backwards;
}

@keyframes train-run {
  0%        { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100vw); }
}

.train .spin-l,
.train .spin-s {
  transform-box: fill-box;
  transform-origin: center;
  animation: wheel-spin 0.4s linear infinite;
}

.train .spin-s { animation-duration: 0.2s; }

@keyframes wheel-spin { to { transform: rotate(360deg); } }

/* Coupling rod follows the crank pins round in a circle */
.train .rod { animation: rod-turn 0.4s linear infinite; }

@keyframes rod-turn {
  0%, 100% { transform: translate(3px, 0); }
  12.5%    { transform: translate(2.12px, 2.12px); }
  25%      { transform: translate(0, 3px); }
  37.5%    { transform: translate(-2.12px, 2.12px); }
  50%      { transform: translate(-3px, 0); }
  62.5%    { transform: translate(-2.12px, -2.12px); }
  75%      { transform: translate(0, -3px); }
  87.5%    { transform: translate(2.12px, -2.12px); }
}

.train .puff {
  transform-box: fill-box;
  transform-origin: center;
  animation: puff 1.2s ease-out infinite;
}

.train .puff:nth-child(2) { animation-delay: 0.4s; }
.train .puff:nth-child(3) { animation-delay: 0.8s; }

@keyframes puff {
  from { transform: translate(0, 0) scale(0.5); opacity: 0.9; }
  to   { transform: translate(-22px, -12px) scale(1.9); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .train-line { display: none; }
  .hero-logo { animation: none; }
  .shop, .listing { transition: none; }
  .shop:hover, .shop:focus-visible,
  .listing:hover, .listing:focus-visible { transform: none; }
}

/* Near-invisible link to the label sheet tool, top right. */
.corner-link {
  position: fixed;
  top: 0.25rem;
  right: 0.5rem;
  padding: 0.25rem;
  color: var(--sb-grey);
  font-size: 0.875rem;
  line-height: 1;
  text-decoration: none;
  opacity: 0.25;
}

.corner-link:hover,
.corner-link:focus-visible { opacity: 1; }
