/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Theme variables (easy tuning) */
:root{
  --header-pad-vert-min: 0.45rem;
  --header-pad-vert-max: 1.0rem;
  --header-pad-horz-min: 0.75rem;
  --header-pad-horz-max: 2.5rem;

  --logo-min: 48px;
  --logo-max: 96px;

  --gap: 0.75rem;

  /* flame color variables (default light-mode values) */
  --flame-inner: rgba(255,50,50,0.08);
  --flame-outer: rgba(255,50,50,0.04);

  /* colors used by selects and controls */
  --panel-bg: rgba(255,255,255,0.96);
  --panel-text: #111;
  --btn-bg: #007acc;
  --btn-bg-hover: #0090e0;
  /* --nav-btn-dark-bg removed (unused) */
}

/* Global styles */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  font-size: 16px;               /* predictable rems */
  line-height: 1.6;
  color: var(--panel-text);
  background-color: #f8f9fa;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Dark mode: toggle by adding .dark-mode to <html> or <body> */
.dark-mode {
  color: #eee;
  background-color: #121212;
  /* flame color overrides */
  --flame-inner: rgba(30,140,255,0.08);
  --flame-outer: rgba(30,140,255,0.04);
  /* panel/button overrides */
  --panel-bg: rgba(10,10,10,0.45);
  --panel-text: #eee;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-bg-hover: rgba(255,255,255,0.09);
}

/* === Header (gradient) === */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to right, #1e90ff, #800080, #ff4500); /* your gradient preserved */
  color: white;

  /* responsive padding (small vertical space, comfortable horizontal) */
  padding:
    clamp(var(--header-pad-vert-min), 1.2vw, var(--header-pad-vert-max))
    clamp(var(--header-pad-horz-min), 3vw, var(--header-pad-horz-max));

  gap: var(--gap);
  box-sizing: border-box;

  /* avoid hard heights (lets content size naturally), but prevent extreme growth */
  max-height: 140px;
}

/* Dark-mode gradient — keep the same colors but reversed direction */
.dark-mode .header {
  background: linear-gradient(to left, #1e90ff, #800080, #ff4500);
}

/* === Logo group === */
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Logo wrapper so we can animate a flame-like background behind the image */
.logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 6px;
}

/* flame color vars in :root; dark overrides in .dark-mode */

/* Pseudo elements create layered fuzzy blobs that animate to mimic flame motion */
.logo-wrap::before,
.logo-wrap::after {
  content: '';
  position: absolute;
  inset: -6px -8px -10px -8px;
  border-radius: 16px;
  /* subtler blur and lower opacity to avoid heavy vignette */
  filter: blur(6px);
  opacity: 0.6;
  transform-origin: center bottom;
}
.logo-wrap::before { background: var(--flame-outer); animation: flame-swell 4.5s ease-in-out infinite; }
.logo-wrap::after { background: var(--flame-inner); animation: flame-flicker 2.4s ease-in-out infinite; }

@keyframes flame-swell {
  0% { transform: translateY(0) scale(1); opacity: 0.5; }
  50% { transform: translateY(-4px) scale(1.015); opacity: 0.72; }
  100% { transform: translateY(0) scale(1); opacity: 0.5; }
}

@keyframes flame-flicker {
  0% { transform: translateX(0) translateY(0) scale(1); opacity: 0.7; }
  25% { transform: translateX(-2px) translateY(-3px) scale(1.01); opacity: 0.78; }
  50% { transform: translateX(0) translateY(-4px) scale(1.02); opacity: 0.82; }
  75% { transform: translateX(2px) translateY(-3px) scale(1.01); opacity: 0.78; }
  100% { transform: translateX(0) translateY(0) scale(1); opacity: 0.7; }
}

/* Logo image — responsive, capped, scales well with zoom and viewport */
.logo img {
  height: clamp(var(--logo-min), 6vw, var(--logo-max)); /* scales between 48px and 96px */
  width: auto;
  display: block;
  object-fit: contain;
  /* Use separate image assets for theme color differences */
}

/* Animated burn-and-reveal for logo transitions between light/dark */
.site-logo{transition:opacity 420ms ease,transform 420ms ease;opacity:1;display:block}
.logo-wrap.burn::before,.logo-wrap.burn::after{animation:flame-burn 700ms ease-out forwards}
.logo-wrap.burn .site-logo{opacity:0;transform:translateY(-8px) scale(.98)}
.logo-wrap.reveal .site-logo{opacity:1;transform:none;transition-delay:160ms}

@keyframes flame-burn{0%{transform:translateY(0) scale(1);opacity:0.6}50%{transform:translateY(-8px) scale(1.12);opacity:1}100%{transform:translateY(-18px) scale(1.25);opacity:0}}

/* Site title next to logo */
.logo h1 {
  font-size: clamp(1.25rem, 2.5vw, 1.9rem);
  font-weight: 700;
  margin: 0;
  line-height: 1;
  white-space: nowrap; /* prevents wrapping into extra lines */
  letter-spacing: 0.2px;
  color: white; /* ensure title remains visible on gradient */
}

/* === Navigation === */
.nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* do not set height:100% — that can force children to stretch */
}

/* Buttons */
.nav-btn {
  background: var(--btn-bg);
  border: none;
  color: white;
  padding: 0.38rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.18s ease, transform 0.08s ease;
}

/* hover / focus */
.nav-btn:hover { background: var(--btn-bg-hover); transform: translateY(-1px); }
.nav-btn:focus { outline: 3px solid rgba(255,255,255,0.14); outline-offset: 2px; }

/* Specific styling for the theme toggle (keeps emoji visible and aligned) */
#theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* Dark-mode adjustments for buttons (readable contrast) */
.dark-mode .nav-btn {
  /* rely on variables for background; keep border/text adjustments for contrast */
  color: var(--panel-text);
  border: 1px solid rgba(255,255,255,0.06);
}
.dark-mode .nav-btn:hover {
  background: var(--btn-bg-hover);
}

/* === Main content === */
.content {
  flex: 1;           /* pushes footer to bottom */
  padding: 2rem;
  /* Ensure content text contrasts with the background in both themes */
  color: var(--panel-text);
}

/* Make sure headings, paragraphs, lists, and links inside content are readable */
.content h1, .content h2, .content h3, .content p, .content li, .content a {
  color: inherit;
}

/* Dark-mode link color (content text uses --panel-text) */
.dark-mode .content a { color: #9cd4ff; }

/* sections */
.section { display: none; }
.section.active { display: block; }

/* Make focused sections visually clear for keyboard users */
.section:focus { outline: 3px solid rgba(0,123,255,0.18); outline-offset: 6px; }

/* About grid */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.team-card {
  background: rgba(255,255,255,0.9);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.dark-mode .team-card {
  background: rgba(255,255,255,0.03);
  box-shadow: none;
}

/* Content panel used on error pages and sections to ensure readable contrast */
.content > .section {
  background: var(--panel-bg);
  color: var(--panel-text);
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 900px;
  margin: 1rem auto;
  box-shadow: 0 6px 18px rgba(20,30,40,0.08);
}

/* Ensure buttons/links inside a panel are visible */
.content > .section .nav-btn,
.content > .section a.nav-btn {
  background: var(--btn-bg);
  color: #fff;
}

/* === Footer (gradient preserved) === */
.footer {
  background: linear-gradient(to right, #1e90ff, #800080, #ff4500); /* preserved */
  color: white;
  text-align: center;
  padding: clamp(0.5rem, 1.0vw, 1rem);
  font-size: 0.9rem;
  box-sizing: border-box;
}

/* Dark-mode footer gradient reversed as before */
.dark-mode .footer {
  background: linear-gradient(to left, #1e90ff, #800080, #ff4500);
}

/* === Responsive small screens === */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: clamp(0.4rem, 2.5vw, 0.8rem) 0.75rem;
  }

  .logo h1 { font-size: 1.25rem; }

  .nav {
    margin-top: 0.6rem;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-btn {
    display: inline-flex;
    padding: 0.35rem 0.65rem;
    font-size: 0.95rem;
  }

  .logo img {
    height: clamp(40px, 8vw, 72px);
  }
}

/* Mobile interaction improvements */
/* Larger touch targets, remove tap highlight, and hint touch-action to reduce click delays */
.nav-btn,
.nav a.nav-btn,
.btn-primary,
.custom-select__button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Make form controls easier to tap on small screens */
@media (max-width: 600px) {
  .contact-form input[type="text"],
  .contact-form input[type="email"],
  .contact-form select,
  .contact-form textarea,
  .nav-btn,
  .btn-primary {
    font-size: 1.05rem;
    padding: 0.85rem 0.9rem;
    min-height: 44px; /* recommended minimum touch target height */
  }

  /* Make custom select appear as a bottom sheet on small screens for easier tapping */
  .custom-select__list {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 12px;
    z-index: 9999;
    margin-top: 0;
    border-radius: 12px;
    max-height: 48vh;
    overflow: auto;
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
    transform: translateY(8px);
    transition: opacity 180ms ease, transform 220ms ease;
  }
  .custom-select__list.is-open { transform: translateY(0); }

  /* Increase option spacing for easier tapping */
  .custom-select__option { padding: 1rem 0.9rem; font-size: 1.05rem; }
}

/* Ensure images scale properly within flexible layouts on mobile */
img { max-width: 100%; height: auto; display: block; }

/* Hero test area used on error pages: large logo and prominent title */
.hero-test {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
}
.hero-test .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.hero-test .logo-wrap img {
  width: 160px;
  height: 160px;
  max-width: none;
}
.hero-test .hero-title {
  font-size: clamp(1.25rem, 3vw, 2rem);
  margin: 0;
  text-align: center;
}

/* Debug outline utilities removed */

/* Buttons that are anchors behave like buttons visually */
.nav a.nav-btn, .nav-btn.btn-primary {
  text-decoration: none;
}

/* Contact form styles */
.contact-form {
  max-width: 760px;
  margin-top: 1rem;
  background: transparent;
}

.contact-form .form-row { margin-bottom: 0.9rem; display: flex; flex-direction: column; }
.contact-form label { font-weight: 600; margin-bottom: 0.3rem; }
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  background: white;
  color: var(--panel-text);
  width: 100%;
  font-size: 1rem;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  -webkit-appearance: none; /* unify select appearance across browsers */
  appearance: none;
}

.dark-mode .contact-form input,
.dark-mode .contact-form select,
.dark-mode .contact-form textarea {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--panel-text);
}

.contact-form input:focus, .contact-form textarea:focus, .contact-form select:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0,123,255,0.12);
  border-color: #007bff;
}

.contact-form textarea { resize: vertical; min-height: 120px; }

.btn-primary { background: #0069d9; }
.btn-primary:hover { background: #005bc1; transform: translateY(-1px); }

.form-status { margin-top: 0.6rem; color: #0b5; }
.dark-mode .form-status { color: #8fe3a3; }

/* visually-hidden helper */
.visually-hidden { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* Stronger native select + custom select styles (fix white-on-white) */
/* Ensure native option colors are explicit, and provide a styled JS listbox */
/* ------------------------------------------------------------------ */


/* Reinforce native select visuals for light/dark mode */
.contact-form select {
  background: rgba(245,247,249,1); /* light fallback */
  color: #111;
}
.dark-mode .contact-form select {
  background: rgba(20,20,20,0.9);
  color: #fff;
}

/* Many UAs ignore option styling; still provide explicit colors */
.contact-form select option {
  background: rgba(245,247,249,1);
  color: #111;
}
.dark-mode .contact-form select option {
  background: rgba(20,20,20,0.95);
  color: #fff;
}

/* If JS replaces native select with .custom-select, style it here */
.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
  margin-top: 0.25rem;
}
.custom-select__button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 1rem;
  text-align: left;
}
.custom-select__button::after {
  content: '\25BE'; /* down-pointing small triangle */
  margin-left: 0.6rem;
  opacity: 0.9;
  transition: transform 220ms ease;
}

/* --- dark mode variants --- */
/* dark mode for custom select is handled by mirroring .dark-mode onto the wrapper */
.custom-select.dark-mode .custom-select__button {
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid rgba(255,255,255,0.06);
}

.custom-select__list {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 60;
  margin-top: 6px;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(10,20,30,0.12);
  /* Slightly stronger backgrounds for readability */
  background: rgba(255,255,255,0.98); /* light-mode: almost solid white */
  color: var(--panel-text);
  max-height: 0; /* collapsed */
  overflow: hidden;
  padding: 0 6px; /* vertical padding handled by option padding */
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 260ms ease, opacity 200ms ease, transform 220ms ease, box-shadow 220ms ease;
  pointer-events: none;
}
.custom-select__list.is-open {
  max-height: 320px; /* allow expansion */
  opacity: 1;
  transform: translateY(0);
  padding: 6px 6px;
  pointer-events: auto;
}

.custom-select.dark-mode .custom-select__list {
  /* darker, less transparent background in dark mode for better contrast */
  background: rgba(12,12,12,0.88);
  color: var(--panel-text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

/* Visual highlight for selected option in the custom list */
/* Make the open list more visually distinct */
.custom-select__list.is-open { box-shadow: 0 12px 36px rgba(10,20,30,0.18); }

.custom-select__option {
  list-style: none;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--panel-text);
  background: transparent;
}

/* light-mode hover/active */
.custom-select__option:focus,
.custom-select__option:hover { outline: none; background: rgba(0,0,0,0.06); }

.custom-select__option.is-selected { font-weight: 600; background: rgba(200,210,220,0.9); }

/* dark-mode variants */
.custom-select.dark-mode .custom-select__option { color: var(--panel-text); }
.custom-select.dark-mode .custom-select__option:focus,
.custom-select.dark-mode .custom-select__option:hover { background: rgba(255,255,255,0.04); }
.custom-select.dark-mode .custom-select__option.is-selected { background: rgba(60,70,80,0.9); }

/* When JS hides native select, keep layout stable by matching sizes */
.contact-form select[aria-hidden="true"] { position: absolute !important; left: -9999px !important; }

/* class to hide native selects when replaced by custom UI (avoids inline styles so CSP is respected) */
.custom-select-hidden { display: none !important; }

/* when JS is enabled hide the native select if it has the helper class */
html.js .custom-select-hidden { display: none !important; }

/* small tweaks for mobile: make custom list full-width and easy to tap */
@media (max-width: 600px) {
  .custom-select__list { max-height: 320px; }
  .custom-select__option { padding: 0.9rem 0.8rem; }
}

/* animate arrow when open */
.custom-select__button[aria-expanded="true"]::after { transform: rotate(180deg); }

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .custom-select__list,
  .custom-select__button::after {
    transition: none !important;
  }
}
