/* layout.css — page structure: container, sections, sticky navbar, page header, footer, car grid.
   Used by: every page (loaded after base.css). */


/* --------------------------------------------------------------------------
   Container and sections
   -------------------------------------------------------------------------- */

/* [TOPIC: classes vs IDs]
   A class (.container) can be used on many elements; an ID (#main) must be
   unique on the page, and an ID selector is stronger than a class selector.
   Every page has exactly one <main id="main">, so we style it by its ID:
   it fills at least the screen height, so short pages never show a floating footer. */
#main {
  min-height: calc(100vh - var(--header-height));
}

/* [TOPIC: units – %]  the container is 90% of the screen, up to 76rem wide */
.container {
  width: 90%;
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
}

.section {
  padding: var(--space-section) 0;
}

.section + .section {
  border-top: 1px solid var(--color-border);
}

.section-tight {
  padding: 3rem 0 var(--space-section);
}

.section-header {
  max-width: 40rem;
  margin-bottom: 2.5rem;
}

.section-header h2 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

.section-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: 1.125rem;
}

/* [TOPIC: flexbox]  title on the left, link on the right */
.section-header-split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  max-width: none;
}

.section-header-split > div {
  max-width: 40rem;
}

/* [TOPIC: grid]  auto-fill makes as many 17rem columns as fit on the screen */
.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 2rem 1.5rem;
}


/* --------------------------------------------------------------------------
   Header and navbar
   -------------------------------------------------------------------------- */

/* [TOPIC: z-index]  position: sticky keeps the header at the top while you
   scroll. z-index: 100 puts it above the page content, but BELOW the modal
   (z-index 1000) and the toasts (z-index 1100) in components.css. */
.site-header {
  --float-gap: 0.75rem;     /* space between the floating bar and the top of the screen */
  --float-pad: 1.25rem;     /* inner padding of the floating bar */
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-header-bg);
  transition: background-color 0.3s ease-out, border-color 0.3s ease-out;
}

/* [TOPIC: flexbox]  logo on the left, links in the middle, buttons on the right */
.navbar {
  position: relative;
  isolation: isolate;       /* keeps the ::before frame below the links but inside the bar */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 100%;
  transition: transform 0.3s ease-out;
}

/* [TOPIC: ::before + z-index]  the frame of the floating bar, drawn BEHIND the logo
   and links (z-index -1). It is wider than the bar by --float-pad on each side, so
   when it appears the content stays exactly where it was. Invisible at the top. */
.navbar::before {
  content: "";
  position: absolute;
  inset: calc(var(--float-gap) / 2) calc(-1 * var(--float-pad));
  z-index: -1;
  border: 1px solid transparent;
  background-color: var(--color-header-bg);
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

/* Scrolled down (navbar.js adds .is-floating): the full-width header disappears and
   the bar floats on its own, away from the top and the sides. Only transform and
   opacity animate, which is cheap for the browser. */
.site-header.is-floating {
  border-bottom-color: transparent;
  background-color: transparent;
  pointer-events: none;     /* clicks go through the empty strip beside the bar */
}

.site-header.is-floating .navbar {
  transform: translateY(calc(var(--float-gap) / 2));
  pointer-events: auto;
}

.site-header.is-floating .navbar::before {
  opacity: 1;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.35);
}

/* On a dark page a shadow is invisible, so the floating bar gets a thin frame instead */
[data-theme="dark"] .site-header.is-floating .navbar::before {
  border-color: var(--color-border);
  box-shadow: none;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo:hover {
  color: var(--color-ink);
}

.logo-mark {
  width: 2.75rem;
  height: 2.75rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  position: relative;
  display: block;
  padding: 0.5rem 0;
  color: var(--color-text);
  font-weight: 500;
  text-decoration: none;
}

/* [TOPIC: :hover] */
.nav-link:hover {
  color: var(--color-ink);
}

.nav-link.is-active {
  color: var(--color-ink);
  font-weight: 600;
}

/* [TOPIC: ::after]  red bar under the link of the current page */
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background-color: var(--color-red);
}

.nav-cta-mobile {
  display: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle,
.menu-toggle {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--color-border);
  background-color: transparent;
  color: var(--color-ink);
  transition: border-color var(--ease);
}

.theme-toggle:hover,
.menu-toggle:hover {
  border-color: var(--color-ink);
}

/* Moon in light mode, sun in dark mode */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Hamburger button (only visible on small screens) */
.menu-toggle {
  display: none;
  align-content: center;
}

.menu-toggle-bar {
  display: block;
  width: 1.1rem;
  height: 2px;
  margin: 2px 0;
  background-color: currentColor;
  transition: transform var(--ease), opacity var(--ease);
}

/* Turn the three bars into an X when the menu is open */
.menu-toggle.is-open .menu-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle.is-open .menu-toggle-bar:nth-child(2) { opacity: 0; }
.menu-toggle.is-open .menu-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }


/* --------------------------------------------------------------------------
   Page header (title block at the top of inner pages)
   -------------------------------------------------------------------------- */
.page-header {
  position: relative;
  overflow: hidden;
  padding: 3.5rem 0 2.5rem;
  border-bottom: 2px solid var(--color-ink);
}

/* Big, quiet illustration in some page headers (Our Fleet, Contact): one flat
   shape just a shade away from the background, cut off by the header's edges.
   The text sits above it (the container comes later and is positioned). */
.page-header .container {
  position: relative;
}

.page-header-art {
  position: absolute;
  height: auto;
  color: var(--color-art);
  pointer-events: none;
}

/* Parts cut out of the shape (the wheel hubs) */
.page-header-art .art-cut {
  fill: var(--color-bg);
  stroke: var(--color-bg);
}

/* A thin outline in the background colour, drawn under the fill,
   so overlapping shapes (pin + rings) stay separate */
.page-header-art .art-gap {
  stroke: var(--color-bg);
  stroke-width: 12;
  paint-order: stroke;
}

.page-header-art-car {
  right: -7rem;
  bottom: -5rem;
  width: min(60rem, 95vw);
}

.page-header-art-map {
  right: -6rem;
  bottom: -3.5rem;
  width: min(48rem, 90vw);
}

.page-header h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2.25rem, 4vw, 3.25rem);
}

.page-header p {
  max-width: 42rem;
  margin: 0;
  color: var(--color-muted);
  font-size: 1.125rem;
}

.breadcrumb {
  margin-bottom: 1.25rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

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

.breadcrumb a:hover {
  color: var(--color-ink);
}

.breadcrumb span {
  margin: 0 0.5rem;
}


/* --------------------------------------------------------------------------
   Photo band — a section with a colour photo behind it
   (home page hero, top of My bookings). Text on it is white.
   -------------------------------------------------------------------------- */
.photo-band {
  --photo-dim: 0.5;            /* each page can make the photo darker or lighter */
  position: relative;
  isolation: isolate;          /* keeps the photo and its dark layer inside the band */
  overflow: hidden;
  border-bottom: 2px solid var(--color-ink);
  background-color: #111111;
  color: #ffffff;
}

/* [TOPIC: z-index]  the photo sits at the very back (-2) ... */
.photo-band-img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* [TOPIC: ::before + z-index]  ... a see-through black layer (-1) darkens it,
   so the white text stays readable while the colours still show */
.photo-band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: rgba(0, 0, 0, var(--photo-dim));
}

.photo-band h1 {
  color: #ffffff;
}

.photo-band .breadcrumb,
.photo-band .breadcrumb a {
  color: rgba(255, 255, 255, 0.82);
}

.photo-band .breadcrumb a:hover {
  color: #ffffff;
}


/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  padding-top: 4rem;
  border-top: 1px solid var(--color-inverse-border);
  background-color: var(--color-inverse-bg);
  color: var(--color-inverse-muted);
  font-size: 0.95rem;
}

/* [TOPIC: grid]  four footer columns of different widths */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.4fr;
  gap: 2.5rem;
}

.site-footer .logo {
  margin-bottom: 1rem;
  color: var(--color-inverse-text);
}

.footer-brand p {
  max-width: 22rem;
}

.footer-title {
  margin-bottom: 1rem;
  color: var(--color-inverse-text);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  color: var(--color-inverse-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-inverse-text);
  text-decoration: underline;
}

.footer-contact {
  font-style: normal;
  line-height: 1.9;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--color-inverse-border);
  font-size: 0.85rem;
}

.footer-bottom p {
  margin: 0;
}


/* --------------------------------------------------------------------------
   Responsive layout
   [TOPIC: media queries]  styles inside only apply below the given width
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile menu: the link list becomes a dropdown panel under the header */
@media (max-width: 900px) {
  .menu-toggle {
    display: grid;
  }

  /* The dropdown hangs under the bar (attached or floating), as wide as its frame */
  .nav-links {
    position: absolute;
    top: 100%;
    left: calc(-1 * var(--float-pad));
    right: calc(-1 * var(--float-pad));
    z-index: 99;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.25rem var(--float-pad) 1.25rem;
    border: 1px solid var(--color-border);
    border-bottom: 2px solid var(--color-ink);
    background-color: var(--color-header-bg);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ease), visibility var(--ease);
  }

  .site-header.is-floating .nav-links {
    top: calc(100% - var(--float-gap) / 2);
  }

  .nav-links.is-open {
    opacity: 1;
    visibility: visible;
  }

  .nav-link {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.125rem;
  }

  .nav-link.is-active {
    color: var(--color-red-text);
  }

  .nav-link.is-active::after {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --space-section: 4rem;
  }

  .site-header {
    --float-gap: 0.5rem;
    --float-pad: 0.75rem;
  }
}

@media (max-width: 480px) {
  .nav-actions .btn {
    display: none;
  }

  .nav-cta-mobile {
    display: block;
    margin-top: 1rem;
  }

  .nav-cta-mobile .btn {
    width: 100%;
  }

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