@layer reset, base, components, roles, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: light; scroll-behavior: smooth; }
  body, h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; }
}

@layer base {
  :root {
    --content-max: 76rem;
    --reading-max: 48rem;
    --page-pad: clamp(1.25rem, 4vw, 3rem);
    --space-1: .5rem;
    --space-2: .75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
    --space-7: clamp(4rem, 8vw, 7.5rem);
    --focus: 0 0 0 3px var(--surface), 0 0 0 6px var(--accent);
  }
  body {
    min-width: 20rem;
    overflow-x: hidden;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    text-rendering: optimizeLegibility;
  }
  a { color: inherit; text-decoration-thickness: .08em; text-underline-offset: .2em; }
  a:hover { color: var(--accent-strong); }
  :where(a, button, summary):focus-visible { border-radius: .15rem; outline: none; box-shadow: var(--focus); }
  h1, h2, h3 { color: var(--heading); font-family: var(--font-display); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking); text-wrap: balance; }
  h1 { max-width: 18ch; font-size: clamp(2.6rem, 7vw, 5.8rem); line-height: .99; }
  h2 { max-width: 26ch; font-size: clamp(2rem, 4.5vw, 3.5rem); line-height: 1.08; }
  h3 { font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.25; }
  p, li, dd { max-width: 72ch; }
  .site-shell { width: min(var(--content-max), calc(100% - (var(--page-pad) * 2))); margin-inline: auto; }
  .skip-link { position: fixed; z-index: 1000; top: .75rem; left: .75rem; padding: .75rem 1rem; transform: translateY(-180%); background: var(--accent); color: var(--accent-ink); font-weight: 800; text-decoration: none; }
  .skip-link:focus { transform: translateY(0); }
}

@layer components {
  .site-header { position: relative; z-index: 20; border-bottom: 1px solid var(--chrome-line); background: var(--chrome); color: var(--chrome-ink); }
  .header-inner { min-height: 5.5rem; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(1rem, 3vw, 2.5rem); }
  .site-brand { display: inline-flex; align-items: center; min-width: 0; color: inherit; text-decoration: none; }
  .site-brand-logo-frame { display: inline-flex; align-items: center; justify-content: flex-start; max-width: 100%; line-height: 1; }
  .site-brand-logo { flex: 0 0 auto; width: clamp(9rem, 18vw, 13.5rem); height: auto; max-height: 3.65rem; object-fit: contain; object-position: left center; }
  .primary-nav { display: flex; justify-content: flex-end; align-items: center; gap: clamp(.85rem, 2.4vw, 2rem); min-width: 0; }
  .primary-nav a { color: inherit; font-size: .76rem; font-weight: 700; letter-spacing: .045em; text-decoration: none; }
  .header-cta, .button, .button.primary { display: inline-flex; justify-content: center; align-items: center; min-height: 2.8rem; padding: .7rem 1.05rem; border: 1px solid var(--button-border); border-radius: var(--button-radius); background: var(--accent); color: var(--accent-ink); font-size: .76rem; font-weight: 850; letter-spacing: .035em; line-height: 1.2; text-align: center; text-decoration: none; }
  .header-cta:hover, .button:hover { background: var(--accent-strong); color: var(--accent-ink); transform: translateY(-1px); }
  .breadcrumb-bar { border-bottom: 1px solid var(--line); background: var(--surface-raised); }
  .breadcrumbs { min-height: 3rem; display: flex; align-items: center; gap: .65rem; overflow: hidden; color: var(--muted); font-size: .72rem; white-space: nowrap; }
  .breadcrumbs span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .role-summary { width: min(var(--content-max), calc(100% - (var(--page-pad) * 2))); margin: clamp(1.5rem, 4vw, 2.5rem) auto 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--surface-raised); box-shadow: var(--shadow-soft); }
  .role-summary span { min-width: 0; padding: 1rem 1.2rem; border-right: 1px solid var(--line); }
  .role-summary span:last-child { border-right: 0; }
  .role-summary small, .role-summary strong { display: block; }
  .role-summary small { margin-bottom: .2rem; color: var(--muted); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; }
  .role-summary strong { color: var(--heading); font-size: .8rem; line-height: 1.35; }
  .page-content { min-height: 60vh; padding: clamp(2.25rem, 5vw, 4.5rem) 0 var(--space-7); }
  .content-fragment { width: min(var(--content-max), calc(100% - (var(--page-pad) * 2))); margin-inline: auto; }
  .content-fragment > div, .content-fragment > article, .content-fragment > .resources-hub, .content-fragment > .seo-article { display: grid; gap: clamp(1.25rem, 3vw, 2rem); }
  .content-fragment :is(.page-hero, .article-hero), .content-fragment > div > header, .content-fragment > div > div > header { position: relative; isolation: isolate; overflow: hidden; padding: clamp(2rem, 7vw, 6.5rem); border: 1px solid var(--hero-line); border-radius: var(--hero-radius); background: var(--hero-bg); color: var(--hero-ink); box-shadow: var(--shadow-hero); }
  .content-fragment :is(.page-hero, .article-hero)::before, .content-fragment > div > header::before, .content-fragment > div > div > header::before { content: ""; position: absolute; z-index: -1; inset: 0; opacity: var(--hero-pattern-opacity); background: var(--hero-pattern); pointer-events: none; }
  .content-fragment :is(.page-hero, .article-hero) h1, .content-fragment > div > header h1, .content-fragment > div > div > header h1 { color: inherit; }
  .content-fragment :is(.page-hero, .article-hero) p, .content-fragment > div > header p, .content-fragment > div > div > header p { margin-top: 1rem; color: var(--hero-muted); font-size: clamp(1rem, 1.6vw, 1.18rem); }
  .content-fragment .eyebrow, .content-fragment .resource-type, .content-fragment .article-meta { color: var(--accent); font-family: var(--font-meta); font-size: .7rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
  .content-fragment .lede { max-width: 62ch; }
  .content-fragment :where(section, .article-toc, .editorial-note, footer.editorial-note) { padding: clamp(1.5rem, 4vw, 3.5rem); border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--surface-raised); box-shadow: var(--shadow-soft); }
  .content-fragment section > :where(h2, header) + * { margin-top: 1rem; }
  .content-fragment section > * + * { margin-top: 1rem; }
  .content-fragment ul, .content-fragment ol { padding-left: 1.35rem; }
  .content-fragment li + li { margin-top: .7rem; }
  .content-fragment dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--line); }
  .content-fragment dl > div { padding: 1.25rem; background: var(--surface-soft); }
  .content-fragment dt { color: var(--heading); font-weight: 850; }
  .content-fragment dd { margin-top: .4rem; color: var(--muted); }
  .resource-card-grid, .category-grid, .related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
  .resource-card, .category, .related-card { position: relative; min-height: 14rem; padding: 1.4rem; border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--card-bg); }
  .resource-card h3, .category h3, .related-card h3 { margin-top: 1.25rem; }
  .resource-card p, .category p, .related-card p { margin-top: .8rem; color: var(--muted); }
  .resource-card .text-link { display: inline-block; margin-top: 1.25rem; color: var(--accent-strong); font-weight: 850; }
  .article-toc { border-left: var(--toc-border); background: var(--toc-bg); }
  .article-toc h2 { font-size: 1.05rem; }
  .article-toc ol { margin-top: 1rem; columns: 2; column-gap: 2.5rem; }
  .article-toc li { break-inside: avoid; font-size: .86rem; }
  .callout, .article-callout { margin: 1.5rem 0; padding: 1.25rem 1.4rem; border-inline-start: .3rem solid var(--accent); border-radius: 0 var(--card-radius) var(--card-radius) 0; background: var(--callout-bg); }
  .callout h3, .article-callout h3 { font-size: 1.05rem; }
  .comparison-table { max-width: 100%; overflow-x: auto; border-radius: var(--card-radius); box-shadow: inset 0 0 0 1px var(--line); }
  table { width: 100%; min-width: 40rem; border-collapse: collapse; background: var(--surface-raised); font-size: .9rem; }
  th, td { padding: 1rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
  th { background: var(--table-head); color: var(--heading); font-family: var(--font-meta); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
  details { border-top: 1px solid var(--line); }
  details:last-child { border-bottom: 1px solid var(--line); }
  summary { position: relative; padding: 1.15rem 2rem 1.15rem 0; color: var(--heading); cursor: pointer; font-weight: 800; list-style: none; }
  summary::-webkit-details-marker { display: none; }
  summary::after { content: "+"; position: absolute; right: .25rem; color: var(--accent-strong); font-size: 1.2rem; }
  details[open] summary::after { content: "–"; }
  details > p { padding: 0 0 1.25rem; color: var(--muted); }
  .cta-panel, .content-fragment section.cta, .content-fragment section[id$="help"] { background: var(--cta-bg); color: var(--cta-ink); border-color: var(--cta-line); }
  .cta-panel h2, .content-fragment section.cta h2, .content-fragment section[id$="help"] h2 { color: inherit; }
  .cta-panel p, .content-fragment section.cta p, .content-fragment section[id$="help"] p { color: var(--cta-muted); }
  .editorial-note { color: var(--muted); font-size: .82rem; }
  .editorial-note code { overflow-wrap: anywhere; }
  .site-footer { border-top: 1px solid var(--chrome-line); background: var(--footer); color: var(--footer-ink); }
  .footer-grid { display: grid; grid-template-columns: minmax(16rem, 2fr) repeat(2, minmax(9rem, 1fr)); gap: clamp(2rem, 5vw, 5rem); padding-block: clamp(3rem, 7vw, 6rem); }
  .footer-brand p { margin-top: 1rem; color: var(--footer-muted); font-size: .8rem; }
  .footer-grid section { display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; }
  .footer-grid section h2 { margin-bottom: .35rem; color: var(--footer-heading); font-family: var(--font-meta); font-size: .67rem; letter-spacing: .14em; text-transform: uppercase; }
  .footer-grid section a { color: var(--footer-muted); font-size: .78rem; text-decoration: none; }
  .footer-bottom { min-height: 4rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-top: 1px solid var(--chrome-line); color: var(--footer-muted); font-size: .65rem; letter-spacing: .05em; }
}

@layer roles {
  .layout-guide .guide-fragment { width: min(67rem, calc(100% - (var(--page-pad) * 2))); }
  .layout-guide .guide-fragment > .seo-article { grid-template-columns: minmax(0, 1fr); }
  .layout-guide .guide-fragment :where(section, footer.editorial-note) { width: min(100%, var(--reading-max)); margin-inline: auto; }
  .layout-guide .guide-fragment :where(.article-hero, .article-toc, .related-resources, .faq-section) { width: 100%; }
  .layout-hub .hub-fragment section { padding-block: clamp(2rem, 5vw, 4.5rem); }
  .layout-service .service-fragment { width: min(72rem, calc(100% - (var(--page-pad) * 2))); }
  .layout-service .service-fragment section section { padding: 1.25rem; background: var(--surface-soft); box-shadow: none; }
  .layout-service .service-fragment ol > li::marker { color: var(--accent-strong); font-weight: 900; }
}

@layer utilities {
  [aria-disabled="true"] { color: var(--muted); cursor: not-allowed; text-decoration: none; }
  @media (max-width: 56rem) {
    .header-inner { grid-template-columns: minmax(0, 1fr) auto; }
    .primary-nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; padding-bottom: 1rem; }
    .role-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .role-summary span:nth-child(2) { border-right: 0; }
    .role-summary span:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
  }
  @media (max-width: 40rem) {
    :root { --page-pad: 1rem; }
    .site-brand-logo { width: 8.25rem; }
    .header-cta { max-width: 9.5rem; }
    .primary-nav a { white-space: nowrap; }
    .role-summary { grid-template-columns: 1fr; }
    .role-summary span { border-right: 0; border-bottom: 1px solid var(--line); }
    .role-summary span:last-child { border-bottom: 0; }
    .content-fragment :is(.page-hero, .article-hero), .content-fragment > div > header, .content-fragment > div > div > header { padding: 2rem 1.25rem; }
    .content-fragment :where(section, .article-toc, .editorial-note, footer.editorial-note) { padding: 1.35rem 1.15rem; }
    .article-toc ol { columns: 1; }
    .footer-grid { grid-template-columns: 1fr; }
    .footer-brand { grid-column: auto; }
    .footer-bottom { align-items: flex-start; flex-direction: column; padding-block: 1rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  }
  @media print {
    .site-header, .site-footer, .breadcrumb-bar, .skip-link { display: none; }
    body { background: white; color: black; }
    .content-fragment, .role-summary { width: 100%; }
  }
}
