:root {
  --body-font-family: Tahoma, Verdana, Segoe UI, sans-serif;
  --body-font-sans-serif: Tahoma, Verdana, system-ui, sans-serif;
  --body-font-size: 1rem;
  --body-font-weight: 400;
  --body-line-height: 1.5;
}

/* Smooth scrolling for motion */
@media (prefers-reduced-motion: no-preference) {
  :root {
    scroll-behavior: smooth;
  }
}

* {
  box-sizing: border-box;
}

/* Body Styling and Colours */
body {
  height: 100vh;
  margin: 0;
  color: var(--font-color);
  background-color: var(--body-bg);
  font-family: var(--body-font-family);
  font-size: var(--body-font-size);
  font-weight: var(--body-font-weight);
  line-height: var(--body-line-height);
  text-transform: uppercase;
}

body.light-mode {
  --header-bg: #cce0ff;
  --body-bg: #d4a8ff;
  --nav-bg: #fff9d1;
  --sidebar-bg: #ffd1d1;
  --footer-bg: #adffe0;
  --input-bg: #e6e9ff;
  --page-wrap: #c6c6c6;
  --font-color: #000;
  --header-text-colour: #fff;
  --window-title-bar: linear-gradient(90deg, #ff9a9e 0%, #fecfef 100%);
}

body.dark-mode {
  --header-bg: #15202b;
  --body-bg: #192734;
  --nav-bg: #22303c;
  --sidebar-bg: #8899ac;
  --footer-bg: #1a374d;
  --input-bg: #2c3e50;
  --page-wrap: #1c2833;
  --font-color: #fff;
  --header-text-colour: #fff;
  --window-title-bar: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

/* Button styling */
.submit-button,
.cancel-button,
.reserve-button,
.move-to-booking,
.body-oops-button {
  text-decoration: none;
  font-family: var(--body-font-family);
  display: inline-block;
  width: 60%;
  min-width: 120px;
  padding: 8px 16px;
  margin-top: 10px;
  background-color: var(--sidebar-bg);
  color: var(--font-color);
  cursor: pointer;

  /* Soft 3D Outset Border */
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.2);
  border-right: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
  transition: filter 0.2s;
}

/* Theme button */
#theme-toggle-button {
  position: fixed;
  height: fit-content;
  top: 15px;
  right: 15px;
  z-index: 1011;
  padding: 8px 16px;
  background-color: var(--sidebar-bg);
  color: var(--font-color);
  font-family: var(--body-font-family);
  cursor: pointer;

  /* Soft 3D Outset Border */
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.2);
  border-right: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
  transition: filter 0.2s;
}

/* Gentle hover glow */
.submit-button:hover,
.cancel-button:hover,
.reserve-button:hover,
.move-to-booking:hover,
.body-oops-button:hover,
#theme-toggle-button:hover {
  filter: brightness(1.05);
}

/* Pressed Effect */
.submit-button:active,
.cancel-button:active,
.reserve-button:active,
.move-to-booking:active,
.body-oops-button:active,
#theme-toggle-button:active {
  border-top: 2px solid rgba(0, 0, 0, 0.2);
  border-left: 2px solid rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid rgba(255, 255, 255, 0.8);
  border-right: 2px solid rgba(255, 255, 255, 0.8);
  padding: 9px 15px 7px 17px;
  box-shadow: none;
}

/* Page wrap layout */
.page-wrap {
  background: var(--page-wrap);
  height: 100%;
  display: grid;
  grid-template-rows: min-content min-content 1fr min-content;
  grid-template-columns: 1fr;
  gap: 4px;
}

.page-wrap > * {
  text-align: center;
}

/* Header */
.page-header {
  grid-row: 1;
  background: var(--header-bg);
  color: var(--font-color);
  justify-content: space-between;
  align-items: center;
  z-index: 1;
  position: relative;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
}

.page-header h1 {
  width: 100%;
  text-decoration: none;
  font-family: var(--body-font-family);
  color: var(--header-text-colour);
  letter-spacing: 4px;
  -webkit-text-stroke-width: 2px;
  -webkit-text-stroke-color: black;
}

/* Logo image and spinning gradient animation */
.logo {
  position: relative;
  height: 5rem;
  aspect-ratio: 1;
  border-radius: 50%;
}

.logo img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: top;
  border-radius: inherit;
}

.logo::before,
.logo::after {
  position: absolute;
  z-index: -1;
  content: "";
  inset: -5px;
  border-radius: inherit;
  background-image: conic-gradient(#00dbde 25%, #fc00ff 50%, #fffb00, #00dbde);
  animation: rotate 3s linear infinite;
}

.logo::after {
  filter: blur(2rem);
  opacity: 0.7;
}

.logo:hover::before,
.logo:hover::after {
  animation-play-state: paused;
}

@keyframes rotate {
  to {
    rotate: 360deg;
  }
}

/* Header image */
.masthead {
  background-image: url("../images/bannerimage.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--header-text-colour);
  position: relative;
  padding: 0 1rem;
  margin: 0;
  z-index: 2;
}

/* Display banner if no network connection */
#offline-banner {
  display: none;
  background-color: var(--sidebar-bg);
  color: var(--font-color);
  text-align: center;
  padding: 10px;
  font-weight: bold;
}

/* Navigation bar - Soft Window Look */
.page-nav {
  grid-row: 2;
  background: var(--nav-bg);
  color: var(--font-color);
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  z-index: 1;
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  margin: 0 5px;
}

.page-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

.page-nav ul li {
  padding: 10px 0;
}

.page-nav ul li a {
  color: var(--font-color);
  text-decoration: none;
  display: block;
  padding: 10px;
  width: 100%;
  text-align: center;
  font-weight: 750;
}

nav ul li a:hover {
  background: var(--sidebar-bg);
  font-weight: 750;
}

.page-nav details {
  background: var(--nav-bg);
  color: var(--font-color);
  padding: 10px;
}

.page-nav details[open] summary {
  display: none;
}

.page-nav summary {
  cursor: pointer;
  padding: 10px;
  background-color: var(--nav-bg);
  color: var(--font-color);
}

/* Desktop Workspace Container */
.desktop-workspace {
  grid-row: 3;
  position: relative;
  height: 100%;
  min-height: 75vh;
  padding: 15px;
  overflow: auto;
  background: var(--body-bg);
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  margin: 0 5px;
}

/* Floating Window Frame */
.retro-window {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%); /* Centers window horizontally on spawn */
  width: 90%;
  max-width: 1000px;
  height: 65vh;
  min-height: 400px;
  background-color: var(--body-bg);
  color: var(--font-color);
  border: 2px solid #000;
  box-shadow: 4px 4px 0px #000;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  margin: 0;
  z-index: 10;
}

/* The Gradient Title Bar */
.window-title-bar {
  background: var(--window-title-bar);
  color: #000;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #000;
  cursor: move;
  user-select: none;
  font-weight: bold;
  letter-spacing: 1px;
}

/* Close Button */
.window-close-btn {
  background: var(--sidebar-bg);
  color: #000;
  font-weight: bold;
  font-family: var(--body-font-family);
  font-size: 0.9rem;
  border-top: 2px solid rgba(255, 255, 255, 0.9);
  border-left: 2px solid rgba(255, 255, 255, 0.9);
  border-bottom: 2px solid rgba(0, 0, 0, 0.6);
  border-right: 2px solid rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 2px;
}

.window-close-btn:active {
  border-top: 2px solid rgba(0, 0, 0, 0.6);
  border-left: 2px solid rgba(0, 0, 0, 0.6);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
  border-right: 2px solid rgba(0, 0, 0, 0.9);
  padding: 3px 7px 1px 9px;
}

.window-content {
  padding: 1rem;
  overflow-y: auto;
  flex-grow: 1;
  background: linear-gradient(var(--nav-bg), var(--nav-bg));
}

.retro-window iframe {
  width: 100%;
  max-width: 600px;
  height: 450px;
  border: none;
  margin: auto;
  display: block;
}

.retro-window article p {
  text-transform: none;
  text-align: center;
}

/* Carousel Container */
.wrapper {
  background-color: var(--sidebar-bg);
  height: 525px;
  overflow: hidden;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0;
  box-sizing: border-box;
  border-top: 2px solid rgba(0, 0, 0, 0.2);
  border-left: 2px solid rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid rgba(255, 255, 255, 0.8);
  border-right: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 4px;
}

/* 12 photos * 700px = 8400px total track width */
.wrapper .track {
  display: flex;
  flex-shrink: 0;
  width: calc(700px * 12);
  animation: scrollDesktop 30s linear infinite alternate;
  gap: 0;
}

.wrapper .carousel {
  width: 700px;
  flex-shrink: 0;
}

.wrapper .carousel img {
  width: 100%;
  height: 500px;
  object-fit: cover;
  display: block;
}

/* Shifts by 11 full slide widths to expose the 12th image */
@keyframes scrollDesktop {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-700px * 11));
  }
}

/* Animation */
@keyframes scrollAnimation {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-700px * 12 + 100%));
  }
}

/* 404 page */
.body-oops-404 {
  background-color: var(--sidebar-bg);
  height: 50vh;
  width: 60%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  margin: 10px auto;
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
}

.body-oops-404 img {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: block;
  background-repeat: no-repeat;
  border-radius: 4px;
  object-fit: contain;
}

/* Footer */
.page-footer {
  grid-row: 4;
  background: var(--footer-bg);
  color: var(--font-color);
  font-family: var(--body-font-family);
  font-size: var(--body-font-size);
  font-weight: var(--body-font-weight);
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  position: relative;
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  margin: 0 5px 5px 5px;
}

.page-footer-icon-group {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-footer-icon img {
  max-width: 2rem;
  max-height: 2rem;
  display: block;
  cursor: pointer;
}

.page-footer-p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  text-align: right;
}

/* Product & Equipment Cards */
#equipment-container,
#reservation-container {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  margin-top: 20px;
  max-width: 100%;
  color: var(--font-color);
  filter: blur(0.2em);
  animation: removeBlur 0.5s ease-in-out forwards;
}

@keyframes removeBlur {
  0% {
    filter: blur(0.2em);
  }
  100% {
    filter: blur(0);
  }
}

.equipment-card,
.reservation-card {
  width: 300px;
  max-width: 90%;
  background: var(--nav-bg);
  border-top: 2px solid rgba(255, 255, 255, 0.8);
  border-left: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  text-align: center;
  perspective: 1000px;
}

.equipment-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform-origin: center;
  transition: transform 0.5s ease-in-out;
}

.equipment-card-front,
.reservation-card {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.equipment-card-back,
.reservation-card-back {
  background: var(--nav-bg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-bottom: 15px;
}

.equipment-card:hover .equipment-card-inner {
  transform: rotateY(180deg);
  transition-duration: 0.5s;
}

.equipment-card img {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  display: block;
}

.equipment-card img.loaded {
  filter: blur(0);
}

.equipment-card-content {
  padding: 15px;
}

.no-reservations-message {
  font-size: 1.2em;
  text-align: center;
  color: var(--font-color);
  margin: 20px;
}

/* --- Media Queries --- */

@media (width > 768px) {
  .page-nav summary::-webkit-details-marker {
    display: none;
  }
  .page-nav {
    display: flex;
  }
  .page-nav details {
    display: block;
    position: relative;
  }
  .page-nav ul {
    flex-direction: row;
    justify-content: space-around;
  }
  .page-nav details[open] summary {
    display: none;
  }
}

@media (width <= 768px) {
  .page-nav summary::-webkit-details-marker {
    display: inline;
    font-size: 15px;
  }
  .page-nav {
    visibility: visible;
    opacity: 1;
  }
  .page-nav details[open] summary {
    display: block;
  }
  .page-nav summary [open] {
    font-size: 1em;
    padding: 8px 10px;
  }
  .retro-window {
    width: 95%;
    min-width: 280px;
  }
  .wrapper {
    height: 300px;
  }
  .wrapper .carousel {
    width: 400px;
  }
  .wrapper .track {
    width: calc(400px * 6);
  }
  .wrapper .carousel img {
    height: 275px;
  }
  @keyframes scroll {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(calc(-400px * 6 + 100vw));
    }
  }
}

@media (width <= 600px) {
  .page-nav summary::-webkit-details-marker {
    font-size: 15px;
    display: inline;
  }
  .page-header {
    max-height: 85px;
  }
  .masthead {
    height: 60px;
  }
  #theme-toggle-button {
    padding: 5px 10px;
  }
  .logo {
    width: 55px;
  }
  .page-wrap {
    grid-template-columns: 100%;
    grid-template-rows: 85px auto 1fr min-content;
  }
  .page-wrap > * {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }
  .wrapper {
    height: 200px;
  }
  .wrapper .carousel {
    width: 250px;
  }
  .wrapper .track {
    width: calc(250px * 6);
  }
  .wrapper .carousel img {
    height: 175px;
  }
  @keyframes scroll {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(calc(-250px * 6 + 100vw));
    }
  }
}
