/* Foundations & Compositions CSS — Phase 4 Production Foundation Integration */

/* ─── Self-Hosted Production Font Faces (OFL License) ─── */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/bricolage-grotesque-latin-variable.9fee080f.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/inter-latin-variable.dd8a4575.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/inter-latin-italic-variable.124b693f.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ─── Base Typography Layer ─── */
@layer ds.base {
  html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"]  { color-scheme: dark; }

  body {
    font-family: var(--ds-font-family-body);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ds-semantic-color-text-primary);
    background-color: var(--ds-semantic-color-background-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--ds-font-family-heading);
    font-weight: 600;
    color: var(--ds-semantic-color-text-primary);
    text-wrap: balance;
  }

  /* Selective Prose Wrapping */
  .ds-prose,
  .ds-body,
  .intro p,
  .article-content p,
  .case-study-copy p,
  .thesis + p,
  .lede,
  article p {
    text-wrap: pretty;
  }

  code, kbd, samp, pre {
    font-family: var(--ds-font-family-mono);
    font-size: 0.8125rem;
  }
}

/* ─── Semantic Typography Roles ─── */
@layer ds.components {
  .ds-display {
    font-family: var(--ds-font-family-heading);
    font-size: clamp(2rem, 1.6rem + 2vw, 3rem);
    font-weight: 600;
    line-height: 1.10;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }

  .ds-title {
    font-family: var(--ds-font-family-heading);
    font-size: clamp(1.375rem, 1.2rem + 0.88vw, 1.75rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }

  .ds-heading {
    font-family: var(--ds-font-family-heading);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.20;
    text-wrap: balance;
  }

  .ds-subheading {
    font-family: var(--ds-font-family-body);
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.45;
    text-wrap: auto;
  }

  .ds-body {
    font-family: var(--ds-font-family-body);
    font-size: 1rem;
    line-height: 1.55;
    text-wrap: pretty;
  }

  .ds-label, .ds-nav-link {
    font-family: var(--ds-font-family-body);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    text-wrap: auto;
  }

  .ds-caption, .ds-metadata {
    font-family: var(--ds-font-family-body);
    font-size: 0.75rem;
    line-height: 1.4;
    text-wrap: auto;
  }

  .ds-metadata {
    color: var(--ds-semantic-color-text-muted);
  }
}

/* ─── Canonical Page Frame & Composition Geometry ─── */
@layer ds.components {
  /* Outer Page Frame (Safe Area Aware) */
  .ds-page-frame {
    width: 100%;
    box-sizing: border-box;
    padding-inline-start: max(var(--ds-layout-page-margin-inline), env(safe-area-inset-left));
    padding-inline-end: max(var(--ds-layout-page-margin-inline), env(safe-area-inset-right));
    padding-block-start: var(--ds-density-page-start, var(--ds-space-10));
    padding-block-end: var(--ds-density-page-end, var(--ds-space-20));
  }

  /* Candidate D Canonical Portfolio Shell & Derived Composition Template */
  :root {
    --ds-layout-shell-template: 1fr;
  }

  .ds-portfolio-shell,
  .ds-grid-overlay__shell {
    width: 100%;
    margin-inline: auto;
    display: grid;
    grid-template-columns: var(--ds-layout-shell-template, 1fr);
    gap: var(--ds-layout-shell-gap);
    align-items: start;
    box-sizing: border-box;
  }

  /* Editorial Flow (600px - 899px) */
  @media (min-width: 600px) {
    :root {
      --ds-layout-shell-template: 1fr;
    }
    .ds-portfolio-shell,
    .ds-grid-overlay__shell {
      max-inline-size: var(--ds-layout-main-track);
      grid-template-columns: var(--ds-layout-shell-template);
    }
  }

  /* Compact Desktop Shell (900px - 1199px) */
  @media (min-width: 900px) {
    :root {
      --ds-layout-shell-template: var(--ds-layout-rail-start) minmax(0, 1fr);
    }
    .ds-portfolio-shell,
    .ds-grid-overlay__shell {
      max-inline-size: calc(var(--ds-layout-rail-start) + var(--ds-layout-shell-gap) + var(--ds-layout-main-track));
      grid-template-columns: var(--ds-layout-shell-template);
      gap: var(--ds-layout-shell-gap);
    }
    .ds-shell-end {
      display: none;
    }
  }

  /* Full Desktop Shell (>= 1200px) */
  @media (min-width: 1200px) {
    :root {
      --ds-layout-shell-template: var(--ds-layout-rail-start) minmax(0, 1fr) var(--ds-layout-rail-end);
    }
    .ds-portfolio-shell,
    .ds-grid-overlay__shell {
      max-inline-size: var(--ds-layout-shell-max);
      width: min(100%, var(--ds-layout-shell-max));
      margin-inline: auto;
      grid-template-columns: var(--ds-layout-shell-template);
      gap: var(--ds-layout-shell-gap);
    }
    .ds-shell-end {
      display: block;
    }
  }

  /* Navigation Start Rail */
  .ds-shell-start {
    grid-column: 1;
    position: static;
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-24);
  }

  @media (min-width: 900px) {
    .ds-shell-start {
      position: sticky;
      top: var(--ds-space-32);
    }
  }

  /* Main Content Track */
  .ds-shell-main {
    grid-column: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--ds-layout-section-gap);
  }

  /* Right Utility End Rail */
  .ds-shell-end {
    position: sticky;
    top: var(--ds-space-32);
    min-width: 0;
  }

  @media (min-width: 900px) {
    .ds-shell-main {
      grid-column: 2;
    }
  }

  @media (min-width: 1200px) {
    .ds-shell-end {
      grid-column: 3;
    }
  }

  /* Reading Measure Constraint */
  .ds-reading-measure {
    max-inline-size: min(100%, var(--ds-layout-reading-max));
    margin-inline-start: 0;
  }

  /* ─── WorkRow Structural Container Queries ─── */
  .ds-work-list {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-1);
  }

  .ds-work-row {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    box-sizing: border-box;
  }

  @container (min-width: 384px) {
    .ds-work-row {
      display: grid;
      grid-template-columns: var(--ds-work-row-date) minmax(0, 1fr);
      gap: var(--ds-semantic-space-component-tight);
      align-items: baseline;
    }
  }

  @container (min-width: 576px) {
    .ds-work-row {
      display: grid;
      grid-template-columns: var(--ds-work-row-date) minmax(0, 1fr) var(--ds-work-row-meta);
      gap: var(--ds-semantic-space-component-default);
      align-items: baseline;
    }
  }
}
