/* ============================================================
   BASE - reset, page-shell grid, typography, links
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  max-width: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--ic-font-body);
  font-size: var(--ic-text-body);
  line-height: var(--ic-leading-body);
  font-weight: var(--ic-weight-body);
  color: var(--ic-text);
  background-color: var(--ic-bg);
  min-height: 100vh;
  overflow-x: clip;
  max-width: 100%;
}

/* Nothing may escape its container horizontally */
img, video, iframe, svg, picture, canvas, object, embed {
  max-width: 100%;
  height: auto;
}
img { display: block; }

pre, code, table { max-width: 100%; overflow-x: auto; }

p, h1, h2, h3, h4, h5, h6, li, blockquote, figcaption, dt, dd {
  overflow-wrap: break-word;
}

:where(ul:not([class]), ol:not([class])) { padding-left: 1.5em; }

/* ------------------------------------------------------------
   PAGE-SHELL GRID - the global containment rule (ported from
   chadlewine/chadworks). Every element on this list becomes a
   three-track grid: empty left, a centered content track at
   --ic-site-width, empty right. Direct children fall into the
   content track; a .full-bleed child spans all three tracks to
   reach the viewport edges. Recursive: a full-bleed section can
   itself be a page-shell and re-anchor its own children.
   This is the ONE width rule for the whole site.
   ------------------------------------------------------------ */
:where(
  .ic-main,
  .ic-shell,
  .ic-masthead,
  .ic-hero,
  .ic-band,
  .ic-footer
) {
  display: grid;
  grid-template-columns:
    [full-start] 1fr
    [content-start] var(--ic-site-width) [content-end]
    1fr [full-end];
  align-content: start;
}

:where(.ic-main, .ic-shell, .ic-masthead, .ic-hero, .ic-band, .ic-footer) > * {
  grid-column: content;
  min-width: 0;
}

:where(.ic-main, .ic-shell, .ic-masthead, .ic-hero, .ic-band, .ic-footer) > .full-bleed {
  grid-column: full;
}

/* Nested-shell promotion: a band inside main spans main's full track
   so its background bleeds edge-to-edge while its content re-anchors. */
:where(.ic-main, .ic-shell) > :where(.ic-hero, .ic-band, .ic-footer) {
  grid-column: full;
}

/* Content-column helpers - constrain a run of content without leaving
   the grid. Reading measure for post bodies, content measure for headers. */
.ic-measure-reading { max-width: var(--ic-reading-width); margin-inline: auto; width: 100%; }
.ic-measure-content { max-width: var(--ic-content-width); margin-inline: auto; width: 100%; }

.ic-main { padding-top: var(--ic-nav-height); }

/* Front page: hero sits under the transparent overlay header. */
.ic-has-overlay-header .ic-main { padding-top: 0; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--ic-text-strong);
  line-height: var(--ic-leading-tight);
  font-weight: var(--ic-weight-body);
}
h2, h3, h4 { text-wrap: balance; }

h1 { font-family: var(--ic-font-display); font-size: var(--ic-h1); letter-spacing: 0.01em; }
h2 { font-family: var(--ic-font-display); font-size: var(--ic-h2); letter-spacing: 0.01em; }
h3 { font-family: var(--ic-font-display); font-size: var(--ic-h3); }
h4 { font-family: var(--ic-font-ui);      font-size: var(--ic-h4); font-weight: var(--ic-weight-semibold); letter-spacing: -0.01em; }
h5 { font-family: var(--ic-font-ui);      font-size: 1.0625rem; font-weight: var(--ic-weight-semibold); }
h6 { font-family: var(--ic-font-ui);      font-size: var(--ic-text-small); font-weight: var(--ic-weight-semibold); text-transform: uppercase; letter-spacing: var(--ic-tracking-label); color: var(--ic-text-muted); }

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

a {
  color: var(--ic-link);
  text-decoration: none;
  transition: color var(--ic-fast) var(--ic-ease);
}
a:hover { color: var(--ic-link-hover); }

strong, b { font-weight: var(--ic-weight-semibold); color: var(--ic-text-strong); }

blockquote {
  margin: var(--ic-space-xl) 0;
  padding-left: var(--ic-space-lg);
  border-left: 3px solid var(--ic-accent);
  font-size: var(--ic-text-lede);
  line-height: var(--ic-leading-snug);
  color: var(--ic-text-strong);
}

hr {
  border: 0;
  height: 1px;
  background: var(--ic-rule);
  margin: var(--ic-space-2xl) 0;
}

code, pre, kbd, samp { font-family: var(--ic-font-mono); font-size: 0.9em; }
code {
  background: var(--ic-sage);
  padding: 0.15em 0.4em;
  border-radius: var(--ic-radius-sm);
  color: var(--ic-text-strong);
}
pre {
  background: var(--ic-olive);
  color: var(--ic-dark-text);
  padding: var(--ic-space-lg);
  border-radius: var(--ic-radius);
  overflow-x: auto;
  line-height: 1.6;
}
pre code { background: none; padding: 0; color: inherit; }

::selection { background: var(--ic-tint-green); color: var(--ic-text-strong); }

/* --- Accessibility --- */
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}
.ic-skip-link {
  position: absolute;
  left: -9999px;
  top: var(--ic-adminbar-offset);
  background: var(--ic-olive);
  color: var(--ic-dark-text);
  padding: var(--ic-space-sm) var(--ic-space-md);
  z-index: 999;
  border-radius: 0 0 var(--ic-radius-sm) 0;
}
.ic-skip-link:focus { left: 0; color: var(--ic-dark-text); }

:focus-visible {
  outline: 2px solid var(--ic-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
