/* NLA Home Automation — Main Stylesheet
   Incorporates /baseline-ui, /fixing-accessibility, /fixing-motion-performance patterns.
   Import order: tokens → reset → base → components → utilities
   ─────────────────────────────────────────────────────────────────────────── */

@import url('./tokens.css');
@import url('./components/nav.css');
@import url('./components/hero.css');
@import url('./components/sections.css');
@import url('./components/footer.css');
@import url('./components/forms.css');
@import url('./components/shop.css');

/* ═══════════════════════════════════════════════════════════════════════════
   /baseline-ui — Reset, typography scale, spacing, base components
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* ── Document ────────────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 100%; /* 16px base; we use px tokens on top */
}

body {
  background-color: var(--light);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-block-size: 100vh;
}

/* ── Base elements ───────────────────────────────────────────────────────── */
a {
  color: inherit;
  text-decoration: none;
}

img, video, svg {
  display: block;
  max-inline-size: 100%;
  height: auto;
}

ul, ol {
  list-style: none;
}

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

input, textarea, select {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  line-height: 1.15;
}

p {
  max-inline-size: 68ch; /* prevent runaway long lines */
}

/* ── Typography scale ────────────────────────────────────────────────────── */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }

/* ── Eyebrow / label type ────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: var(--track-widest);
  text-transform: uppercase;
  color: var(--green);
}
.eyebrow--muted { opacity: 0.7; }
.eyebrow--dark  { color: var(--dark-mute); }

/* ── Headline (Playfair Display) ─────────────────────────────────────────── */
.headline {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
}
.headline em {
  font-style: italic;
  color: var(--muted);
}
.headline--dark { color: var(--dark-text); }
.headline--dark em { color: var(--dark-mute); }

/* ── Body copy ───────────────────────────────────────────────────────────── */
.body-copy {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-mid);
  line-height: 1.85;
}
.body-copy--dark { color: var(--dark-mute); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  max-inline-size: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--track-wide);
  color: #fff;
  background-color: var(--green);
  padding-block: var(--space-3);
  padding-inline: var(--space-6);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.btn-primary:hover { background-color: var(--green-dk); }
.btn-primary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  background-color: var(--green-dk);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 300;
  letter-spacing: var(--track-wide);
  color: var(--muted);
  transition: color var(--transition-fast);
}
.btn-ghost:hover { color: var(--ink); }
.btn-ghost:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

.btn-ghost__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 20px;
  block-size: 20px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 10px;
  transition: border-color var(--transition-fast);
}
.btn-ghost:hover .btn-ghost__arrow { border-color: var(--ink-mid); }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--track-wider);
  text-transform: uppercase;
  color: var(--green);
  transition: gap var(--transition-fast);
}
.btn-link:hover { gap: var(--space-3); }
.btn-link:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }


/* ═══════════════════════════════════════════════════════════════════════════
   /fixing-accessibility — ARIA support, focus, contrast, keyboard patterns
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Skip link ───────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: var(--space-4);
  z-index: 9999;
  background-color: var(--green);
  color: #fff;
  padding-block: var(--space-2);
  padding-inline: var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: inset-block-start var(--transition-fast);
}
.skip-link:focus-visible {
  inset-block-start: var(--space-4);
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ── Global focus style (WCAG 2.4.11 — visible focus) ───────────────────── */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 1px;
}
/* Remove default outline only where we provide :focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}

/* ── Screen-reader only ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── High contrast mode support ──────────────────────────────────────────── */
@media (forced-colors: active) {
  .btn-primary {
    forced-color-adjust: none;
    border-color: ButtonText;
  }
  :focus-visible {
    outline-color: Highlight;
  }
}

/* ── Form accessibility ──────────────────────────────────────────────────── */
/* Error states — announced via aria-describedby */
.field-error {
  display: block;
  font-size: var(--text-sm);
  color: #C0392B;
  margin-block-start: var(--space-1);
  font-weight: 400;
}
/* WCAG 1.4.1 — don't rely on colour alone; use an icon prefix */
.field-error::before {
  content: '⚠ ';
  speak: never;
}

/* ── Minimum touch target (WCAG 2.5.5 — 44×44px) ───────────────────────── */
.btn-primary,
.btn-ghost,
.nav-link,
.nav-cta {
  min-block-size: 44px;
}
/* Inline .btn-link doesn't need min-height but needs padding for touch */
.btn-link {
  padding-block: var(--space-2);
}


/* ═══════════════════════════════════════════════════════════════════════════
   /fixing-motion-performance — Animations, lazy loading, CLS prevention
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Entrance reveal animations ──────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  will-change: auto; /* release after animation */
}

/* Stagger children of a reveal group */
.reveal-group > *:nth-child(1) { transition-delay: 0s; }
.reveal-group > *:nth-child(2) { transition-delay: 0.08s; }
.reveal-group > *:nth-child(3) { transition-delay: 0.16s; }
.reveal-group > *:nth-child(4) { transition-delay: 0.24s; }

/* ── Respect prefers-reduced-motion (WCAG 2.3.3) ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
    will-change: auto;
  }
}

/* ── Image CLS prevention — explicit aspect ratios ──────────────────────── */
/* All <img> tags MUST have width + height attributes set.
   This rule provides a safe fallback for images without explicit dimensions. */
img {
  aspect-ratio: attr(width) / attr(height);
}

/* CSS art containers — fixed aspect ratios prevent layout shift */
.art-hero    { aspect-ratio: 1 / 1; }
.art-phil    { aspect-ratio: 4 / 5; }
.art-project { aspect-ratio: 16 / 9; }

/* ── Font loading — prevent FOIT ─────────────────────────────────────────── */
/* Google Fonts uses font-display:swap. Fallback fonts are size-matched below. */
@font-face {
  font-family: 'Playfair Display Fallback';
  src: local('Georgia');
  size-adjust: 96%;
  ascent-override: 105%;
  descent-override: 26%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Jost Fallback';
  src: local('Helvetica Neue'), local('Arial');
  size-adjust: 98%;
}

/* ── Contain paint for heavy sections ────────────────────────────────────── */
.section--dark,
.hero,
.project-full {
  contain: paint;
}

/* ── Smooth scroll only when no motion preference ───────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Responsive utilities */
@media (max-width: 767px)  { .hide-mobile     { display: none !important; } }
@media (min-width: 768px)  { .hide-tablet-up  { display: none !important; } }
@media (min-width: 1024px) { .hide-desktop-up { display: none !important; } }
