:root {
    /* ==== ETS Brand Palette — constants across themes ==== */
    --ets-blue: #0056ab;
    --ets-blue-light: #4a8fd1;
    --ets-blue-deep: #003d7a;
    --ets-teal: #107370;
    --ets-teal-light: #2a9691;
    --ets-teal-dark: #0a4e4c;

    /* Base neutrals — referenced by both themes */
    --black: #050608;
    --ink: #0d0f13;
    --ink-soft: #151821;
    --ink-card: #1a1e28;
    --bone: #ecebe4;
    --bone-warm: #f5f1e8;
    --bone-soft: #c9c8c0;
    --concrete: #8a8a82;
    --concrete-dark: #5a5a54;

    --serif: 'Fraunces', 'Times New Roman', serif;
    --sans: 'Inter Tight', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
  }

  /* ==== DARK theme (default) ==== */
  :root,
  [data-theme="dark"] {
    --bg:            var(--black);
    --bg-section:    var(--ink);
    --bg-elevated:   var(--ink-card);
    --fg:            var(--bone);
    --fg-muted:      var(--bone-soft);
    --fg-dim:        var(--concrete);

    --accent:        var(--ets-blue-light);     /* italic / emphasis color */
    --accent-deep:   var(--ets-blue);
    --accent-on-bg:  var(--ets-blue-light);
    --meta:          var(--ets-teal-light);     /* technical/mono labels */

    --line:          rgba(236,235,228,0.1);
    --line-mid:      rgba(236,235,228,0.18);
    --line-strong:   rgba(236,235,228,0.3);
    --line-brand:    rgba(0,86,171,0.4);
    --line-meta:     rgba(16,115,112,0.5);

    --grain-opacity: 0.08;
    --grain-blend:   overlay;

    --project-overlay: linear-gradient(to top, rgba(5,6,8,0.92) 0%, rgba(5,6,8,0.5) 45%, rgba(5,6,8,0.15) 100%);
    --nav-gradient:    linear-gradient(to bottom, rgba(5,6,8,0.92), rgba(5,6,8,0));
  }

  /* ==== LIGHT theme ==== */
  [data-theme="light"] {
    --bg:            var(--bone-warm);
    --bg-section:    #ffffff;
    --bg-elevated:   #ffffff;
    --fg:            #0a0d14;
    --fg-muted:      #4a5168;
    --fg-dim:        #8a8f9e;

    --accent:        var(--ets-blue);           /* darker blue on light bg */
    --accent-deep:   var(--ets-blue-deep);
    --accent-on-bg:  var(--ets-blue);
    --meta:          var(--ets-teal);           /* darker teal on light bg */

    --line:          rgba(10,13,20,0.1);
    --line-mid:      rgba(10,13,20,0.18);
    --line-strong:   rgba(10,13,20,0.3);
    --line-brand:    rgba(0,86,171,0.35);
    --line-meta:     rgba(16,115,112,0.5);

    --grain-opacity: 0.045;
    --grain-blend:   multiply;

    --project-overlay: linear-gradient(to top, rgba(10,13,20,0.92) 0%, rgba(10,13,20,0.5) 45%, rgba(10,13,20,0.15) 100%);
    --nav-gradient:    linear-gradient(to bottom, rgba(245,241,232,0.92), rgba(245,241,232,0));
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-weight: 400;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

  /* Subtle grain — theme-aware */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: var(--grain-blend);
  }

  .container { max-width: 1280px; margin: 0 auto; padding: 0 40px; }

  /* Page hero photo backdrop (services, projects, about) */
  .page-hero {
    position: relative;
    overflow: hidden;
  }
  .page-hero-photo {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center top;
    pointer-events: none;
  }
  .page-hero-photo::after {
    content: '';
    position: absolute;
    inset: 0;
  }
  [data-theme="dark"] .page-hero-photo::after {
    background:
      linear-gradient(to right, rgba(5,6,8,0.94) 0%, rgba(5,6,8,0.82) 40%, rgba(5,6,8,0.62) 100%),
      linear-gradient(to top, rgba(5,6,8,0.78) 0%, rgba(5,6,8,0.22) 55%);
  }
  [data-theme="light"] .page-hero-photo::after {
    background:
      linear-gradient(to right, rgba(8,12,20,0.90) 0%, rgba(8,12,20,0.74) 40%, rgba(8,12,20,0.48) 100%),
      linear-gradient(to top, rgba(8,12,20,0.68) 0%, rgba(8,12,20,0.14) 55%);
  }
  .page-hero-inner {
    position: relative;
    z-index: 1;
  }

  .mono {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
  }

/* ========== NAV ========== */

.nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    padding: 20px 40px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 40px;
    background: var(--nav-gradient);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--fg);
  }
  .logo-icon {
    width: 42px;
    height: 42px;
    display: block;
  }
  .logo-text {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 16px;
    letter-spacing: -0.01em;
    line-height: 1;
  }
  .logo-text .lt-sub {
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.16em;
    color: var(--meta);
    text-transform: uppercase;
    margin-top: 5px;
  }

  .nav-links {
    display: flex;
    gap: 36px;
    justify-content: center;
  }
  .nav-links a {
    color: var(--fg);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    position: relative;
    padding: 4px 0;
  }
  .nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--ets-blue-light);
    transition: width 0.3s ease;
  }
  .nav-links a:hover::after { width: 100%; }
  .nav-links a.is-active { color: var(--accent); }
  .nav-links a.is-active::after { width: 100%; }

  .nav-cta {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bone);
    background: var(--ets-blue);
    padding: 12px 20px;
    border: 1px solid var(--ets-blue);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s;
  }
  .nav-cta:hover {
    background: var(--ets-blue-light);
    border-color: var(--ets-blue-light);
    color: var(--bone);
  }
  .nav-cta .dot {
    width: 6px; height: 6px;
    background: var(--ets-teal-light);
    border-radius: 50%;
    animation: pulse 2s infinite;
  }

  /* ========== THEME TOGGLE ========== */
  .nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .theme-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line-strong);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg);
    transition: all 0.25s;
    position: relative;
    border-radius: 2px;
  }
  .theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
  .theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.5s cubic-bezier(0.2,0.6,0.2,1);
  }
  .theme-toggle .sun { display: none; }
  .theme-toggle .moon { display: block; }
  [data-theme="light"] .theme-toggle .sun { display: block; }
  [data-theme="light"] .theme-toggle .moon { display: none; }
  .theme-toggle:hover svg { transform: rotate(20deg); }

  @keyframes pulse {
    0%,100% { opacity: 1; }
    50% { opacity: 0.3; }
  }

footer {
    background: var(--black);
    color: var(--bone);
    padding: 60px 40px 30px;
    border-top: 1px solid var(--line);
  }
  .footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 60px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--line);
    max-width: 1280px;
    margin: 0 auto;
  }
  .footer-brand .logo { margin-bottom: 20px; color: var(--bone); }
  .footer-brand p {
    font-size: 13px;
    color: var(--bone-soft);
    line-height: 1.65;
    max-width: 360px;
  }
  .footer-col h4 {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--meta);
    margin-bottom: 20px;
  }
  .footer-col ul { list-style: none; }
  .footer-col li { padding: 5px 0; }
  .footer-col a {
    font-size: 13px;
    color: var(--bone);
    text-decoration: none;
    transition: color 0.2s;
  }
  .footer-col a:hover { color: var(--accent); }

  .footer-bottom {
    padding-top: 30px;
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--concrete);
    max-width: 1280px;
    margin: 0 auto;
  }

@media (max-width: 900px) {
  .nav { padding: 16px 20px; gap: 20px; }
  .nav-links { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
}
@media (max-width: 600px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
}
