/* hugo-kit: base and block styles. Uses only the token contract (lib/contract.mjs, set by the site's
   assets/theme.css) and the optional tokens below, which a theme may override. Two layers: the kit's, then the
   site's (theme file and site stylesheet), so site rules beat kit rules without !important. Derived tones come from
   the tokens via color-mix(). Layouts are intrinsic (grid auto-fit) where they can be; where a block needs a
   breakpoint, it uses a container query (every .kit-block is a container), and page-level media queries use the
   fixed values 40rem and 64rem (custom properties do not work in media queries). */
@layer kit, site;

@layer kit {
  :root {
    --radius: 12px;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;
    --measure: 68ch;
    --kit-width: 1080px;
  }

  body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
  }

  .kit-skip {
    position: absolute;
    left: -9999px;
    &:focus { left: var(--space-3); top: var(--space-3); z-index: 10; padding: var(--space-2) var(--space-3);
      background: var(--color-surface); color: var(--color-text); border-radius: var(--radius); }
  }

  :focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }

  .kit-block {
    container-type: inline-size;
    max-width: var(--kit-width);
    margin-inline: auto;
    padding: var(--space-5) 20px;
    color: var(--color-text);
    font-family: var(--font-body);
    & h1, & h2 { font-family: var(--font-display); line-height: 1.1; margin: 0 0 var(--space-3); overflow-wrap: break-word; hyphens: auto; }
    & h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
    & h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
    /* Text measure without specificity, so block lists (cards, checks) can set their own width. */
    & :where(p, ul, ol) { max-width: var(--measure); }
    & a { color: var(--color-accent); }
    & a:hover { color: color-mix(in oklch, var(--color-accent), var(--color-text) 30%); }
  }

  /* Buttons for links (<a>) and forms (<button>): the classes are the interface (README, Buttons). */
  .kit-button {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 14px 22px;
    border: 0;
    border-radius: var(--radius);
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    .kit-block &, .kit-block &:hover { color: var(--color-accent-contrast); }
    &:hover { background: color-mix(in oklch, var(--color-accent), black 15%); color: var(--color-accent-contrast); }
    &:disabled, &[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
  }
  .kit-button--small { min-height: 40px; padding: 9px 14px; font-size: 0.95rem; }
  .kit-button--secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-line);
    .kit-block &, .kit-block &:hover { color: var(--color-text); }
    &:hover { background: var(--color-surface); color: var(--color-text); }
  }
  @media (forced-colors: active) {
    .kit-button { border: 1px solid ButtonText; }
  }
  .kit-actions { margin-block: var(--space-4); }

  .kit-img { display: block; max-width: 100%; height: auto; border-radius: var(--radius); }

  .kit-hero {
    display: grid;
    gap: var(--space-4);
    align-items: center;
    /* Two columns once each gets 22rem, one below: no breakpoint needed. */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    & .kit-hero__lead { font-size: 1.2rem; color: var(--color-text-muted); }
    & .kit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
  }
  /* Without image: one column over the full width. */
  .kit-hero--text { grid-template-columns: 1fr; }
  .kit-hero__link { color: var(--color-accent); font-weight: 600; padding-block: 0.6em; }
  .kit-checks {
    list-style: none;
    padding: 0;
    & li { position: relative; padding-left: 1.6em; margin-block: var(--space-2); }
    & li::before { content: "✓"; position: absolute; left: 0; color: var(--color-accent); font-weight: 700; }
  }
  .kit-note, .kit-hero__note { color: var(--color-text-muted); }

  .kit-cards__list {
    list-style: none;
    padding: 0;
    max-width: none;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  }
  .kit-card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    padding: var(--space-4);
    & h3 { margin: 0 0 var(--space-2); font-family: var(--font-display); }
    & p { margin: 0; }
  }

  .kit-card > .kit-img { width: 100%; margin-bottom: var(--space-3); border-radius: calc(var(--radius) - 4px); }

  /* features with an image: text and image side by side once the block is wide enough, image below otherwise. */
  .kit-features__layout { display: grid; gap: var(--space-4); }
  @container (min-width: 48rem) {
    .kit-features--image .kit-features__layout { grid-template-columns: 1fr 1fr; align-items: center; }
  }
  .kit-features__image .kit-img { width: 100%; }

  .kit-showcase__images {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-end;
    & .kit-showcase__shot { flex: 1 1 18rem; min-width: 0; }
    & .kit-showcase__shot--portrait { flex: 0 1 12rem; }
    & .kit-img { width: 100%; }
  }

  .kit-faq__item {
    max-width: var(--measure);
    border-bottom: 1px solid var(--color-line);
    padding-block: var(--space-3);
    /* Native disclosure marker kept (display: list-item); padding gives the 44px target. */
    & summary { cursor: pointer; font-weight: 700; padding-block: 10px; }
  }

  .kit-cta { text-align: start; }
  .kit-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-3); }

  .kit-sources__list { color: var(--color-text-muted); font-size: 0.95rem; }

  .kit-article__header, .kit-article__body {
    max-width: var(--kit-width);
    margin-inline: auto;
    padding: var(--space-5) 20px 0;
    color: var(--color-text);
    font-family: var(--font-body);
    & h1, & h2, & h3 { font-family: var(--font-display); line-height: 1.15; }
    & h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 var(--space-3); }
    & > * { max-width: var(--measure); }
    & a { color: var(--color-accent); }
  }
  .kit-article__meta { color: var(--color-text-muted); }

  .kit-page { max-width: var(--kit-width); margin-inline: auto; padding: var(--space-5) 20px; }
}
