/* ==========================================================================
   Design system - doderlein.com (component layer)
   Consumes tokens.css. This is the single source of truth for components.
   Pages use these classes; pages do NOT define their own component styles.
   ========================================================================== */

/* --- Reset --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: var(--radius) !important; /* zero radius is the design signature */
}
img,
svg,
video {
  display: block;
  max-width: 100%;
}
a {
  color: inherit;
}
ul,
ol {
  list-style: none;
}

/* --- Base ---------------------------------------------------------------- */
html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
/* Subtle dot-grid watermark behind all content */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(24, 24, 26, 0.045) 0.5px, transparent 0.5px);
  background-size: 8px 8px;
  z-index: -1;
  pointer-events: none;
}

/* --- Headings (variant B: Inter regular, sentence case, tight) ----------- */
h1,
h2,
h3 {
  font-family: var(--hd-family);
  font-weight: var(--hd-weight);
  text-transform: var(--hd-transform);
  letter-spacing: var(--hd-tracking);
  line-height: var(--hd-line);
}

/* --- Layout primitives --------------------------------------------------- */
.ds-section {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-10) var(--space-4);
  border-bottom: var(--border-width) solid var(--border-hair);
}
.ds-eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: var(--space-3);
}
.ds-h2 {
  font-size: var(--text-2xl);
}

/* Hero section */
.ds-hero {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}
.ds-hero h1 {
  font-size: var(--text-display);
  max-width: 16ch;
}
.ds-hero__cta {
  margin-top: var(--space-5);
}

/* Hero with a portrait media box (left of the text on desktop) */
.ds-hero__media {
  margin: 0 auto var(--space-5);
  max-width: 300px;
  aspect-ratio: 4 / 5;
  border: var(--border-width) solid var(--border-hair);
  background: var(--bg-surface);
  overflow: hidden;
}
.ds-hero__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}
@media (min-width: 880px) {
  .ds-hero--media {
    display: grid;
    grid-template-columns: minmax(300px, 0.78fr) 1fr;
    gap: var(--space-8);
    align-items: center;
  }
  .ds-hero--media .ds-hero__media {
    margin: 0;
    max-width: none;
  }
}
.ds-lead {
  font-size: var(--text-lg);
  color: var(--text-main);
  max-width: var(--reading);
  margin-top: var(--space-3);
}
.ds-prose {
  font-size: var(--text-base);
  color: var(--text-meta);
  max-width: var(--reading);
  margin-top: var(--space-2);
}
.ds-prose a {
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 1px solid var(--border-hair);
}
.ds-prose a:hover {
  border-bottom-color: var(--accent);
}

/* --- Buttons (THE single button definition) ------------------------------ */
/* Default size; .btn--sm is the smaller size (nav). Both share weight,
   letter-spacing and centering so they read as one component. Vertical
   centering comes from inline-flex + the inherited line-height (symmetric). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 24px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  border: var(--border-width) solid var(--border-strong);
  background: transparent;
  color: var(--text-main);
  transition: all var(--transition-fast);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}
.btn--outline:hover {
  background: var(--text-main);
  color: var(--bg-body);
}
.btn--sm {
  padding: 11px 18px;
}

/* --- Inline link --------------------------------------------------------- */
.ds-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border-hair);
  font-weight: 600;
  transition: border-color var(--transition-fast);
}
.ds-link:hover {
  border-bottom-color: var(--accent);
}

/* --- Header / nav -------------------------------------------------------- */
.ds-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 243, 239, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: var(--border-width) solid var(--border-hair);
}
.ds-nav__inner {
  max-width: var(--content);
  margin: 0 auto;
  height: var(--nav-height);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.ds-nav__brand {
  font-weight: 600;
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ds-nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-meta);
}
.ds-nav__links a:not(.btn) {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color var(--transition-fast);
}
.ds-nav__links a:not(.btn):hover {
  border-bottom-color: var(--accent);
}
.btn--sm {
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .ds-nav__links a:not(.btn) {
    display: none;
  }
  .ds-nav__inner {
    padding: 0 var(--space-3);
  }
}

/* --- Portfolio ledger ---------------------------------------------------- */
.ledger {
  border-top: var(--border-width) solid var(--border-strong);
}
.ledger__group-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  padding: var(--space-4) 0 var(--space-2);
  border-bottom: var(--border-width) solid var(--border-strong);
}
.row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 1.5fr auto;
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--border-hair);
  transition: background var(--transition-fast);
}
.row:hover {
  background: rgba(24, 24, 26, 0.025);
}
.row__name {
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.row__name a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.row:hover .row__name a {
  border-bottom-color: var(--accent);
}
.row__desc {
  color: var(--text-meta);
  font-size: var(--text-base);
}
.row__status {
  justify-self: end;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: var(--space-2) 0;
  }
  .row__status {
    justify-self: start;
  }
}

/* --- Service lead-in blocks --------------------------------------------- */
.services {
  display: grid;
  gap: var(--space-5);
  margin-top: var(--space-6);
}
@media (min-width: 760px) {
  .services {
    grid-template-columns: repeat(3, 1fr);
  }
}
.service__head {
  font-size: var(--text-lg);
  font-weight: var(--hd-weight-section);
  letter-spacing: -0.015em;
}
.service__body {
  color: var(--text-meta);
  font-size: var(--text-base);
  margin-top: var(--space-1);
}

/* --- Stats --------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-5);
}
@media (min-width: 760px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}
.stat__num {
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.stat__cap {
  font-size: var(--text-sm);
  color: var(--text-meta);
  margin-top: 4px;
}

/* --- Status tags --------------------------------------------------------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.tag {
  border: var(--border-width) solid var(--border-strong);
  padding: 5px 12px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--bg-surface);
}

/* --- Contact band (ink) -------------------------------------------------- */
.band {
  background: var(--bg-ink);
  color: var(--text-on-ink);
  padding: var(--space-12) var(--space-4);
}
.band__inner {
  max-width: var(--content);
  margin: 0 auto;
}
.band h2 {
  font-size: var(--text-2xl);
  color: var(--text-on-ink);
  max-width: 18ch;
}
.band__note {
  color: rgba(244, 243, 239, 0.6);
  max-width: var(--reading);
  margin-top: var(--space-3);
  font-size: var(--text-base);
}
.band__cta {
  margin-top: var(--space-5);
}

/* --- Footer -------------------------------------------------------------- */
.footer {
  background: var(--bg-ink);
  color: rgba(244, 243, 239, 0.6);
  padding: var(--space-6) var(--space-4) var(--space-8);
  border-top: var(--border-width) solid rgba(244, 243, 239, 0.12);
}
.footer__inner {
  max-width: var(--content);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
}
.footer a {
  color: var(--text-on-ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(244, 243, 239, 0.2);
}
.footer a:hover {
  border-bottom-color: var(--accent);
}
.footer__links {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* --- Motion (restrained; disabled under reduced-motion) ------------------ */
/* Reveal hidden-states are gated on html.js so that without JS (or if the
   script fails) all content is visible by default - no FOUC, no lock-out.
   A one-line head script adds the `js` class before first paint. */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(var(--reveal-distance));
    transition:
      opacity var(--reveal-duration) var(--ease-out),
      transform var(--reveal-duration) var(--ease-out);
    will-change: opacity, transform;
  }
  .js .reveal.is-visible {
    opacity: 1;
    transform: none;
  }

  /* Staggered children (ledger rows, service blocks, stat cells) */
  .js .reveal-stagger > * {
    opacity: 0;
    transform: translateY(calc(var(--reveal-distance) * 0.75));
    transition:
      opacity 0.5s var(--ease-out),
      transform 0.5s var(--ease-out);
  }
  .js .reveal-stagger.is-visible > * {
    opacity: 1;
    transform: none;
  }
  .js .reveal-stagger.is-visible > *:nth-child(1) {
    transition-delay: 0.02s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(2) {
    transition-delay: 0.07s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(3) {
    transition-delay: 0.12s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(4) {
    transition-delay: 0.17s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(5) {
    transition-delay: 0.22s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(6) {
    transition-delay: 0.27s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(7) {
    transition-delay: 0.32s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(8) {
    transition-delay: 0.37s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(9) {
    transition-delay: 0.42s;
  }
  .js .reveal-stagger.is-visible > *:nth-child(n + 10) {
    transition-delay: 0.47s;
  }

  /* Button: subtle lift on hover, settle on press */
  .btn:hover {
    transform: translateY(-2px);
  }
  .btn:active {
    transform: translateY(0);
  }
}

/* Button transition includes transform regardless (no-op under reduced motion) */
.btn {
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

/* Ledger row: status label warms toward ink on hover, alongside the bg tint */
.row__status {
  transition: color var(--transition-fast);
}
.row:hover .row__status {
  color: var(--text-meta);
}
