/* ==========================================================================
   CraftX Tech — Base CSS
   Global Reset, Typography, Standout Floating Header, Footer & Utilities
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(var(--grid-dot-color) 1.2px, transparent 1.2px);
  background-size: 28px 28px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4, h5, h6, p {
  margin: 0;
  text-wrap: balance;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  user-select: none;
}

/* Accessibility Focus */
:focus-visible {
  outline: 2px solid var(--accent-brand);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Containers */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 480px) {
  .container,
  .container-narrow {
    padding: 0 16px;
  }
}

/* Sections */
section {
  padding: var(--space-4xl) 0;
  position: relative;
  width: 100%;
}

@media (max-width: 960px) {
  section {
    padding: 72px 0;
  }
}

@media (max-width: 600px) {
  section {
    padding: 56px 0;
  }
}

/* Typography Hierarchy */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(30px, 5.5vw, 56px);
  line-height: 1.12;
}

h2 {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.2;
  margin-bottom: 14px;
}

h3 {
  font-size: 20px;
  line-height: 1.35;
}

h4 {
  font-size: 15px;
  line-height: 1.4;
}

.section-head {
  margin-bottom: var(--space-2xl);
  width: 100%;
}

.section-head.center {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.section-head p {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.65;
}

@media (max-width: 600px) {
  .section-head {
    margin-bottom: 32px;
  }
  .section-head p {
    font-size: 15px;
  }
}

/* Technical Label / Section Badges */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-brand);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-medium);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
  max-width: 100%;
}

.section-label .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-success);
  box-shadow: 0 0 8px var(--status-success);
  display: inline-block;
  flex-shrink: 0;
  animation: pulseLive 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseLive {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 22px;
  min-height: 44px;
  border-radius: var(--radius-full);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid var(--btn-primary-border);
  box-shadow: var(--btn-primary-shadow);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--btn-primary-hover-bg);
  box-shadow: var(--btn-primary-hover-shadow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover-bg);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--accent-brand);
  border: 1px solid transparent;
  padding: 9px 16px;
}

.btn-ghost:hover {
  background: var(--bg-surface-subtle);
  color: var(--accent-brand-dark);
}

.btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.btn:hover svg {
  transform: translateX(2px);
}

/* ==========================================================================
   Standout Floating Architectural Header (.header-island)
   ========================================================================== */
.header-wrapper {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none; /* children enable pointer events */
  transition: all 0.25s ease;
}

.header-island {
  pointer-events: auto;
  width: 100%;
  max-width: 980px;
  height: 44px;
  background: var(--nav-island-bg);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  border: 1px solid var(--nav-island-border);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 16px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Subtle elevation when scrolled */
.header-wrapper.is-scrolled .header-island {
  border-color: var(--border-hover);
  box-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .header-wrapper {
    top: 8px;
    padding: 0 10px;
  }
  .header-island {
    height: 42px;
    padding: 0 4px 0 12px;
  }
}

/* Brand Logo */
.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.brand-link:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.brand-logo-img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.25));
}

.brand-logo-dark {
  display: block;
  height: 32px;
  width: auto;
  max-width: 180px;
  flex-shrink: 0;
}

.brand-logo-light {
  display: none;
  height: 32px;
  width: auto;
  max-width: 180px;
  flex-shrink: 0;
}

[data-theme="light"] .brand-logo-dark {
  display: none;
}

[data-theme="light"] .brand-logo-light {
  display: block;
}

.brand-logo-svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.brand-name {
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-name .x-accent {
  color: var(--accent-brand);
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .brand-badge {
    display: none;
  }
}

/* Desktop Navigation Links */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}

@media (max-width: 900px) {
  .nav-menu {
    display: none;
  }
}

/* Header Controls (Theme Toggle & CTA) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-elevated);
  transform: scale(1.05);
}

.theme-toggle-btn svg {
  width: 15px;
  height: 15px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hide/show sun or moon based on active theme */
[data-theme="dark"] .icon-moon {
  display: block;
}
[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: none;
}
[data-theme="light"] .icon-sun {
  display: block;
}
/* Fallback when no data-theme attribute is set (defaults to dark) */
:root:not([data-theme="light"]) .icon-moon {
  display: block;
}
:root:not([data-theme="light"]) .icon-sun {
  display: none;
}

.nav-cta-btn {
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  height: 30px;
  min-height: 30px;
  border-radius: var(--radius-full);
}

@media (max-width: 540px) {
  .nav-cta-btn {
    display: none;
  }
}

/* Mobile Toggle Hamburger */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  z-index: 1002;
}

.mobile-toggle span {
  display: block;
  height: 2px;
  width: 16px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.mobile-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.mobile-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 900px) {
  .mobile-toggle {
    display: flex;
  }
}

/* Mobile Drawer Overlay */
.mobile-drawer {
  position: fixed;
  top: 76px;
  left: 12px;
  right: 12px;
  background: var(--nav-island-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 20px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: auto;
  animation: drawerSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.mobile-drawer.is-open {
  display: flex;
}

@keyframes drawerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.mobile-drawer .nav-link {
  font-size: 15px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  width: 100%;
  justify-content: space-between;
}

.mobile-drawer-footer {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-drawer-cta {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  background: var(--bg-surface-base);
  border-top: 1px solid var(--border-subtle);
  padding: 64px 0 max(32px, env(safe-area-inset-bottom));
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
}

/* Footer Social Icons Bar */
.footer-social-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.footer-social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.footer-social-btn:hover {
  color: var(--accent-brand);
  border-color: var(--accent-brand);
  background: var(--bg-surface-subtle);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px var(--accent-brand-glow);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1.1fr 1.1fr;
  gap: 56px;
  margin-bottom: var(--space-3xl);
}

@media (max-width: 960px) {
  .footer-grid {
    grid-template-columns: 1.5fr 1fr;
    gap: 36px;
  }
}

@media (max-width: 600px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 36px;
  }
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
  max-width: 380px;
  margin-top: 16px;
}

.footer h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.footer ul {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer ul a {
  color: var(--text-secondary);
  display: inline-block;
  padding: 2px 0;
}

.footer ul a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 14px;
}

@media (max-width: 600px) {
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

.footer-social-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.footer-social-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-surface-elevated);
  transform: translateY(-2px);
}

/* ==========================================================================
   Scroll Reveal
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
