/* --- 1. GLOBAL & CARD BASE --- */
body {
  margin: 0;
  padding: 0;
  background-color: #1a1a1a;
  color: white;
  font-family: "Titillium Web", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  overflow-x: hidden;
  position: relative; /* Required for the logo layer */
}

/* THE LOGO LAYER */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Update the path here! */
  background-image: url("WR-Trans-512.png");
  background-repeat: no-repeat;
  background-position: center 40%; /* Lines up with your 565px gap */
  background-size: 280px;
  z-index: -1; /* Puts it behind everything */
  opacity: 0.5; /* Adjust this to make the logo subtle or bright */
  pointer-events: none; /* Keeps it from blocking clicks */
}

.WR-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 15px;
  width: 100%;
  height: 50px; /* Lock the header height */
  box-sizing: border-box;
  background-color: #1a1a1a;
}

.WR-logo {
  height: 100%;
  display: flex;
  align-items: center;
  /* Ensure no background or border is inherited */
  background: transparent !important;
  border: none !important;
}

.logo-img {
  height: 50px; /* Manually set a clean height */
  width: auto; /* Aspect ratio stays perfect */
  display: block;
}

.card {
  position: relative;
  background: #1a1a1a;
  padding: 10px;
  border-radius: 15px;
  border-top: 2px solid #e10600;
  text-align: center;
  margin: 5px auto;
  width: calc(100% - 10px);
  max-width: 600px;
  transition: min-height 0.3s ease-out;
  height: auto;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

  /* The original 4s smooth pulse */
  animation: stripHeat 4s infinite ease-in-out;
}

@keyframes stripHeat {
  0%,
  100% {
    border-top-color: #7a0300;
  }
  50% {
    border-top-color: #ff0b0b;
  }
}

/* --- 2. THE F1 SWIPE CARDS (The Triple-Pulse Limiter) --- */

#upcoming_card {
  /* This overrides the .card animation specifically for these two */
  animation: pitLimiter 6s infinite linear !important;
}

@keyframes pitLimiter {
  /* PULSE 1-3: THE IDLE (0% - 70%) */
  0%,
  20% {
    border-top-color: #300100;
  }
  10% {
    border-top-color: #5a0200;
  }
  25%,
  45% {
    border-top-color: #300100;
  }
  35% {
    border-top-color: #5a0200;
  }
  50%,
  70% {
    border-top-color: #300100;
  }
  60% {
    border-top-color: #5a0200;
  }

  /* THE REDLINE HIT (75% - 100%) */
  75%,
  85% {
    border-top-color: #ff0b0b;
  }
  90% {
    border-top-color: #e10600;
  }
  93% {
    border-top-color: #7a0300;
  }
  96% {
    border-top-color: #e10600;
  }
  100% {
    border-top-color: #300100;
  }
}

/* --- 2. THE IGNITION SYSTEM (Fades & Animations) --- */
#loading {
  font-weight: bold;
  color: #e10600;
  text-transform: uppercase;
}

#temp_C,
#humidity,
#weather_emoji,
#rain_horizon,
#units_toggle_container,
#telemetry_divider,
.telemetry-row,
.wind-telemetry-wrapper,
.forecast-details,
#historical-match-hook,
#upcoming-events-hook,
#race-results-hook,
#match_card,           /* Added */
#upcoming_card,
#results_card,        /* Added */
#footer-group {
  /* Added */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.8s ease-in-out,
    visibility 0.8s ease-in-out;
}

/* This is the master switch that flips them all to 1 */
.data-ready {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* --- 3. TOP TELEMETRY (Emoji, Desc, Temp, Hum) --- */
#weather_emoji {
  font-size: 5em;
  margin-top: -30px;
  margin-bottom: 5px;
}
#weather_desc {
  /* The "Look" */
  font-size: 1.2em;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 10px;
  width: 100%;
  transition: opacity 0.4s ease-in-out;
  opacity: 1;
  visibility: visible;
}

#temp_C {
  font-size: 4.1em;
  letter-spacing: -2px;
  margin: 0;
  margin-bottom: 5px;
  padding: 0;
  line-height: 1;
}
#telemetry_divider {
  font-size: 2.5em;
  color: #e10600;
  font-weight: bold;
  opacity: 0.9;
}
#humidity {
  font-size: 2em;
  margin: 0;
  padding: 0;
  line-height: 1;
}

.telemetry-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 60px;
}

/* --- 4. WIND TELEMETRY --- */
/* --- WIND TELEMETRY CONTAINER --- */
.wind-telemetry-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.wind-row {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  width: 100%;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.wind-row::-webkit-scrollbar {
  display: none;
}

/* --- INDIVIDUAL HOUR CARD --- */
.wind-item {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 20px;
}

.wind-time-header {
  color: #fff;
  font-size: 1.2em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: -10px;
  margin-bottom: 10px;
}

.wind-row {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  width: 100%;
  height: 100px; /* Bumping this up from 90px */
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.wind-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- LABELS & VALUES --- */
.wind-label {
  color: #aaa;
  text-transform: uppercase;
  font-size: 1em;
  letter-spacing: 1px;
  font-weight: 800;
}

.wind-value {
  font-weight: 900;
  font-size: 1.1em;
  color: white;
  display: flex;
  align-items: center;
  gap: 5px;
}

#wind_unit_label {
  font-size: 0.8em;
  font-weight: 800;
  color: white;
  text-transform: lowercase;
}

.wind-arrow {
  color: #e10600;
  font-size: 1.2em;
  transition: transform 1s ease-in-out;
}

/* --- NAVIGATION BUTTONS --- */
.wind-nav-btn,
.f1-nav-btn {
  position: absolute;
  top: 45px;
  transform: translateY(-50%);
  z-index: 20;
  background: transparent !important; /* Forces the box to disappear */
  border: none !important;
  cursor: pointer;
  padding: 15px;
  font-size: 1.2rem;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;

  /* Start subtle */
  color: #aaa;
}

/* Positioning for both sets */
.wind-nav-btn.left,
.f1-nav-btn.left {
  left: 0;
}
.wind-nav-btn.right,
.f1-nav-btn.right {
  right: 0;
}

/* Identical Hover/Active States */
@media (hover: hover) {
  .wind-nav-btn:hover,
  .f1-nav-btn:hover {
    color: #ffffff;
  }
}

.wind-nav-btn:active,
.f1-nav-btn:active {
  color: #ffffff;
  transition: none;
}

/* --- 5. RAIN HORIZON & SCROLLBAR --- */
.rain-horizon {
  display: flex;
  overflow-x: auto;
  gap: 5px;
  min-height: 120px;
  width: 100%;
  flex-shrink: 0;
  align-items: flex-start;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.rain-horizon.data-ready {
  scrollbar-color: #666 #1a1a1a;
}
.rain-horizon::-webkit-scrollbar {
  height: 2px;
}
.rain-horizon::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
}
.rain-horizon.data-ready::-webkit-scrollbar-thumb {
  background: #666;
}

/* --- 6. HOUR CARDS --- */
.hour-card {
  /* 1. Dimensions & Layout */
  flex: 0 0 85px;
  height: 115px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 3px solid #333;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 0.6s ease-out,
    transform 0.6s ease-out,
    visibility 0.6s,
    background-color 0.3s ease;
}

.hour-card.data-ready {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (min-width: 768px) {
  .hour-emoji {
    font-size: 1.8em; /* 40% larger on PC */
    height: 25px;
  }
}

/* Internal card slide-up effect */
.hour-time,
.hour-temp, /* ADDED */
.hour-prob,
.hour-label {
  opacity: 0;
  transform: translateY(5px);
  transition: all 0.6s ease-out;
}

.hour-card.data-ready .hour-time,
.hour-card.data-ready .hour-temp, /* ADDED */
.hour-card.data-ready .hour-prob,
.hour-card.data-ready .hour-label {
  opacity: 1;
  transform: translateY(0);
}

.hour-time {
  font-size: 0.75em;
  color: #aaa;
  text-transform: uppercase;
  font-weight: bold;
  line-height: 1;
  margin-bottom: 5px;
  margin-top: 5px;
}

.hour-temp {
  font-size: 1em; /* Made it slightly larger to be the 'Hero' number */
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px; /* Adjust this to create that space you wanted */
}

.hour-emoji {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em; /* Nice and compact for mobile */
  margin-bottom: 5px;
}

.hour-prob {
  font-size: 1.2em;
  font-weight: 900;
  margin: 2px 0;
  line-height: 1.1;
}
.hour-label {
  font-size: 0.6em;
  letter-spacing: 1px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 5px;
}

/* --- 8. 10-DAY FORECAST --- */
.forecast-details {
  width: 100%;
  margin-top: 2px;
  border-top: 1px solid #333;
}

.forecast-summary {
  list-style: none;
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  font-size: 1.2em;
  border-bottom: 1px solid #333;
  padding-bottom: 8px; /* Adjust this to control how close the text is to the bottom line */
}

.forecast-summary::-webkit-details-marker {
  display: none;
}

.forecast-row {
  opacity: 0;
  transform: translateY(5px);
  font-family: sans-serif;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;

  /* CHANGE THIS: 1.2fr for the day name, and 1fr for the 4 data points */
  display: grid;
  /* 1.5fr for Day, 2.5fr for the combined Weather block, 1.5fr for Temp, 1fr for Wind */
  grid-template-columns: 0.8fr 1fr 0.5fr 1fr 0.9fr;
  align-items: center;
  padding: 12px 5px;
  gap: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family:
    "Titillium Web", sans-serif; /* Increased gap slightly so stacks don't touch */
}

.forecast-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.day-name {
  font-weight: 900;
}
.weekend {
  color: #ffcc00;
}
.today {
  color: #aaa;
}

.forecast-rain {
  font-weight: 800;
}
.forecast-hum {
  color: #666;
  font-size: 0.75em;
  display: block;
}

.forecast-temp {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  gap: 0;
}

.temp-high,
.temp-low {
  width: 35px;
  display: inline-block;
}

.temp-high {
  text-align: right;
  padding-right: 4px;
  color: #fff;
}
.temp-low {
  text-align: left;
  padding-left: 4px;
  color: #fff;
}

.forecast-row.data-ready {
  opacity: 1;
  transform: translateY(0); /* Slide up into place */
}

.forecast-row.no-animation {
  transition: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.forecast-details[open] .chevron {
  transform: rotate(180deg);
}

.chevron {
  display: inline-block;
  transition: transform 0.3s ease;
}

.day-time-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px; /* Space between 12AM and RACE */
  white-space: nowrap; /* Prevents wrapping */
}

.race-badge {
  background: #e10600; /* F1 Red */
  color: white;
  font-size: 0.65em;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
  line-height: 1;
}

/* --- TOGGLE BUTTON --- */
#units_toggle_container {
  position: relative;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
}

/* Add this to re-enable clicking once it fades in */
#units_toggle_container.data-ready {
  pointer-events: auto;
}
#units_toggle {
  appearance: none;
  -webkit-appearance: none;
  background: #222;
  color: #e10600;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 6px 6px;
  cursor: pointer;
  min-width: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  outline: none;
}
#units_toggle::before {
  content: "→ °F";
  font-size: 0.9em;
  font-weight: bold;
  text-transform: uppercase;
}
#units_toggle:checked::before {
  content: "→ °C";
}
#units_toggle:active {
  transform: scale(0.95);
}

#historical-match-hook {
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  transition-delay: 0.4s;
  width: 100%;
  padding-bottom: 20px; /* Adds space so the text doesn't touch the card edge */
}

#historical-match-hook.data-ready {
  opacity: 1 !important;
  transform: translateY(0);
}

.signature {
  position: fixed;
  bottom: 10px;
  right: 15px;
  font-family: "Titillium Web", sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  z-index: 9999;
  text-decoration: none;
}

.signature a {
  color: #e10600; /* F1 Red */
  text-decoration: none;
  font-weight: bold;
}

.signature a:hover {
  text-decoration: underline;
}

.footer-container {
  width: 100%;
  box-sizing: border-box; /* Ensures padding doesn't push the footer wider than the screen */
}

/* The container that limits the view */
.f1-swipe-container {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 15px auto;
  overflow: hidden;
}

/* The actual scrolling row */
.f1-swipe-row {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  align-items: flex-start; /* THIS IS THE HEIGHT FIX */
  scrollbar-width: none;
}

.f1-swipe-row::-webkit-scrollbar {
  display: none;
}

/* The "Page" that holds each card */
.f1-slide {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  align-items: center; /* Increased gap for better separation */
  padding: 10px 0 30px 0; /* Added bottom padding so the About card isn't touching the floor */
  height: auto; /* Ensure it expands to fit both cards */
}
/* The Cards themselves */
#match_card,
#upcoming_card,
#results_card,
#about_card {
  width: calc(100% - 30px);
  margin: 0;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.8s ease,
    transform 0.8s ease;
}

#match_card.data-ready,
#upcoming_card.data-ready,
#results_card.data-ready,
#about_card.data-ready {
  opacity: 1;
  transform: translateY(0);
}

/* Force the main card to only be as tall as its visible parts */

/* Bring the swipe container up to meet it */
.f1-swipe-container {
  position: relative;
  width: 100%;
  max-width: 620px; /* Slightly wider than the cards to fit the arrows */
  margin: 0 auto;
  overflow: hidden;
}

/* Ensure the containers allow the cards to be full width */
#about-hook,
#upcoming-events-hook,
#historical-match-hook,
#race-results-hook {
  width: 100%;
  display: block;
  flex-direction: column;
  align-items: center;
}

#footer-group {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px); /* Slides up from the bottom */
  transition:
    opacity 1s ease-in-out,
    transform 1s ease-out,
    visibility 1s;
}

#footer-group.data-ready {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Container for the flip effect */
.flip-card {
  background-color: transparent;
  width: 100%;
  min-height: 600px;
  height: auto; /* Adjust based on your card height */
  perspective: 1000px; /* Required for 3D effect */
  cursor: pointer;
}

/* This container is needed to position the front and back side */
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  /* CRITICAL: Force Safari to recognize the 3D space */
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

/* Do the actual flip when the class is toggled */
.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

/* Position the front and back side */
/* 1. Add webkit prefix here for better iOS support */

/* 2. Force the front to be "Face Forward" and hidden when flipped */
.flip-card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* ADD THIS: Anchor it to the front 3D plane */
  -webkit-transform: rotateY(0deg);
  transform: rotateY(0deg);
  z-index: 2; /* Ensure front stays on top until flipped */
}

/* 3. Force the back to stay "Face Backward" */
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* ADD THIS: Make sure it starts exactly at 180 */
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
/* Subtle pulse animation for the teaser text */
@keyframes pulse {
  0% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}
