/* Critical CSS - mobile-first (header, nav, skip link, container, basic variables)
   This file is now mobile-first. Desktop/tablet enhancements use min-width media queries. */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-primary-a: rgb(10 10 15 / 0.95);
  --bg-secondary: #151520;
  --text-primary: #fff;
  --text-secondary: #a0a0b0;
  --accent-1: #00f5ff;
  --accent-2: #b537f2;
  --accent-3: #22c55e; /* accessible green (AAA vs dark bg) */
  --card-bg: rgb(255 255 255 / 0.03);
  --border: rgb(255 255 255 / 0.1);
  --nav-border: rgb(255 255 255 / 0.3);
  --preload-disabled: none;
}

/* While the page is in 'preload' state, disable animations and transitions that can cause layout jumps */
body.preload *,
body.preload *::before,
body.preload *::after {
  animation: none;
  transition: none;
}

html,
body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
}

html {
  scroll-behavior: smooth;
}

.background-grid {
  position: fixed;
}

.site-header {
  position: sticky;
  top: 1rem;
  z-index: 1000;

  /* Reserve header vertical space to prevent CLS on desktop and mobile */
  min-height: 56px; /* base mobile header height */
}

.nav-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

/* Reserve final header spacing and sizes in critical CSS to avoid layout shift */
.logo-container {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem; /* match final site-title sizing to avoid jump */
  font-weight: 700;
  display: inline-block;
  text-decoration: none;
  line-height: 1.1;
  margin: 0;
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.1;
}

/* Ensure the site/logo image is constrained in critical CSS so it doesn't flash huge before full CSS loads */

/* Logo link container sizing */
.custom-logo-link {
  display: block;
  line-height: 0;
}

.custom-logo-link img,
.logo img,
.custom-logo-link svg,
.logo svg {
  height: 50px; /* fixed to prevent layout jump when media loads */
  max-height: 50px;
  width: auto;
  display: block;
}

/* Reserve space for the mobile menu / action buttons so header width doesn't shift when icons render */
.mobile-menu-toggle,
.search-toggle {
  min-width: 40px;
  min-height: 40px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.nav-container {
  /* Minimal structural rules for critical CSS to reserve layout & off-canvas box */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: fixed;
  inset: 5rem 0 0;
  background: var(--bg-primary);
  padding: 1.5rem;
  gap: 2rem;
  opacity: 0;
  visibility: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;

  /* keep overflow/height so it doesn't collapse while hidden */
  overflow-y: auto;
  height: 80vh;
  z-index: 1000; /* match header stacking */
}

/* Hero: reserve vertical space for above-the-fold so headline doesn't push content on load */
.hero {
  padding: 0 0 2rem 0; /* baseline spacing reserved */
}

.hero h1 {
  font-size: 2.25rem; /* mobile baseline */
  line-height: 1.1;
  margin: 1rem 0 0.5rem;
}

@media (min-width: 1025px) {
  /* Larger reserved sizes for desktop to avoid reflow when full CSS loads */
  .site-header {
    min-height: 72px;
  }

  .hero h1 {
    font-size: 3.5rem;
  }

  /* Desktop-only: make nav static/horizontal at wider viewports */
  .nav-container {
    visibility: visible;
    opacity: 1;
    flex-direction: row;
    position: static;
    border: unset;
    border-radius: unset;
  }
}

/* Basic nav/link sizing reserved in critical CSS to avoid layout jumps */
.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  list-style: none;
  margin: 0;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 1.05rem; /* slightly smaller base for initial paint */
  display: block;
  padding: 0.5rem 0;
}

/* Desktop: reserve horizontal nav layout space */
@media (min-width: 1025px) {
  .nav-links {
    flex-flow: row wrap;
    width: auto;
  }

  .nav-links a {
    padding: 0.5rem 1rem;
    font-size: 1.05rem;
  }
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

/* Header search: reserve vertical space for desktop open state to avoid jump when toggled */
.header-search {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
  opacity: 1;
  visibility: visible;
}

/* Skip link visible area reserved */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-1);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 8px 8px;
}

.screen-reader-text {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%); /* modern browsers */
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: 0;
}

/* Critical: single post essentials (minimal to avoid FOUC/layout shifts) */
.single-post-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem;
}

@media (min-width: 1024px) {
  .single-post-container {
    max-width: 1200px;
    padding: 2rem 1rem;
  }
}

.page-layout {
  display: block;
}

.entry-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
}

@media (min-width: 1024px) {
  .page .entry-card {
    padding: 2rem 4rem;
  }
}

.post-meta-single {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.featured-image img {
  width: 100%;
  max-width: 1000px;
  height: auto;
  display: block;
  border-radius: 8px;
  margin: 0 auto 2rem;
}

.entry-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition:
    transform 0.3s,
    border-color 0.3s,
    box-shadow 0.3s,
    background-color 0.3s;
  position: relative;
  display: flex;
  flex-direction: column;
}

.post-image,
.post-image-placeholder {
  width: 100%;
  height: 200px;
  display: block;
  object-fit: cover;
  background: linear-gradient(
    135deg,
    rgb(0 245 255 / 0.08),
    rgb(181 55 242 / 0.06)
  );
}

.post-image-placeholder {
  background-size: cover;
}

.page-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

@media (min-width: 1024px) {
  .page-container {
    max-width: 1200px;
  }
}

:where(
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  textarea,
  select
) {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s;
}

:where(
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  textarea,
  select
):focus {
  border-color: var(--accent-1);
  outline: none;
}
