/* Page layout. The studio sets its own background and text colours with a selector
   that outranks site-common.css's html[data-theme="dark"] body rule, so the page always
   uses the studio's colour roles (styles/tokens.css), which follow the site theme. */
:root body.aiop-page,
:root[data-theme] body.aiop-page {
  margin: 0;
  background: var(--aiop-bg);
  color: var(--aiop-text);
  font-family: var(--aiop-font-sans);
  font-size: var(--aiop-size-body);
  line-height: 1.6;
}

.aiop-page *,
.aiop-page *::before,
.aiop-page *::after { box-sizing: border-box; }

/* Pinned bars. The site header (site-common.css) is pinned at the top; on studio pages the
   guide bar is pinned just below it (not on phones). app/components/sticky-offsets.js
   measures both and updates these values; the defaults are the site header height alone.
   scroll-padding-top keeps anything scrolled to or tabbed to below the pinned bars. It is
   the only offset: a scroll-margin on the target as well would add to it and leave a gap
   twice as tall (fixed 2026-11-19). */
:root {
  --aiop-site-header-h: 77px;
  --aiop-bar-h: 0px;
  --aiop-sticky-offset: calc(var(--aiop-site-header-h) + var(--aiop-bar-h) + var(--aiop-space-3));
}
html:has(body.aiop-page) { scroll-padding-top: var(--aiop-sticky-offset); }

/* The element rules below skip the shared site header and contact dialog that
   site-common.js adds (.site-shell, .contact-dialog), so those keep the main site's own
   colours and spacing. :where() keeps the specificity the same as before. */
.aiop-page h1:where(:not(.site-shell *, .contact-dialog *)),
.aiop-page h2:where(:not(.site-shell *, .contact-dialog *)),
.aiop-page h3:where(:not(.site-shell *, .contact-dialog *)) {
  font-family: var(--aiop-font-serif);
  color: var(--aiop-text);
  line-height: 1.25;
  font-weight: 600;
}
.aiop-page h1:where(:not(.site-shell *, .contact-dialog *)) { font-size: var(--aiop-size-h1); margin: var(--aiop-space-3) 0 var(--aiop-space-4); }
.aiop-page h2:where(:not(.site-shell *, .contact-dialog *)) { font-size: var(--aiop-size-h2); margin: var(--aiop-space-6) 0 var(--aiop-space-3); }
.aiop-page h3:where(:not(.site-shell *, .contact-dialog *)) { font-size: var(--aiop-size-h3); margin: 0 0 var(--aiop-space-2); }
/* The page heading takes focus after each route change so screen readers announce the new
   page. It is not a control, so it shows no focus ring. */
.aiop-page h1:focus, .aiop-page h1:focus-visible { outline: none; }

/* Paragraphs inside the shared search dialog (.gs-dialog) keep that dialog's own spacing. */
.aiop-page p:where(:not(.site-shell *, .contact-dialog *, .gs-dialog *)) { margin: 0 0 var(--aiop-space-4); }
.aiop-page a:where(:not(.site-shell *, .contact-dialog *)) { color: var(--aiop-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.aiop-page a:where(:not(.site-shell *, .contact-dialog *)):hover { color: var(--aiop-text); }

/* Focus is always visible on studio controls. */
.aiop-page a:focus-visible,
.aiop-page button:focus-visible,
.aiop-page input:focus-visible,
.aiop-page select:focus-visible,
.aiop-page textarea:focus-visible,
.aiop-page summary:focus-visible {
  outline: 3px solid var(--aiop-focus);
  outline-offset: 2px;
}
/* The site header, its dropdown panels and the contact dialog inherit body text; give them
   the main site's font, size and line height so they match mikehadaway.info exactly. */
.aiop-page .site-shell,
.aiop-page .contact-dialog { font-family: Karla, Arial, sans-serif; font-size: 1rem; line-height: 1.62; }
/* On the site header and contact dialog, use the site's own accent so focus shows. */
.aiop-page .site-shell :focus-visible,
.aiop-page .contact-dialog :focus-visible { outline-color: var(--nav-accent, var(--aiop-focus)); }

.aiop-skip {
  position: absolute;
  left: -9999px;
  top: var(--aiop-space-2);
  z-index: 1200;
  background: var(--aiop-panel);
  color: var(--aiop-text);
  border: 1px solid var(--aiop-control);
  padding: var(--aiop-space-2) var(--aiop-space-4);
  border-radius: var(--aiop-radius);
}
.aiop-skip:focus { left: var(--aiop-space-2); }
.aiop-page .aiop-skip:focus-visible { outline: 3px solid var(--aiop-focus); outline-offset: 2px; color: var(--aiop-text); }

/* Guide bar, as on the Sales Field Guide: after the site header and pinned just below it.
   Not a <header>, so site-common.js always finds the site header first. Stacked below the
   site header (1000) so the site's dropdowns and phone menu cover it. */
.aiop-guidebar {
  position: sticky;
  top: var(--aiop-site-header-h);
  z-index: 900;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  gap: var(--aiop-space-3);
  padding: var(--aiop-space-1) var(--aiop-space-4);
  background: var(--aiop-panel);
  color: var(--aiop-text);
  border-bottom: 1px solid var(--aiop-line);
}
.aiop-page .aiop-brand {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--aiop-text);
  text-decoration: none;
  font-size: var(--aiop-size-small);
}
.aiop-brand strong { font-family: var(--aiop-font-serif); font-size: 1.05rem; font-weight: 600; }
.aiop-brand-sub { color: var(--aiop-text-muted); }
/* Tablets and narrow windows: the tagline gives way and the studio name keeps its full
   width; the Contents label shortens instead (its full text is in the menu itself). */
@media (max-width: 1100px) {
  .aiop-brand-sub { display: none; }
  .aiop-page .aiop-brand { flex: none; }
}
.aiop-spacer { flex: 1 1 0; }
/* The studio's own controls. A later sign-in button belongs in this group too. */
.aiop-gb-controls { display: flex; align-items: center; gap: var(--aiop-space-2); flex: none; }
.aiop-gb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0 var(--aiop-space-3);
  font: 600 var(--aiop-size-small)/1 var(--aiop-font-sans);
  color: var(--aiop-text);
  background: var(--aiop-panel-2);
  border: 1px solid var(--aiop-control);
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
}
.aiop-gb-btn:hover { border-color: var(--aiop-accent); }
.aiop-gb-btn svg { width: 18px; height: 18px; flex: none; }
.aiop-menu-btn { display: none; flex: 0 1 auto; min-width: 0; }
.aiop-menu-cur { overflow: hidden; text-overflow: ellipsis; }

/* Pinned room: the site header plus the guide bar (sticky-offsets.js sets both). */
:root { --aiop-top: calc(var(--aiop-site-header-h) + var(--aiop-bar-h)); }

/* Menu beside the page, as on the Sales guide: an 18rem column, up to 86rem in all. */
.aiop-layout { display: grid; grid-template-columns: 18rem minmax(0, 1fr); max-width: 86rem; margin: 0 auto; }
.aiop-content { min-width: 0; }

/* Left menu (app/components/sidebar.js) */
.aiop-sidebar {
  position: sticky;
  top: var(--aiop-top);
  height: calc(100vh - var(--aiop-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--aiop-space-4) var(--aiop-space-3) var(--aiop-space-6);
  border-right: 1px solid var(--aiop-line);
  background: var(--aiop-bg);
}
.aiop-sb-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0.35rem var(--aiop-space-2); }
.aiop-sb-head > span { font-family: var(--aiop-font-mono); font-size: 0.8rem; font-weight: 600; color: var(--aiop-text-muted); }
.aiop-sb-close { display: none; width: 2.75rem; padding: 0; justify-content: center; }
.aiop-page .aiop-sb-group { margin: 1.1rem 0.6rem 0.3rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--aiop-text-muted); }
.aiop-sb-list, .aiop-sb-sub, .aiop-sb-links { list-style: none; margin: 0; padding: 0; }
.aiop-page .aiop-nl {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.25rem;
  padding: 0.3rem 0.6rem;
  border-radius: 7px;
  color: var(--aiop-text);
  text-decoration: none;
  font-size: 0.94rem;
  line-height: 1.25;
}
.aiop-page .aiop-nl:hover { background: var(--aiop-panel-2); color: var(--aiop-text); }
.aiop-n { min-width: 1.35rem; font-family: var(--aiop-font-mono); font-size: 0.8rem; color: var(--aiop-text-muted); }
.aiop-tx { flex: 1; min-width: 0; }
.aiop-sb-tag { font-family: var(--aiop-font-mono); font-size: 0.72rem; color: var(--aiop-text-muted); border: 1px solid var(--aiop-line); border-radius: 4px; padding: 0 0.3rem; }
.aiop-sb-done { font-size: 0.85rem; font-weight: 700; color: var(--aiop-done); }
.aiop-sb-progress { font-size: 0.85rem; color: var(--aiop-warn); }
/* The current page: soft accent fill and a bar on the left, as on the Sales guide. */
.aiop-page .aiop-nl[aria-current] { background: var(--aiop-accent-soft); color: var(--aiop-accent); font-weight: 600; }
.aiop-nl[aria-current]::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--aiop-accent); }
.aiop-nl[aria-current] .aiop-n, .aiop-nl[aria-current] .aiop-sb-done, .aiop-nl[aria-current] .aiop-sb-progress { color: var(--aiop-accent); }
.aiop-sb-sub { margin: 0.15rem 0 0.35rem 1.6rem; padding-left: 0.3rem; border-left: 1px solid var(--aiop-line); }
.aiop-page .aiop-nl-sub { min-height: 2rem; font-size: 0.9rem; color: var(--aiop-text-muted); }
.aiop-sb-foot { margin: 1.4rem 0.35rem 0; padding: 0.85rem 0.75rem; border: 1px solid var(--aiop-line); border-radius: 10px; background: var(--aiop-panel); font-size: 0.875rem; color: var(--aiop-text-muted); }
.aiop-sb-foot strong { display: block; margin-bottom: 0.2rem; color: var(--aiop-text); }
.aiop-sb-links + .aiop-sb-links { margin-top: var(--aiop-space-2); padding-top: var(--aiop-space-2); border-top: 1px solid var(--aiop-line); }
.aiop-page .aiop-sb-links a { display: inline-flex; align-items: center; min-height: 1.875rem; font-weight: 600; }
.aiop-backdrop { display: none; }
/* Search at the top of the drawer (app/components/search.js). Not on the desktop menu. */
.aiop-page .aiop-sidebar .aiop-sb-search { display: none; }

/* Floating Contents button: phones only, once the guide bar has scrolled away. */
.aiop-tocbtn {
  display: none;
  position: fixed;
  left: var(--aiop-space-4);
  bottom: var(--aiop-space-4);
  z-index: 850;
  min-height: 2.75rem;
  padding: 0 0.95rem;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--aiop-control);
  border-radius: 22px;
  background: var(--aiop-panel);
  color: var(--aiop-text);
  font: 600 1rem/1 var(--aiop-font-sans);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.aiop-tocbtn svg { width: 18px; height: 18px; flex: none; }
.aiop-tocbtn.aiop-show { opacity: 1; visibility: visible; transform: none; }

/* 900px and below: the menu becomes a drawer, opened from the Contents button. Bar
   controls are touch-sized: 44px tall, 16px text. */
@media (max-width: 900px) {
  .aiop-layout { grid-template-columns: minmax(0, 1fr); }
  .aiop-menu-btn { display: inline-flex; }
  .aiop-gb-btn, .aiop-guidebar .aiop-mentor-toggle { min-height: 2.75rem; font-size: 1rem; }
  .aiop-sidebar {
    position: fixed;
    top: var(--aiop-top);
    left: 0;
    bottom: 0;
    height: auto;
    width: min(21rem, 88vw);
    z-index: 950;
    /* Its own colour, edge and shadow, so it stands apart from the page (tokens.css). */
    background: var(--aiop-drawer);
    border-right-color: var(--aiop-drawer-edge);
    transform: translateX(-102%);
    visibility: hidden;
    /* On close it stays visible while it slides out, then hides. */
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    padding-top: var(--aiop-space-3);
  }
  /* On open it is visible at once, so focus can move into it straight away. */
  .aiop-nav-open .aiop-sidebar { transform: none; visibility: visible; transition: transform 0.22s ease, visibility 0s; box-shadow: var(--aiop-drawer-shadow); }
  /* Rows on the drawer colour: hover, the current page and done ticks keep their contrast. */
  .aiop-page .aiop-sidebar .aiop-nl:hover { background: var(--aiop-drawer-hover); }
  .aiop-page .aiop-sidebar .aiop-nl[aria-current] { background: var(--aiop-drawer-current); }
  .aiop-sidebar .aiop-sb-done { color: var(--aiop-drawer-done); }
  .aiop-sidebar .aiop-nl[aria-current] .aiop-sb-done { color: var(--aiop-accent); }
  .aiop-sb-close { display: inline-flex; }
  .aiop-page .aiop-sidebar .aiop-sb-search {
    display: flex;
    width: calc(100% - 0.7rem);
    margin: 0 0.35rem var(--aiop-space-3);
    border-color: var(--aiop-control);
    border-radius: var(--aiop-radius);
    background: transparent;
    color: var(--aiop-text);
    font-family: var(--aiop-font-sans);
    font-size: 1rem;
  }
  .aiop-page .aiop-sidebar .aiop-sb-search:hover { background: var(--aiop-drawer-hover); color: var(--aiop-text); border-color: var(--aiop-text); }
  .aiop-backdrop { display: block; position: fixed; inset: 0; z-index: 940; background: var(--aiop-scrim); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .aiop-nav-open .aiop-backdrop { opacity: 1; pointer-events: auto; }
  body.aiop-nav-open { overflow: hidden; }
}
/* Phones: only the site header stays pinned; the guide bar scrolls with the page, and the
   studio name and "Mode" give way to the controls. */
@media (max-width: 640px) {
  .aiop-guidebar { position: static; padding: var(--aiop-space-1) var(--aiop-space-3); gap: var(--aiop-space-2); }
  .aiop-page .aiop-brand { display: none; }
  .aiop-mentor-rest { display: none; }
  .aiop-guidebar .aiop-mentor-toggle { padding: var(--aiop-space-1) var(--aiop-space-2); }
  .aiop-tocbtn { display: inline-flex; }
  .aiop-nav-open .aiop-tocbtn { display: none; }
}
/* Members' controls (release 1, 2026-11-21): /members/members-shell.js fills the first slot
   of the right-hand group with Account and Sign out (or "Sign in again"). Below 900px the
   bar has room for them only without the studio name; the site header, the Contents menu
   and the page trail still name and link the studio. */
@media (max-width: 900px) {
  .aiop-page .aiop-guidebar .aiop-brand { display: none; }
}
/* Phones: the guide bar scrolls with the page (above), so it can take a second row. The
   members' controls move to their own row, on the right, and the studio's controls keep
   their room on the first. */
@media (max-width: 640px) {
  .aiop-guidebar { flex-wrap: wrap; row-gap: var(--aiop-space-1); }
  .aiop-guidebar .aiop-gb-controls { display: contents; }
  /* The Contents button shrinks (its label is cut short) rather than push a control down. */
  .aiop-guidebar .aiop-menu-btn { flex: 1 1 0; max-width: max-content; }
  .aiop-guidebar .aiop-spacer { display: none; }
  .aiop-guidebar .aiop-search-btn { margin-left: auto; }
  .aiop-guidebar .mh-members-controls { order: 1; flex: 1 0 100%; justify-content: flex-end; }
}
/* Windows high contrast: fills are dropped, so the current row also gets an outline. */
@media (forced-colors: active) {
  .aiop-page .aiop-nl[aria-current] { outline: 2px solid Highlight; outline-offset: -2px; }
}

.aiop-notices { padding: 0 clamp(1rem, 4vw, 3.5rem); }

.aiop-main {
  display: block;
  padding: var(--aiop-space-4) clamp(1rem, 4vw, 3.5rem) var(--aiop-space-7);
}
.aiop-main:focus { outline: none; }
.aiop-reading { max-width: var(--aiop-measure); }
/* Body text never runs wider than a comfortable line, wherever it sits. */
.aiop-main p, .aiop-main li, .aiop-main dd, .aiop-main dt, .aiop-main blockquote { max-width: var(--aiop-measure); }

.aiop-footer {
  border-top: 1px solid var(--aiop-line);
  color: var(--aiop-text-muted);
  font-size: var(--aiop-size-small);
}
.aiop-footer-inner { padding: var(--aiop-space-5) clamp(1rem, 4vw, 3.5rem); }
.aiop-footer p { margin: 0 0 var(--aiop-space-2); }

.aiop-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .aiop-page *, .aiop-page *::before, .aiop-page *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
