/* Base styles — resets, typography, layout primitives.
   Built on tokens.css (loaded by base.njk).
*/

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4) 0;
  line-height: var(--leading-tight);
  color: var(--color-accent);
  letter-spacing: -0.015em;
}

p { margin: 0 0 var(--space-4) 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: var(--color-bg-subtle);
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
  color: var(--color-primary-dark);
}

.container {
  width: 100%;
  max-width: var(--container-max, 1200px);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ----------------------------------------------------------------- *
 *  Header (top navigation)
 * ----------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: box-shadow var(--duration-base) var(--ease-out), background var(--duration-base) var(--ease-out);
}
.site-header.is-scrolled {
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.95);
}
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  min-height: var(--header-height, 64px);
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

/* Brand block — explicitly pinned to the TOP-LEFT corner of the
   header. Three things guarantee that at every viewport:

   1. The parent `.nav` uses `align-items: flex-start` so its children
      sit at the top of the row, not vertically centered.
   2. `.nav-brand` itself uses `align-items: flex-start` so the logo
      and text are top-aligned with each other.
   3. `margin-right: auto` pushes the nav-list / CTA to the right
      edge, so the brand always owns the left half of the row.

   Text inside is `text-align: left`; the column container is
   `align-items: flex-start` so two stacked lines (title / sub) are
   flush-left instead of stretched. */
.nav-brand {
  display: inline-flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--space-3);
  margin: 0 auto 0 0;
  padding: 0;
  text-align: left;
  color: var(--color-accent);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  text-decoration: none;
  letter-spacing: -0.005em;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 50%;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand-logo {
  display: inline-flex;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  /* Top-anchor the logo so it lines up with the first line of text. */
  margin-top: 2px;
  position: relative;
}
.nav-brand-logo__img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
/* When the custom logo image fails to load, the JS swaps the
   src to the bundled default. The .nav-brand-logo--fallback class
   is added so we can style that path differently (no border
   radius, no shadow) and the bundled jpg shows through cleanly. */
.nav-brand-logo--fallback .nav-brand-logo__img {
  border-radius: 0;
  box-shadow: none;
}
/* Brand text — left-aligned, top-anchored column. The logo sits to the
   left at the same top baseline; both lines of text are flush-left so
   long brand names don't drift toward the center. */
.nav-brand-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  line-height: 1.15;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  gap: 1px;
}
.nav-brand-text .title {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: left;
}
.nav-brand-text .sub {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: left;
}
.nav-brand-fallback {
  display: none;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  text-align: left;
}

/* ---- Responsive: keep the brand top-left across all viewports. ---- */

/* Large desktops (≥1280px): brand can be a bit larger and own more
   horizontal real estate. */
@media (min-width: 1280px) {
  .nav-brand {
    max-width: 45%;
    gap: var(--space-4);
  }
  .nav-brand-logo {
    width: 40px;
    height: 40px;
  }
  .nav-brand-text .title {
    font-size: var(--text-lg);
  }
}

/* Tablet (≤1024px): tighten gap, slightly smaller logo. */
@media (max-width: 1024px) {
  .nav-brand {
    max-width: 55%;
    gap: var(--space-3);
  }
  .nav-brand-logo {
    width: 34px;
    height: 34px;
  }
}

/* Small tablet / large phone (≤768px): drop to compact sizing. */
@media (max-width: 768px) {
  .nav {
    gap: var(--space-2) var(--space-3);
  }
  .nav-brand {
    gap: var(--space-2);
    max-width: 60%;
  }
  .nav-brand-logo {
    width: 32px;
    height: 32px;
  }
  .nav-brand-text .title {
    font-size: var(--text-sm);
  }
  .nav-brand-text .sub {
    font-size: 10px;
  }
}

/* Phone (≤480px): drop the subtitle to free up horizontal space; keep
   the title top-left and the logo pinned to the corner. */
@media (max-width: 480px) {
  .nav {
    gap: var(--space-2);
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
  }
  .nav-brand {
    gap: var(--space-2);
    max-width: 70%;
  }
  .nav-brand-logo {
    width: 28px;
    height: 28px;
    margin-top: 1px;
  }
  .nav-brand-text .title {
    font-size: var(--text-sm);
    max-width: 60vw;
  }
  .nav-brand-text .sub {
    display: none;
  }
}

/* Very small phones (≤360px): the brand keeps the top-left corner at
   the smallest practical size. */
@media (max-width: 360px) {
  .nav-brand {
    max-width: 75%;
  }
  .nav-brand-logo {
    width: 24px;
    height: 24px;
  }
  .nav-brand-text .title {
    font-size: var(--text-xs);
  }
}

.nav-list {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list li a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition:
    color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}
@media (hover: hover) {
  .nav-list li a:hover {
    color: var(--color-text);
    background: var(--color-bg-subtle);
    text-decoration: none;
  }
  .nav-list li a:not([aria-current="page"]):hover::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -2px;
    transform: translateX(-50%);
    width: 18px;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: var(--radius-full);
    opacity: 0.5;
  }
}
.nav-list li a[aria-current="page"] {
  color: var(--color-primary);
}
.nav-list li a[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  width: 18px;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--radius-full);
}
.nav-list .nav-cta { margin-left: var(--space-2); }
.nav-list .nav-cta-btn { padding: 0 var(--space-4); height: 36px; color: var(--color-text-inverse); }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-toggle:hover { background: var(--color-bg-subtle); }

@media (max-width: 880px) {
  .nav-toggle { display: inline-flex; }
  .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3);
    box-shadow: var(--shadow-lg);
    display: none;
    gap: 0;
    align-items: stretch;
  }
  .nav-list.is-open { display: flex; }
  .nav-list li { width: 100%; }
  .nav-list li a { width: 100%; padding: var(--space-3) var(--space-4); }
  .nav-list li a[aria-current="page"]::after { display: none; }
  .nav-list li a[aria-current="page"] { background: var(--color-bg-subtle); }
  .nav-list .nav-cta { margin-left: 0; margin-top: var(--space-2); }
  .nav-cta-btn { width: 100%; }
}

.site-footer { font-family: var(--font-sans); }

main {
  min-height: 60vh;
}

/* Reveal-on-scroll animation (used by /js/site.js) */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 600ms var(--ease-out),
    transform 600ms var(--ease-out);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal[data-delay="100"] { transition-delay: 100ms; }
.reveal[data-delay="200"] { transition-delay: 200ms; }
.reveal[data-delay="300"] { transition-delay: 300ms; }
.reveal[data-delay="400"] { transition-delay: 400ms; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}