/* ============================================================
   DESIGN SYSTEM — Archesian Construction Ltd
   Base tokens overridden by Archesian brand layer
   ============================================================
   This file contains the complete design foundation:
   1. CSS Reset (modern)
   2. Custom Properties (design tokens)
   3. Typography scale & styles
   4. Grid & layout utilities
   5. Spacing utilities
   6. Color utilities
   7. Responsive breakpoints
   ============================================================ */

/* ──────────────────────────────────────────────────────────────
   1. MODERN CSS RESET
   Based on Andy Bell's modern reset + Josh Comeau's additions
   ────────────────────────────────────────────────────────────── */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scroll-behavior: auto; /* Lenis handles smooth scroll */
}

body {
  min-height: 100vh;
  line-height: var(--lh-normal);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text-on-dark);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Remove default list styles */
ul[role='list'],
ol[role='list'],
ul, ol {
  list-style: none;
}

/* Set core body defaults */
body, h1, h2, h3, h4, h5, h6, p,
figure, blockquote, dl, dd {
  margin: 0;
}

/* Set shorter line heights on headings and interactive elements */
h1, h2, h3, h4,
button, input, label {
  line-height: var(--lh-tight);
}

/* Balance text wrapping on headings */
h1, h2, h3, h4 {
  text-wrap: balance;
}

/* Improve paragraph readability */
p {
  text-wrap: pretty;
  max-width: 72ch;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

/* Make images easier to work with */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Inherit fonts for inputs and buttons */
input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@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;
  }
}

/* Remove button default styles */
button {
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
}

/* ──────────────────────────────────────────────────────────────
   2. DESIGN TOKENS (CSS Custom Properties)
   ────────────────────────────────────────────────────────────── */

:root {
  /* ── Color Palette ── */
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-tertiary: #161616;
  --bg-inverse: #FAFAFA;
  --bg-inverse-secondary: #F0F0F0;
  --bg-card: #111111;
  --bg-card-hover: #1A1A1A;

  --text-on-dark: #FAFAFA;
  --text-on-dark-secondary: #D4D4D4;
  --text-on-light: #0A0A0A;
  --text-on-light-secondary: #404040;
  --text-muted: #737373;
  --text-muted-light: #A3A3A3;

  --border-subtle-dark: #1F1F1F;
  --border-dark: #2A2A2A;
  --border-subtle-light: #E5E5E5;
  --border-light: #D4D4D4;

  /* Accent token, overridden by Archesian blueprint blue */
  --accent: #B8956A;
  --accent-hover: #CEAD87;
  --accent-active: #A37E55;
  --accent-muted: rgba(184, 149, 106, 0.15);

  /* Functional colors */
  --success: #4ADE80;
  --error: #F87171;
  --warning: #FBBF24;
  --info: #60A5FA;

  /* Overlays */
  --overlay: rgba(10, 10, 10, 0.85);
  --overlay-light: rgba(10, 10, 10, 0.5);
  --glass: rgba(10, 10, 10, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* ── Typography ── */
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Fluid type scale (clamp for responsive sizing) */
  --fs-display: clamp(3rem, 6vw + 1rem, 5.5rem);
  --fs-h1: clamp(2.25rem, 4.5vw + 0.5rem, 3.75rem);
  --fs-h2: clamp(1.75rem, 3vw + 0.5rem, 2.75rem);
  --fs-h3: clamp(1.375rem, 2vw + 0.25rem, 1.875rem);
  --fs-h4: clamp(1.125rem, 1.5vw, 1.375rem);
  --fs-body-lg: 1.125rem;
  --fs-body: 1rem;
  --fs-caption: 0.875rem;
  --fs-eyebrow: 0.75rem;
  --fs-small: 0.6875rem;

  /* Line heights */
  --lh-display: 1.05;
  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.6;
  --lh-loose: 1.8;

  /* Letter spacing */
  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.05em;
  --ls-eyebrow: 0.2em;
  --ls-ultra-wide: 0.3em;

  /* Font weights */
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ── Spacing (8px base grid) ── */
  --space-2xs: 0.25rem;   /* 4px */
  --space-xs: 0.5rem;     /* 8px */
  --space-sm: 1rem;       /* 16px */
  --space-md: 1.5rem;     /* 24px */
  --space-lg: 2rem;       /* 32px */
  --space-xl: 3rem;       /* 48px */
  --space-2xl: 4rem;      /* 64px */
  --space-3xl: 6rem;      /* 96px */
  --space-4xl: 8rem;      /* 128px */
  --space-5xl: 10rem;     /* 160px */
  --space-section: clamp(4rem, 10vw, 8rem);

  /* ── Layout ── */
  --max-width: 1440px;
  --content-width: 800px;
  --narrow-width: 640px;
  --gutter: clamp(1.5rem, 4vw, 3rem);
  --nav-height: 80px;
  --nav-height-scrolled: 64px;

  /* ── Motion / Easing ── */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 400ms;
  --duration-slow: 600ms;
  --duration-reveal: 900ms;
  --duration-page: 600ms;

  /* ── Borders & Radius ── */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px rgba(184, 149, 106, 0.15);

  /* ── Z-Index Scale ── */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-cursor: 600;
  --z-transition: 700;
  --z-max: 9999;
}


/* ──────────────────────────────────────────────────────────────
   3. TYPOGRAPHY
   ────────────────────────────────────────────────────────────── */

/* Display — Hero headlines */
.text-display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-tight);
  font-weight: var(--fw-regular);
}

/* H1 */
.text-h1,
h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  font-weight: var(--fw-regular);
}

/* H2 */
.text-h2,
h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  font-weight: var(--fw-regular);
}

/* H3 */
.text-h3,
h3 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: var(--lh-snug);
  font-weight: var(--fw-regular);
}

/* H4 */
.text-h4,
h4 {
  font-family: var(--font-body);
  font-size: var(--fs-h4);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
}

/* Body large */
.text-body-lg {
  font-size: var(--fs-body-lg);
  line-height: var(--lh-normal);
}

/* Body default */
.text-body {
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
}

/* Caption */
.text-caption {
  font-size: var(--fs-caption);
  line-height: var(--lh-normal);
  color: var(--text-muted);
}

/* Eyebrow — uppercase label */
.text-eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Eyebrow with accent */
.text-eyebrow--accent {
  color: var(--accent);
}

/* Small text */
.text-small {
  font-size: var(--fs-small);
  line-height: var(--lh-normal);
}

/* Lead paragraph — larger body for intros */
.text-lead {
  font-size: clamp(1.125rem, 1.5vw, 1.375rem);
  line-height: var(--lh-loose);
  color: var(--text-on-dark-secondary);
  max-width: 60ch;
}

/* Blockquote */
blockquote,
.text-quote {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: var(--lh-snug);
  font-style: italic;
  position: relative;
  padding-left: var(--space-lg);
  border-left: 2px solid var(--accent);
}

/* Strong emphasis */
strong, b {
  font-weight: var(--fw-semibold);
}

/* Links in content */
.content-area a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--duration-fast) ease;
}

.content-area a:hover {
  color: var(--accent-hover);
}

/* Selection */
::selection {
  background-color: var(--accent);
  color: var(--bg-primary);
}


/* ──────────────────────────────────────────────────────────────
   4. LAYOUT & GRID
   ────────────────────────────────────────────────────────────── */

/* Container — centered content with max-width and gutters */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Narrow container for text-heavy content */
.container--narrow {
  max-width: var(--content-width);
}

.container--xs {
  max-width: var(--narrow-width);
}

/* Full-bleed — breaks out of container */
.full-bleed {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}

/* Section — vertical section spacing */
.section {
  padding-block: var(--space-section);
}

.section--tight {
  padding-block: var(--space-2xl);
}

.section--loose {
  padding-block: var(--space-5xl);
}

/* Section with dark background */
.section--dark {
  background-color: var(--bg-primary);
  color: var(--text-on-dark);
}

/* Section with light background */
.section--light {
  background-color: var(--bg-inverse);
  color: var(--text-on-light);
}

/* Section with secondary dark background */
.section--secondary {
  background-color: var(--bg-secondary);
  color: var(--text-on-dark);
}

/* Auto grid — responsive grid that adapts columns automatically */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Auto-fit grid — columns adapt to available space */
.grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}

.grid--auto-sm {
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}

/* Asymmetric grid — editorial layout */
.grid--asymmetric {
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-xl);
}

.grid--asymmetric-reverse {
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-xl);
}

/* Flex utilities */
.flex {
  display: flex;
}

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

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

.flex--col {
  display: flex;
  flex-direction: column;
}

.flex--wrap {
  flex-wrap: wrap;
}

.flex--gap-sm {
  gap: var(--space-sm);
}

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

.flex--gap-lg {
  gap: var(--space-lg);
}

.flex--gap-xl {
  gap: var(--space-xl);
}

/* Stack — vertical spacing between children */
.stack > * + * {
  margin-top: var(--space-sm);
}

.stack--md > * + * {
  margin-top: var(--space-md);
}

.stack--lg > * + * {
  margin-top: var(--space-lg);
}

.stack--xl > * + * {
  margin-top: var(--space-xl);
}


/* ──────────────────────────────────────────────────────────────
   5. UTILITY CLASSES
   ────────────────────────────────────────────────────────────── */

/* Text alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Text colors */
.text-dark { color: var(--text-on-dark); }
.text-light { color: var(--text-on-light); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }

/* Background colors */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-inverse { background-color: var(--bg-inverse); }

/* Visibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.hidden { display: none !important; }

.visible-desktop {
  display: none;
}

.visible-mobile {
  display: block;
}

/* Divider */
.divider {
  width: 100%;
  height: 1px;
  background-color: var(--border-subtle-dark);
  border: none;
}

.divider--light {
  background-color: var(--border-subtle-light);
}

/* Spacer */
.spacer { height: var(--space-lg); }
.spacer--sm { height: var(--space-sm); }
.spacer--md { height: var(--space-md); }
.spacer--xl { height: var(--space-xl); }
.spacer--2xl { height: var(--space-2xl); }
.spacer--section { height: var(--space-section); }

/* Aspect ratios */
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-square { aspect-ratio: 1; }
.aspect-portrait { aspect-ratio: 3 / 4; }
.aspect-wide { aspect-ratio: 21 / 9; }
.aspect-photo { aspect-ratio: 4 / 3; }

/* Object fit */
.cover {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

/* Overflow */
.overflow-hidden { overflow: hidden; }

/* Relative positioning */
.relative { position: relative; }

/* Max width for readable text */
.max-w-prose { max-width: 72ch; }
.max-w-narrow { max-width: var(--narrow-width); }
.max-w-content { max-width: var(--content-width); }

/* Margin auto */
.mx-auto { margin-inline: auto; }
.mt-section { margin-top: var(--space-section); }


/* ──────────────────────────────────────────────────────────────
   6. RESPONSIVE BREAKPOINTS
   ────────────────────────────────────────────────────────────── */

/* Tablet (768px+) */
@media (min-width: 768px) {
  .visible-desktop {
    display: block;
  }

  .visible-mobile {
    display: none;
  }

  .grid--2-tablet {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  :root {
    --nav-height: 96px;
  }

  .grid--responsive-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--responsive-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid--responsive-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
  .grid--responsive-5 {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Mobile only (below 768px) */
@media (max-width: 767px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }

  .grid--asymmetric,
  .grid--asymmetric-reverse {
    grid-template-columns: 1fr;
  }

  .text-display {
    font-size: clamp(2.25rem, 8vw, 3.5rem);
  }

  .section {
    padding-block: var(--space-2xl);
  }
}

/* Tablet only (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
