/* ============================================================
   MECHASH — Global Design System
   Cyber-Industrial Dark Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@300;400;500;700&display=swap');

/* ── Custom Properties ─────────────────────────────────── */
:root {
  /* Theme 8 - Cyber-Industrial V3 (The Refined Hybrid) */
  --bg-base: #0B1A24;
  /* A sophisticated middle ground between charcoal and midnight blue */
  /* T3 - Deep Charcoal */
  --bg-card: #015366;
  /* T4 - Deep Sea Teal (Subtle color shift) */
  --bg-card-alt: #1a4d59;
  --bg-nav: rgba(11, 26, 36, 0.9);

  --accent-teal: #54ACBF;
  /* T2 - Vibrant Cyan (Grid & Tech Lines) */
  --bg-energy: #7A4428;
  /* Slightly deeper Copper */
  /* T5 - Industrial Copper (Atmospheric Fog) */
  --bg-energy-alt: #1E5272;
  /* Slightly deeper Steel Blue */
  /* T2 - Steel Blue (Secondary Fog Energy) */

  --accent-cyan: #26658C;
  /* T2 - Steel Blue */
  --accent-teal-glow: rgba(84, 172, 191, 0.3);

  --cta-mint: #B6F9C9;
  /* T0 - Original Mint (Max Contrast for CTAs) */
  --cta-mint-dark: #54ACBF;
  --cta-mint-glow: rgba(182, 249, 201, 0.25);

  --text-body: #A7EBF2;
  /* T2 - Ice Blue (High Readability) */
  --text-heading: #FBE4D8;
  /* T1 - Peach White (Warm Pop) */
  --text-muted: #88A4B0;
  /* Brighter Slate Teal for metadata and labels */
  /* T4 - Muted Teal */
  --text-faint: #4A5C6A;
  /* Visible Dark Slate for footer and placeholders */

  --border-color: rgba(84, 172, 191, 0.25);
  --border-glow: rgba(182, 249, 201, 0.3);
  --grid-major: rgba(84, 172, 191, 0.15);
  --grid-minor: rgba(84, 172, 191, 0.05);

  /* Glassmorphism */
  --glass-bg: rgba(15, 35, 55, 0.18);
  /* Max translucency for a high-end spectral look */
  --glass-border: rgba(167, 209, 210, 0.25);
  /* Brightened slightly to define the edge */
  --glass-blur: 30px;
  /* Deeper blur to compensate for lower opacity */
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 5rem;

  /* Typography */
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  --text-7xl: 4.5rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(8, 126, 139, 0.1) inset;
  --shadow-glow: 0 0 30px rgba(8, 126, 139, 0.3);
  --shadow-mint: 0 0 20px rgba(182, 249, 201, 0.3);
  --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(8, 126, 139, 0.2);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.6s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-body);
  background-color: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

body::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    /* Major Grid (Solid - Darkened) */
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    /* Minor Grid (Faint) */
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  background-position: -1px -1px;
  filter: blur(1.5px);
  /* Increased blur to soften the grid lines */
  opacity: 0.4;
  /* Reduced opacity for a more subtle technical background */
}

main {
  flex: 1 0 auto;
}

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

a {
  color: var(--accent-teal);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--cta-mint);
}

ul,
ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input,
textarea,
select {
  font-family: inherit;
}

/* ── Typography ─────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-heading);
}

h1 {
  font-size: clamp(var(--text-4xl), 6vw, var(--text-7xl));
}

h2 {
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
}

h3 {
  font-size: clamp(var(--text-xl), 2.5vw, var(--text-2xl));
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-teal);
}

.text-mint {
  color: var(--cta-mint);
}

.text-heading {
  color: var(--text-heading);
}

/* ── Glassmorphism ─────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.glass-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-hover);
}

/* ── Content Blocks Layout ─────────────────────────── */
.content-block {
  margin-bottom: var(--space-xl);
  max-width: 1000px;
}

/* Sizing */
.block--sm {
  width: 33.33%;
  min-width: 280px;
}

.block--md {
  width: 66.66%;
  min-width: 320px;
}

.block--lg {
  width: 100%;
}

/* Alignment & Magazine Wrapping */
.align-left {
  float: left;
  margin-right: var(--space-xl);
  margin-bottom: var(--space-md);
}

.align-right {
  float: right;
  margin-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

.align-center {
  margin-left: auto;
  margin-right: auto;
  display: block;
  float: none;
  clear: both;
}

/* Clearfix for non-wrapping blocks */
.clearfix::after {
  content: "";
  clear: both;
  display: table;
}

/* Reset wrapping for headers or major sections */
h1,
.divider {
  clear: both;
}

/* Headers inside content blocks should wrap around floats */
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  clear: none;
}

/* Markdown Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-family: var(--font-body);
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--glass-border);
  padding: 12px 16px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-card-alt);
  color: var(--accent-teal);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
}

.markdown-body tr:nth-child(even) {
  background: var(--glass-bg);
}

@media (max-width: 768px) {

  .block--sm,
  .block--md {
    width: 100%;
    float: none;
    margin-left: 0;
    margin-right: 0;
  }
}

/* ── Section Layout ─────────────────────────────────────── */
.section {
  padding: var(--space-3xl) var(--space-xl);
  scroll-margin-top: 80px;
}

.section--sm {
  padding: var(--space-2xl) var(--space-xl);
  scroll-margin-top: 80px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-teal);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-label::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent-teal);
}

.section-title {
  color: var(--text-heading);
  margin-bottom: var(--space-md);
}

.section-subtitle {
  color: var(--text-muted);
  font-size: var(--text-lg);
  max-width: 600px;
  margin-bottom: var(--space-2xl);
  line-height: 1.6;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-2xl);
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header .section-title {
  margin-bottom: 0;
  line-height: 1;
}

/* ── Utility ────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xl);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xl);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(8, 126, 139, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(8, 126, 139, 0.3);
}

.tag--firmware {
  background: rgba(8, 126, 139, 0.15);
  color: var(--accent-teal);
  border-color: rgba(8, 126, 139, 0.3);
}

.tag--hardware {
  background: rgba(50, 103, 113, 0.15);
  color: #76c9d6;
  border-color: rgba(50, 103, 113, 0.4);
}

.tag--software {
  background: rgba(182, 249, 201, 0.1);
  color: var(--cta-mint);
  border-color: rgba(182, 249, 201, 0.25);
}

/* ── Dividers ───────────────────────────────────────────── */
.divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: var(--space-2xl) 0;
}

/* ── Scroll Reveal ──────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* ── Page Header (inner pages) ──────────────────────────── */
.page-header {
  padding: calc(80px + var(--space-3xl)) var(--space-xl) var(--space-2xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(8, 126, 139, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Footer ────────────────────────────────────────────── */
footer {
  background: var(--bg-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: var(--space-2xl) var(--space-xl);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-2xl);
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: var(--space-xl);
}

.footer-brand .logo {
  font-size: var(--text-xl);
  margin-bottom: var(--space-md);
}

.footer-brand p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: 280px;
}

.footer-col h5 {
  color: var(--text-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.footer-col ul li {
  margin-bottom: var(--space-sm);
}

.footer-col ul li a {
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-col ul li a:hover {
  color: var(--cta-mint);
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-bottom p {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.social-links {
  display: flex;
  gap: var(--space-md);
}

.social-links a {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.social-links a:hover {
  border-color: var(--accent-teal);
  color: var(--cta-mint);
  background: rgba(8, 126, 139, 0.1);
}

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

  .footer-grid {
    grid-template-columns: 1.2fr 1fr 1fr 1fr;
    gap: var(--space-xl);
  }
}

@media (max-width: 768px) {
  :root {
    --space-3xl: 3rem;
    --space-2xl: 2rem;
  }

  .container {
    padding: 0 var(--space-lg);
  }

  .section, .section--sm {
    padding-left: 0;
    padding-right: 0;
  }

  .section--sm {
    padding-top: 6rem;
  }

  .section > .container, 
  .section--sm > .container {
    display: flex;
    flex-direction: column;
  }

  .section-label { order: 1; }
  
  .section-header {
    display: contents;
  }

  .section-header .section-title {
    order: 2;
    margin-bottom: var(--space-lg);
  }

  #featured-builds-grid,
  #recent-logs-grid,
  .slider-wrapper {
    order: 3;
  }

  .section-header .btn {
    order: 5;
    margin-top: var(--space-lg);
    width: 100%;
    justify-content: center;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xl);
  }

  .footer-brand {
    grid-column: 1 / -1;
    margin-bottom: var(--space-sm);
  }

  .footer-col h5 {
    font-size: var(--text-xs);
    margin-bottom: var(--space-sm);
  }

  .footer-col ul li {
    margin-bottom: var(--space-xs);
  }

  .footer-col ul li a {
    font-size: var(--text-xs);
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
}

/* ── Background Switcher (Dev Tools) ────────────────────── */
#bg-switcher {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 27, 46, 0.9);
  border: 1px solid var(--accent-teal);
  padding: 12px;
  border-radius: 8px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.switcher-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-teal);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.switcher-btn {
  background: rgba(8, 126, 139, 0.1);
  border: 1px solid rgba(8, 126, 139, 0.3);
  color: var(--text-body);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-mono);
  text-align: left;
  transition: all 0.2s ease;
}

.switcher-btn:hover {
  background: rgba(8, 126, 139, 0.2);
  border-color: var(--accent-teal);
}

.switcher-btn.active {
  background: var(--accent-teal);
  color: white;
  border-color: var(--accent-teal);
  box-shadow: 0 0 10px var(--accent-teal-glow);
}