/* ===================================================================
   BASE & RESET
   =================================================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* offset for sticky header */
}

html,
body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  background: transparent; /* allow background to show through */
  color: var(--text);
  line-height: var(--line-height-normal);
}

/* Fixed background layer with solid dark color */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
}


a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:visited {
  color: var(--link);
}

a.btn:not(.btn-secondary),
a.btn:not(.btn-secondary):visited,
a.btn:not(.btn-secondary):hover {
  color: white;
}

a:hover {
  color: var(--link-hover);
}

/* ===================================================================
   LAYOUT
   =================================================================== */

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-3);
}

/* Shared section wrapper/container pattern */
.section-wrapper {
  width: 100%;
  background: var(--overlay-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: var(--space-5) 0;
}

.section-container {
  max-width: var(--content-width-wide);
  margin: 0 auto;
  padding: clamp(var(--space-5), 8vw, var(--section-padding-max)) var(--space-3);
}


/* ===================================================================
   TYPOGRAPHY
   =================================================================== */

h1 {
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-2) 0;
}

h2 {
  font-size: var(--font-size-xl);
  margin: 0 0 var(--space-1) 0;
}


/* ===================================================================
   SHARED UTILITIES
   =================================================================== */

/* Logo theme switching - shared between brand and footer */
.logo-light {
  display: inline;
}

.logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .logo-light {
    display: none;
  }

  .logo-dark {
    display: inline;
  }
}

/* Manual theme overrides for logos */
html.theme-dark .logo-light {
  display: none;
}

html.theme-dark .logo-dark {
  display: inline;
}

html.theme-light .logo-light {
  display: inline;
}

html.theme-light .logo-dark {
  display: none;
}


/* ===================================================================
   COMPONENTS
   =================================================================== */

/* Brand
   ------------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 31px;
  width: auto;
  object-fit: contain;
}


/* Header
   ------------------------------------------------------------------- */

header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: var(--backdrop-blur-lg);
  background: var(--overlay-header);
  border-bottom: 1px solid var(--border);
}

header .wrap {
  position: relative;
  max-width: var(--content-width-wide);
}


/* Navigation
   ------------------------------------------------------------------- */

.nav {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-2);
}

.brand {
  justify-self: start;
}

.text-nav {
  justify-self: center;
}

.nav-cta {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  text-decoration: none;
  color: var(--text);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  white-space: nowrap;
}

.nav-cta:hover {
  color: var(--brand);
  background: var(--overlay-surface);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  color: var(--text);
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
}

.theme-toggle:hover {
  color: var(--brand);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: var(--icon-size-md);
  height: var(--icon-size-md);
}
/* Sun/moon visibility per theme lives in shared/css/components.css. */

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  color: var(--text);
  transition: color var(--transition-fast);
}

.hamburger:hover {
  color: var(--brand);
}

.hamburger .icon {
  width: var(--icon-size-md);
  height: var(--icon-size-md);
}

.text-nav {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.text-nav a {
  position: relative;
  text-decoration: none;
  color: var(--text);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.text-nav a:hover {
  color: var(--brand);
}

.text-nav a + a::before {
  content: "·";
  position: absolute;
  right: 100%;
  margin-right: calc(var(--space-4) / 2 - 0.25em);
  color: var(--muted);
  pointer-events: none;
}

.text-nav .mobile-only {
  display: none;
}


/* Buttons
   ------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  box-shadow: var(--shadow);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary,
.btn.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover,
.btn.btn-secondary:hover {
  background: var(--overlay-surface);
  border-color: var(--brand);
}

.btn-nav {
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-sm);
}

.btn.btn-full-width {
  width: 100%;
  justify-content: center;
}

/* Dark mode button text - make primary button text dark in dark mode */
@media (prefers-color-scheme: dark) {
  .btn:not(.btn-secondary),
  a.btn:not(.btn-secondary):visited,
  a.btn:not(.btn-secondary):hover {
    color: var(--bg);
  }
}

html.theme-dark .btn:not(.btn-secondary),
html.theme-dark a.btn:not(.btn-secondary):visited,
html.theme-dark a.btn:not(.btn-secondary):hover {
  color: var(--bg);
}

html.theme-light .btn:not(.btn-secondary),
html.theme-light a.btn:not(.btn-secondary):visited,
html.theme-light a.btn:not(.btn-secondary):hover {
  color: white;
}


/* Section intro text
   ------------------------------------------------------------------- */

.section-intro {
  text-align: center;
  max-width: var(--content-width-narrow);
  margin: 0 auto var(--space-3) auto;
  color: var(--muted);
  font-size: var(--font-size-lg);
}


/* Forms
   ------------------------------------------------------------------- */

.contact-form {
  margin-top: var(--space-2);
}

.form-group {
  margin-bottom: var(--space-2);
}

.form-group label {
  display: block;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-1);
  color: var(--text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.form-group textarea {
  resize: vertical;
  min-height: var(--space-6);
}

.form-status {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  display: none;
}

.form-status.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.form-status.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.form-status.show {
  display: block;
}


/* Footer
   ------------------------------------------------------------------- */

footer {
  margin-top: var(--space-6);
  color: var(--text);
  font-size: var(--font-size-sm);
  backdrop-filter: var(--backdrop-blur-lg);
  background: var(--overlay-footer);
  border-top: 1px solid var(--border);
}

.footer-content {
  max-width: var(--content-width-wide);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3) var(--space-3) var(--space-3);
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  align-items: flex-start;
}

.footer-left {
  flex: 1;
  max-width: 500px;
}

.footer-brand {
  display: inline-block;
  margin-bottom: var(--space-2);
}

.footer-brand img {
  height: 31px;
  width: auto;
  object-fit: contain;
}

.footer-tagline {
  margin: 0 0 var(--space-2) 0;
  line-height: var(--line-height-normal);
  color: var(--muted);
}

.footer-contact {
  margin: 0;
  color: var(--muted);
}

.footer-copyright {
  margin: var(--space-3) 0 0 0;
  color: var(--muted);
}

.footer-contact a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-contact a:hover {
  color: var(--brand);
}

.footer-right {
  display: flex;
  gap: var(--space-5);
}

.footer-links-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-links-group h3 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-tight);
  margin: 0 0 var(--space-1) 0;
  color: var(--muted);
}

.footer-links-group a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.footer-links-group a:hover {
  color: var(--brand);
}

.icon-external {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}


/* ===================================================================
   UTILITIES
   =================================================================== */

/* Focus styles */
.text-nav a:focus-visible,
.btn:focus-visible,
.theme-toggle:focus-visible,
.hamburger:focus-visible {
  outline: var(--outline-width) solid var(--accent);
  outline-offset: var(--outline-offset);
}

.icon {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  margin-top: 3px; /* optical alignment with text baseline */
}


/* ===================================================================
   MEDIA QUERIES
   =================================================================== */

/* Tablet and below - Show hamburger menu */
@media (max-width: 900px) {
  .nav {
    grid-template-columns: auto 1fr auto auto;
  }

  .nav-cta {
    display: none;
  }

  .hamburger {
    display: block;
    justify-self: end;
  }

  .text-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--overlay-menu);
    backdrop-filter: var(--backdrop-blur-lg);
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) 0;
    display: none;
    box-shadow: var(--shadow);
    z-index: calc(var(--z-sticky) - 1);
    justify-self: stretch;
    grid-column: 1 / -1;
  }

  .text-nav.active {
    display: flex;
  }

  .text-nav a {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-base);
    width: 100%;
    border-bottom: 1px solid var(--border);
  }

  .text-nav a + a::before {
    display: none;
  }

  .text-nav a:last-child {
    border-bottom: none;
  }

  .text-nav a:hover {
    background: var(--overlay-header);
  }

  .text-nav .mobile-only {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: var(--space-2);
  }

  /* Footer mobile layout */
  .footer-content {
    flex-direction: column;
    gap: var(--space-4);
  }

  .footer-left {
    max-width: 100%;
  }

  .footer-right {
    gap: var(--space-4);
  }
}

/* Skip navigation link (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-3);
  z-index: 9999;
  background: var(--brand);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.1s;
}
.skip-link:focus {
  top: var(--space-2);
}
