/**
 * Shared Styles for Header, Footer, and Common Components
 * Include this in all pages to ensure consistent styling
 */

/* --- Core Variables --- */
:root {
  --bg-base: #292929;
  --bg-gradient: linear-gradient(180deg, #292929 0%, #1f1f1f 100%);
  --text: #f5f5f5;
  --muted: #cfcfcf;
  --faint: #a0a0a0;
  --border: rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.22);
  --accent: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(255, 255, 255, 0.06);
  --risk-high: #f87171;
  --safe: #4ade80;
  
  --maxw: 1120px;
  --padX: clamp(18px, 6vw, 48px);
  --padY: clamp(18px, 6vw, 44px);
  --sectionY: clamp(80px, 15vh, 160px);
  --header-height: 70px;
}

/* --- Reset & Base --- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

a, button {
  touch-action: manipulation;
}

body {
  margin: 0;
  background: var(--bg-base);
  background: var(--bg-gradient);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, .brand { color: var(--accent); letter-spacing: -0.02em; }
h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.1; margin: 0 0 24px 0; }
h2 { font-size: clamp(24px, 4vw, 36px); margin: 0 0 20px 0; }
h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px 0; }
p { margin: 0 0 16px 0; }
.lead { font-size: clamp(18px, 2.5vw, 22px); color: var(--muted); max-width: 65ch; line-height: 1.5; }
.sublead { font-size: 16px; color: var(--muted); line-height: 1.6; }
.kicker { color: var(--faint); text-transform: uppercase; font-size: 11px; font-weight: 600; letter-spacing: 0.15em; margin-bottom: 12px; display: block; }
.mono { font-family: 'IBM Plex Mono', monospace; }

/* --- Layout Utilities --- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--padX); }
section { padding: var(--sectionY) 0; }
hr.dim { border: 0; border-top: 1px solid var(--border); margin: clamp(60px, 10vh, 100px) 0; opacity: 0.5; }

/* --- Header --- */
header {
  position: relative;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  min-height: 70px;
  background-color: #292929;
  border-bottom: none; /* No border on mobile */
  display: flex;
  align-items: center;
  width: 100%;
}

/* Only sticky on desktop where it works reliably */
@media (min-width: 768px) {
  header {
    position: sticky;
    background-color: rgba(41, 41, 41, 0.95);
    border-bottom: 1px solid var(--border);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

.header-inner {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  font-size: 16px;
  color: var(--text);
}

.nav-desktop {
  display: none;
  gap: 24px;
}

.nav-desktop a {
  color: var(--faint);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-desktop a:hover,
.nav-desktop a.active {
  color: var(--text);
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-icons-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  opacity: 0.8;
  transition: opacity 0.2s;
}

.action-icon:hover {
  opacity: 1;
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* --- Language Switcher --- */
.lang-switcher {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.lang-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.lang-btn svg {
  transition: transform 0.2s;
}

.lang-switcher.open .lang-btn svg {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 100px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 200;
  overflow: hidden;
}

.lang-switcher.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: block;
  padding: 10px 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}

.lang-option:hover {
  background: var(--card-hover);
  color: var(--text);
}

.lang-option.active {
  color: var(--text);
  background: var(--card-bg);
}

/* --- Mobile Nav Toggle --- */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 102;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: transform 0.2s, opacity 0.2s;
}

/* --- Mobile Menu --- */
.mobile-menu {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: 0;
  background: var(--bg-base);
  overflow: hidden;
  transition: height 0.3s ease-in-out;
  border-bottom: none; /* No border when closed */
  z-index: 99;
}

.mobile-menu.is-open {
  height: auto;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border); /* Only show border when open */
}

.mobile-menu a {
  display: block;
  padding: 16px var(--padX);
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .nav-toggle { display: none; }
  .mobile-menu { display: none; }
}

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--text);
  color: var(--bg-base);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 16px;
}

/* --- Back to Top Button --- */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, background 0.2s, transform 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}

@media (max-width: 600px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }
}

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border);
  padding: 48px 0;
  margin-top: var(--sectionY);
  color: var(--faint);
  font-size: 13px;
}

.footer-flex {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links a {
  color: inherit;
  text-decoration: none;
  margin-left: 20px;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-hash {
  font-size: 10px;
  opacity: 0.4;
  margin-top: 8px;
  word-break: break-all;
  line-height: 1.4;
  transition: opacity 0.2s;
}

.footer-hash:hover {
  opacity: 1;
}

@media (max-width: 600px) {
  .footer-flex {
    flex-direction: column;
    text-align: center;
  }
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .footer-links a {
    margin-left: 0;
  }
}

/* --- Focus States (Accessibility) --- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* --- Mobile Header Optimizations --- */
@media (max-width: 480px) {
  .header-inner {
    gap: 12px;
  }
  .brand {
    font-size: 14px;
    white-space: nowrap;
  }
  .actions {
    gap: 10px;
  }
  .action-icons-row {
    display: flex;
    gap: 10px;
  }
}

/* --- Buttons --- */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  width: auto;
  text-align: center;
}

.btn-primary {
  background: var(--text);
  color: var(--bg-base);
  border: 1px solid var(--text);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-primary:hover {
  background: #fff;
  transform: translateY(-1px);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--text);
}

.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-style: dashed;
}

@media (max-width: 480px) {
  .btn-group {
    flex-direction: column;
  }
}

/* --- Cards --- */
.grid-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: 12px;
  transition: background 0.2s, transform 0.2s;
}

.card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

@media (max-width: 600px) {
  .grid-features {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card {
    padding: 24px;
  }
}

/* --- Hero --- */
.hero {
  padding-top: clamp(80px, 15vh, 140px);
  padding-bottom: clamp(40px, 8vh, 80px);
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
