/*
 * Loxbridge High‑Tech Forum Site CSS
 * - Theme variables (light/dark)
 * - Base elements
 * - Layout: header, nav, container, footer
 * - Components: carousel, hero, features, news, chatbot, forms, tables
 * - Utilities & responsive
 */

/* =========================
  Theme Variables
  ========================= */
:root {
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --transition-speed: 0.1s;
  --step-0: clamp(0.95rem, 0.90rem + 0.4vw, 1.05rem);
}

.light-theme {
  --background: #fff;
  --surface: #f4f7fb;
  --primary: #012169;
  --secondary: #0052cc;
  --text: #222;
  --text-light: #555;
  --hyperlinks: #012169;
  --border: #dbe2ef;
  --nav-bg: #fff;
  --footer-bg: #012169;
  --footer-text: #e0e6f0;
  --link: #012169;
  --link-hover: #0052cc;
  --chat-bg: #fff;
  --chat-bubble-user: #0052cc;
  --chat-bubble-bot: #e0e6f0;
}

.dark-theme {
  --background: #0a1436;
  --surface: #172a45;
  --primary: #e8f1fa;
  --secondary: #0052cc;
  --text: #e8f1fa;
  --text-light: #b0c7e3;
  --hyperlinks: #0052cc;
  --border: #203459;
  --nav-bg: #0a1436;
  --footer-bg: #012169;
  --footer-text: #a7c0e4;
  --link: #0052cc;
  --link-hover: #62c3ff;
  --chat-bg: #172a45;
  --chat-bubble-user: #0052cc;
  --chat-bubble-bot: #203459;
}

/* =========================
  Base Elements
  ========================= */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: var(--background);
  color: var(--text);
  font-size: var(--step-0);
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* =========================
  Layout: Header, Nav, Container, Footer
  ========================= */
.site-header {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.logo img {
  display: block;
  max-height: clamp(36px, 6vw, 56px);
  object-fit: contain;
}

.nav-controls,
.header-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1.1rem;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.main-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a {
  display: inline-block;
  text-decoration: none;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.active {
  background: var(--secondary);
  color: #fff;
}

.container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* =========================
  Hyperlinks
  ========================= */
p a,
ul li a,
ol li a,
p ol li a, 
p ul li a,
section a {
  color: var(--hyperlinks);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  background: transparent;
  transition: color var(--transition-speed), background-color var(--transition-speed);
}

p a:hover,
p a:focus,
ul li a:hover,
ul li a:focus,
ol li a:hover,
ol li a:focus,
p ol li a:hover,
p ol li a:focus,
p ul li a:hover,
p ul li a:focus,
section a:hover,
section a:focus {
  color: #fff;
  background: var(--primary);
  outline: none;
  text-decoration: none;
}

/* =========================
  Header Buttons & Theme Toggle
  ========================= */
#theme-toggle,
.header-buttons button {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  transition: transform var(--transition-speed);
}

#theme-toggle:hover,
.header-buttons button:hover {
  transform: scale(1.1);
}

#theme-toggle:hover {
  transform: rotate(20deg);
}

/* =========================
  Carousel
  ========================= */
.carousel {
  position: relative;
  overflow: hidden;
  max-height: 520px;
  min-height: 350px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  background: var(--surface);
  margin-bottom: 2rem;
}

.carousel-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 450ms ease;
}

.carousel-img.is-current {
  opacity: 1;
}

.carousel .caption {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.75rem;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  padding: .6rem .8rem;
  border-radius: 8px;
  font-size: .95rem;
}

.carousel .caption:empty,
.carousel .caption[hidden] {
  display: none;
}

.carousel-control {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, .6);
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 1.4rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--transition-speed), transform var(--transition-speed);
}

.carousel-control:hover {
  background: rgba(0, 0, 0, .55);
  transform: translateY(-50%) scale(1.05);
}

.carousel-control.prev {
  left: .5rem;
}

.carousel-control.next {
  right: .5rem;
}

.carousel-indicators {
  position: absolute;
  left: 0;
  right: 0;
  bottom: .5rem;
  display: flex;
  justify-content: center;
  gap: .35rem;
}

.carousel-indicators button {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, .55);
  cursor: pointer;
}

.carousel-indicators button[aria-current="true"] {
  background: #fff;
}

.carousel .caption,
.carousel .carousel-control,
.carousel .carousel-indicators {
  position: absolute;
  z-index: 2;
}

/* =========================
  Hero Section & Buttons
  ========================= */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hero-text {
  flex: 1 1 300px;
}

.hero-text h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 2.2rem;
  color: var(--primary);
}

.hero-text p {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text-light);
}

.hero-image {
  flex: 1 1 300px;
}

.tagline {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--secondary);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  font-weight: 600;
  border: none;
}

.btn:hover,
.btn:focus {
  background: var(--secondary);
  color: #fff;
}

.btn.secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  margin-top: 1rem;
}

.btn.secondary:hover,
.btn.secondary:focus {
  background: var(--primary);
  color: #fff;
}

/* =========================
  Features Section
  ========================= */
.features {
  margin-top: 3rem;
}

.features h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.feature-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.feature-item {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.feature-item h3 {
  margin-top: 0;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.feature-item p {
  flex-grow: 1;
  color: var(--text-light);
}

/* =========================
  News Section
  ========================= */
.news {
  margin-top: 3rem;
}

.news h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.news article {
  background: var(--surface);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.news article h3 {
  margin-top: 0;
  color: var(--primary);
}

.news article p {
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

/* =========================
  Footer
  ========================= */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 2rem 1rem;
  margin-top: 4rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.footer-col h3 {
  margin-top: 0;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.footer-col p,
.footer-col a {
  color: var(--footer-text);
  font-size: 0.9rem;
  text-decoration: none;
}

.footer-col a:hover {
  text-decoration: underline;
}

.footer-bottom {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--footer-text);
}

.footer-social-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-social-links .social-icon {
  width: 28px;
  height: 28px;
  display: inline-block;
  filter: brightness(0) invert(1);
  opacity: 0.9;
  transition: opacity var(--transition-speed), transform var(--transition-speed);
}

.footer-social-links a:hover .social-icon {
  opacity: 1;
  transform: translateY(-2px);
}

/* =========================
  Chatbot
  ========================= */
.chatbot-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 320px;
  max-height: 500px;
  background: var(--chat-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity var(--transition-speed), transform var(--transition-speed);
}

.chatbot-container.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.chatbot-header {
  background: var(--primary);
  color: #fff;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 1rem;
}

.chatbot-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.chatbot-messages {
  flex-grow: 1;
  padding: 0.5rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

.chatbot-messages .message {
  margin-bottom: 0.5rem;
  display: flex;
}

.chatbot-messages .message.user .bubble {
  margin-left: auto;
  background: var(--chat-bubble-user);
  color: #fff;
}

.chatbot-messages .message.bot .bubble {
  margin-right: auto;
  background: var(--chat-bubble-bot);
  color: var(--text);
}

.chatbot-messages .bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  max-width: 80%;
  line-height: 1.3;
}

.chatbot-form {
  display: flex;
  border-top: 1px solid var(--border);
}

.chatbot-form input {
  flex-grow: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  color: var(--text);
}

.chatbot-form button {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 0 1rem;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.chatbot-form button:hover {
  background: var(--secondary);
}

/* =========================
  Forms
  ========================= */
form {
  max-width: 640px;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

form label {
  display: block;
  margin-top: 1rem;
  font-weight: 600;
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

form textarea {
  resize: vertical;
}

form button,
form button[type="submit"] {
  margin-top: 1.5rem;
  padding: 0.6rem 1rem;
  background: var(--primary);
  border: none;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color var(--transition-speed);
  align-self: start;
}

form button[type="submit"]:hover,
form button:hover {
  background: var(--secondary);
}

/* Success and error messages */
.success-message {
  background: #e8f7ee;
  color: #155724;
  border: 1px solid #c3e6cb;
  padding: .75rem 1rem;
  border-radius: 6px;
}

.error-message {
  background: #fdeeee;
  color: #721c24;
  border: 1px solid #f5c6cb;
  padding: .75rem 1rem;
  border-radius: 6px;
}

/* =========================
  Tables
  ========================= */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

table th,
table td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
}

table th {
  background: var(--surface);
  color: var(--primary);
}

/* =========================
  Photo Grid & Lightbox
  ========================= */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
}

.photo-grid figure {
  margin: 0;
}

.photo-grid img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform .25s ease, box-shadow .25s ease;
}

.photo-grid img:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}

.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .75);
  padding: 2vw;
}

.lb-overlay.is-open {
  display: flex;
}

.lb-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lb-content img {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 8px;
}

.lb-close,
.lb-prev,
.lb-next {
  position: absolute;
  top: .5rem;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.lb-close {
  right: .5rem;
}

.lb-prev {
  left: .5rem;
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
}

.lb-hide-scroll {
  overflow: hidden;
}

/* =========================
  Sub-navigation & eLibrary
  ========================= */
.sub-nav ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sub-nav a {
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  transition: background-color var(--transition-speed);
}

.sub-nav a:hover,
.sub-nav a.active {
  background: var(--secondary);
  color: #fff;
}

/* eLibrary tidy styles */
.elibrary-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  padding-left: 0;
  list-style: none;
  margin: 0 0 1rem 0;
}

.elibrary-nav a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.elibrary-nav a:hover {
  border-bottom-color: currentColor;
}

.elibrary .elibrary-filter {
  margin: 1rem 0;
}

.elibrary .elibrary-filter input[type="search"] {
  max-width: 420px;
  width: 100%;
}

.lib-section {
  margin: 2rem 0;
}

.lib-section h2 {
  margin-bottom: .75rem;
}

.lib-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.lib-list li {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .35rem 0;
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}

body.dark .lib-list li {
  border-bottom-color: rgba(255,255,255,0.12);
}

.lib-list a {
  word-break: break-word;
}

.lib-meta {
  font-size: .85rem;
  opacity: .75;
}

.lib-note {
  margin-top: 2rem;
  font-size: .925rem;
  opacity: .85;
}

/* =========================
  Cards & Layout Switch
  ========================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

.cards[data-layout="grid"] {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.cards[data-layout="list"] {
  display: block;
}

.card {
  background: var(--surface, #0b1b33);
  border: 1px solid var(--border, #203459);
  border-radius: 10px;
  overflow: hidden;
}

.card-media-wrap {
  aspect-ratio: 16 / 9;
  background: rgba(255,255,255,.04);
}

.card-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 1rem;
}

.card-title {
  margin: 0 0 .5rem;
  font-size: 1.1rem;
  line-height: 1.3;
}

.card-meta {
  color: var(--text-light, #b0c7e3);
  font-size: .9rem;
  margin: 0 0 .5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.card-excerpt {
  margin: .5rem 0;
}

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border, #203459);
  font-size: .75rem;
}

.btn.card-btn {
  display: inline-block;
  padding: .5rem .8rem;
  border: 1px solid var(--border, #203459);
  border-radius: 6px;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
}

.btn.is-active {
  box-shadow: inset 0 0 0 9999px rgba(255,255,255,.06);
}

.tag {
  display:inline-block;
  margin-right:.35rem;
  opacity:.85;
  font-size:.8rem;
}

.sep {
  opacity:.5;
  padding: 0 .3rem;
}

.card.is-cancelled {
  opacity: .6;
  filter: grayscale(.5);
}

/* List layout */
.cards[data-layout="list"] .card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  margin-bottom: 1rem;
}

.cards[data-layout="list"] .card .card-media-wrap {
  height: 100%;
  aspect-ratio: auto;
  min-height: 120px;
}

.cards[data-layout="list"] .card .card-body {
  padding: .9rem 1rem;
}

/* Mobile: list collapses to vertical stack */
@media (max-width: 640px) {
  .cards[data-layout="list"] .card {
   grid-template-columns: 1fr;
  }
}

/* Layout switch bar */
.layout-switch {
  display: flex;
  gap: .4rem;
  align-items: center;
  margin: .8rem 0 1rem;
}

.layout-switch .btn {
  font-size: .9rem;
}

/* =========================
  Responsive
  ========================= */
@media (max-width: 1024px) {
  .header-inner {
   padding: 1rem;
   grid-template-columns: auto auto 1fr;
  }
  .carousel {
   max-height: 440px;
   min-height: 280px;
  }
  .logo img {
   height: 40px;
  }
  .photo-grid {
   grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 992px) {
  .header-inner {
   padding: 1rem;
  }
  .logo img {
   height: 40px;
  }
}

@media (max-width: 820px) {
  .header-inner {
   grid-template-columns: auto 1fr auto;
  }
  .nav-toggle {
   display: inline-block;
  }
  .main-nav {
   grid-column: 1 / -1;
   order: 3;
   width: 100%;
   background: var(--nav-bg);
   border-top: 1px solid var(--border);
   display: none;
  }
  .main-nav.is-open {
   display: block;
  }
  .main-nav ul {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 0.25rem;
   padding: 0.5rem 0.25rem;
  }
  .main-nav a {
   padding: 0.6rem;
  }
}

@media (max-width: 768px) {
  .carousel {
   max-height: 320px;
   min-height: 220px;
  }
  .carousel .caption {
   font-size: 0.9rem;
  }
  .hero {
   flex-direction: column;
  }
  .main-nav ul {
   flex-wrap: wrap;
   gap: 0.5rem;
   width: 100%;
   justify-content: flex-start;
  }
  .main-nav a {
   padding: 0.4rem 0.6rem;
  }
  .container {
   padding: 0 0.75rem;
  }
  .logo img {
   height: 36px;
  }
  .site-header {
   height: auto;
  }
  .header-inner {
   flex-wrap: wrap;
   gap: 0.5rem;
  }
  .photo-grid {
   grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .photo-grid {
   grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .footer-inner {
   grid-template-columns: 1fr;
  }
  .logo img {
   height: 34px;
  }
  .hero-text h1 {
   font-size: clamp(1.4rem, 5vw, 1.8rem);
  }
  .features h2,
  .news h2 {
   font-size: 1.4rem;
  }
}