:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #111827;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --border: #1f2937;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.6);
  --grid: rgba(148, 163, 184, 0.08);
  
   /* Black & White Palette (High Contrast) */
   --t-red: var(--pixel-white);    /* Boiler: Black (Background) */
   --t-blue: var(--pixel-white);   /* Cabin: Black (Background) */
   --t-green: var(--pixel-white);  /* Carriage: Black (Background) */
   --t-yellow: var(--pixel-black); /* Details/Wheels: White (Foreground) */
   --t-dark: var(--pixel-white);   /* Chassis: Black (Background) */
   --t-light: var(--pixel-white);  /* Windows: Black (Background) */
   
   --pixel-black: var(--text);
   --pixel-white: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 0 1rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


header {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-weight: 900;
  letter-spacing: 0;
  font-size: 1.25rem;
  text-transform: uppercase;
}

nav a {
  color: var(--muted);
  margin-left: 1rem;
  text-decoration: none;
  font-weight: 600;
}

nav a:hover {
  color: var(--text);
}

.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2.5rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: rgba(34, 197, 94, 0.16);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 0.6rem;
}

p.lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.button:hover {
  opacity: 0.9;
}

.button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: border-color 0.2s;
}

.panel:hover {
  border-color: var(--muted);
}


.features {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.features h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.features p {
  margin: 0;
  color: var(--muted);
}

.footnote {
  max-width: 1080px;
  margin: auto auto 0;
  width: 100%;
  padding: 2rem 0 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.footnote a {
  color: var(--muted);
}

.footnote a:hover {
  color: var(--text);
}

/* Train Animation - Thomas Style */
.train-stage {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 600px; /* Increased height */
}

.train-wrapper {
  display: none; /* Hide the train */
  position: relative;
  width: 600px;
  height: 250px;
  margin-top: 50px;
}

.train {
  width: 100%;
  height: 100%;
  position: relative;
  animation: shake 0.6s ease-in-out infinite alternate;
}

@keyframes shake {
  0% { transform: translateY(0); }
  100% { transform: translateY(-2px); }
}

/* Film Strip Container */
.film-strip {
    background: #000;
    width: 640px; 
    padding: 40px 0;
    position: relative;
    box-shadow: 0 0 0 2px #333, 0 30px 60px rgba(0,0,0,0.8);
    margin-top: 0;
    display: flex;
    flex-direction: column;
    
    transform: scale(1.5);
    transform-origin: center center;
}

/* Sprocket Holes (Top & Bottom) */
.film-strip::before, .film-strip::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 25px;
    background-image: linear-gradient(90deg, #fff 16px, transparent 16px);
    background-size: 34px 100%;
    background-position: 15px 0;
    background-repeat: repeat-x;
    opacity: 0.8;
}
.film-strip::before { top: 15px; } 
.film-strip::after { bottom: 15px; }

/* Film Frame (Screen) */
.film-screen {
    width: 100%;
    height: 280px;
    background: var(--bg);
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    overflow: hidden;
    position: relative;
}

/* Old Film Effect Overlay */
.film-screen::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(120, 100, 80, 0.05);
    box-shadow: inset 0 0 80px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 100;
}

/* Vertical Scratch Line Animation */
.film-screen::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0; left: 20%;
    width: 1px;
    background: rgba(0,0,0,0.2);
    z-index: 101;
    animation: scratch 4s infinite steps(1);
}

@keyframes scratch {
    0% { left: 10%; opacity: 0; }
    10% { left: 15%; opacity: 0.3; }
    20% { left: 80%; opacity: 0.1; }
    30% { opacity: 0; }
    50% { left: 40%; opacity: 0.2; }
    100% { opacity: 0; }
}

/* background scenery container */
.scenery-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden;
    z-index: 0; 
}

.scenery-item {
    position: absolute;
    top: 0; left: 0;
    width: 640px;
    height: 100%;
    will-change: transform;
}

.scenery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: contrast(1.2) brightness(0.7);
    background-color: #334155;
}

@keyframes scenery-scroll {
    from { transform: translateX(640px); }
    to { transform: translateX(-640px); }
}

@keyframes scenery-scroll-initial {
    from { transform: translateX(0); }
    to { transform: translateX(-640px); }
}


/* Train Wrapper Specifics */
.train-wrapper {
    display: none; /* Hide the train */
    width: 600px;
    height: 250px;
    position: absolute;
    bottom: 5px;
    left: 180px;
    transform-origin: bottom left;
    transform: scaleX(-1) scale(0.3);
    z-index: 10; 
}

/* Coupling Link */
.train-link {
    position: absolute;
    bottom: 45px;
    left: 270px;
    width: 45px;
    height: 8px;
    background: var(--pixel-black);
    z-index: 3;
}

/* Carriage Container */
.train-carriage {
    position: absolute;
    bottom: 0px;
    left: 305px;
    width: 250px;
    height: 160px;
    animation: shake 0.6s ease-in-out infinite alternate-reverse;
}

/* Carriage Body */
.carriage-body {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 220px;
    height: 90px;
    background: var(--t-green);
    border: 5px solid var(--pixel-black);
    z-index: 5;
}

/* Carriage Roof */
.carriage-body::after {
    content: "";
    position: absolute;
    top: -12px; left: -10px;
    width: 240px; height: 12px;
    background: var(--pixel-black);
}

/* Carriage Windows */
.carriage-window {
    position: absolute;
    bottom: 65px;
    width: 45px;
    height: 40px;
    background: var(--t-light);
    border: 4px solid var(--pixel-black);
    z-index: 6;
}
.carriage-window.cw1 { left: 25px; }
.carriage-window.cw2 { left: 90px; }
.carriage-window.cw3 { left: 155px; }

/* Carriage Wheels */
.carriage-wheel {
    position: absolute;
    bottom: 0px;
    width: 45px;
    height: 45px;
    background: var(--t-yellow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 0.8s linear infinite;
    z-index: 10;
    border: 2px solid var(--pixel-black);
}
.carriage-wheel::after {
    content: "";
    width: 16px; height: 16px;
    background: var(--pixel-white); /* Contrast color for axle */
    border-radius: 50%;
}
.carriage-wheel.w1 { left: 30px; }
.carriage-wheel.w2 { left: 145px; }

/* Cabin */
.train-cabin {
  position: absolute;
  bottom: 50px;
  left: 175px;
  width: 100px;
  height: 110px;
  background: var(--t-blue);
  border: 5px solid var(--pixel-black);
  z-index: 5;
}

/* Cabin Roof */
.train-cabin::before {
  content: "";
  position: absolute;
  top: -12px;
  left: -10px;
  width: 120px;
  height: 12px;
  background: var(--pixel-black);
}

/* Cabin Window */
.train-window {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 60px;
  height: 55px;
  background: var(--t-light);
  border: 4px solid var(--pixel-black);
}
.train-window::after, .train-window::before {
    display: none;
}

/* Boiler */
.train-body {
  position: absolute;
  bottom: 50px;
  left: 40px;
  width: 140px;
  height: 75px;
  background: var(--t-red);
  z-index: 6;
  border: 4px solid var(--pixel-black);
  border-right: none;
}

.train-body::before {
    content: "";
    position: absolute;
    top: 10px; left: 0;
    width: 100%;
    height: 4px;
    background: var(--t-yellow);
}

/* Boiler Front Plate */
.train-plate {
   position: absolute;
   bottom: 50px;
   left: 30px; 
   width: 15px;
   height: 75px;
   background: var(--t-yellow);
   border: 5px solid var(--pixel-black);
   border-right: none;
   z-index: 7;
}
.train-plate::after {
    content: "";
    position: absolute;
    top: 25px; left: -2px;
    width: 8px; height: 15px;
    background: var(--pixel-black);
}

/* Chimney */
.train-chimney {
  position: absolute;
  bottom: 125px;
  left: 60px;
  width: 32px;
  height: 55px;
  background: var(--t-dark);
  z-index: 8;
  border: 3px solid var(--pixel-black);
}
.train-chimney::before {
    content: "";
    position: absolute;
    top: -10px; left: -9px;
    width: 50px; height: 10px;
    background: var(--pixel-black);
    border-radius: 2px;
}
.train-chimney::after {
    content: "";
    position: absolute;
    bottom: -6px; left: -6px;
    width: 44px; height: 6px;
    background: var(--pixel-black);
}

/* Cowcatcher */
.train-cowcatcher {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 40px;
    height: 40px;
    background: var(--t-dark);
    border: 4px solid var(--pixel-black);
    clip-path: polygon(0 100%, 100% 0, 100% 100%);
    z-index: 9;
}

/* Chassis */
.train-chassis {
  position: absolute;
  bottom: 40px;
  left: 30px;
  width: 250px;
  height: 15px;
  background: var(--t-dark);
  border: 4px solid var(--pixel-black);
  z-index: 4;
}

/* Wheels */
.train-wheel {
  position: absolute;
  bottom: 0px;
  width: 55px;
  height: 55px;
  background: var(--t-yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spin 0.8s linear infinite;
  z-index: 10;
  border: 3px solid var(--pixel-black);
}
.train-wheel::after {
    content: "";
    width: 20px; height: 20px;
    background: var(--pixel-white); /* Contrast color for axle */
    border-radius: 50%;
}

.train-wheel.w1 { left: 45px; }
.train-wheel.w2 { left: 125px; }
.train-wheel.w3 { left: 215px; }

/* Connecting Rod */
.train-rod {
  position: absolute;
  bottom: 25px;
  left: 40px;
  width: 150px; 
  height: 8px;
  background: var(--pixel-white);
  border: 4px solid var(--pixel-black);
  z-index: 15;
  transform-origin: 0 0; 
  animation: rod-move 1s linear infinite;
  display: none; 
}

@keyframes rod-move {
  0%   { transform: translate(0, -9px); }
  25%  { transform: translate(-9px, 0); }
  50%  { transform: translate(0, 9px); }
  75%  { transform: translate(9px, 0); }
  100% { transform: translate(0, -9px); }
}

/* Smoke */
.smoke {
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--pixel-white);
  border: 3px solid var(--pixel-black); 
  border-radius: 50%;
  opacity: 0;
  z-index: 20;
}
.smoke.s1 { left: 60px; bottom: 180px; animation: puff 1.4s ease-out infinite; }
.smoke.s2 { left: 80px; bottom: 190px; animation: puff 1.4s ease-out infinite 0.5s; }

@keyframes puff {
  0% { 
      transform: translate(0, 0) scale(0.5); 
      opacity: 0.8; 
  }
  100% { 
      transform: translate(100px, -80px) scale(2.5); 
      opacity: 0; 
  }
}

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

/* Track / Rails */
.track {
    display: none; /* Hide the track */
    position: absolute;
    bottom: 0px;
    left: 0;
    width: 200%;
    height: 6px;
    background-image: 
        linear-gradient(90deg, transparent 40px, var(--pixel-black) 40px, var(--pixel-black) 46px, transparent 46px), 
        linear-gradient(to bottom, transparent 0px, var(--pixel-black) 0px, var(--pixel-black) 2px, transparent 2px);
    background-size: 60px 100%, 100% 100%;
    background-repeat: repeat-x, no-repeat;
    animation: track-move 0.4s linear infinite;
    z-index: 1;
    opacity: 0.8;
}

@keyframes track-move {
    from { transform: translateX(0); }
    to { transform: translateX(-60px); }
}

/* Station (Hidden) */
.station, .station-sign, .station-poles, .station-platform, .station-scenery {
    display: none;
}
