/* Opt-in local pen review. No handwriting font, media recoloring or runtime skin. */
body.pen-site {
  --pen-blue: #244c91;
  --pen-red: #a3473f;
  --pen-green: #386b4e;
  --pen-paper: #f6f1e5;
  --pen-line: #d9d0bc;
}
html[data-theme="dark"] body.pen-site {
  --pen-blue: #a7bfe8;
  --pen-red: #e0a398;
  --pen-green: #a0c6a7;
  --pen-paper: #242520;
  --pen-line: #505145;
}
body.pen-site[data-pen-scope="static"] {
  --bg: var(--pen-paper);
  --paper: #fcf9f1;
  --accent: var(--pen-blue);
  --line: var(--pen-line);
  background: var(--bg);
}
html[data-theme="dark"] body.pen-site[data-pen-scope="static"] { --paper: #2d2e27; }
body.pen-site .pen-filter-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
body.pen-site svg[data-pen-ink="true"] { color: var(--pen-blue); filter: url(#pen-ink-grain); }
body.pen-site .pen-ink-punctuation { display: inline-block; white-space: nowrap; }
body.pen-site[data-pen-decorated="1"] footer.sf-footer .footer-signature-name.pen-author-signature {width:280px!important;max-width:100%!important;}
body.pen-site footer svg.pen-author-art {display:block!important;width:100%!important;height:auto!important;max-width:100%!important;overflow:visible;}
html[data-theme="dark"] body.pen-site .pen-author-art {filter:brightness(1.5) saturate(.8);}
body.pen-site .pen-note,
body.pen-site [data-pen-note] { border-left: 2px solid currentColor; padding-left: 1rem; font-size: .9em; line-height: 1.65; }
body.pen-site .pen-note--red,
body.pen-site [data-pen-note="red"] { color: var(--pen-red); }
body.pen-site .pen-note--green,
body.pen-site [data-pen-note="green"] { color: var(--pen-green); }

/* The existing word half and accessible brand name are left untouched. */
body.pen-site .brand .pen-before-ready {
  display: inline-block;
  width: 3.08em;
  height: 1.027em;
  vertical-align: -.17em;
  margin-right: -.025em;
}
body.pen-site .brand .pen-before-ready > .brand-before-drawing { display: block !important; width:100%!important; height:100%!important; }
body.pen-site .brand .pen-before-loaded > .brand-before-drawing { display: none !important; }
body.pen-site .brand .pen-before-image {
  display: none;
  width: 100%;
  height: auto;
  max-width: none;
  border: 0;
}
body.pen-site .brand .pen-before-loaded > .pen-before-image {display:block;}
/* Brightness applies only to the new transparent ink artwork, never to media. */
html[data-theme="dark"] body.pen-site .pen-before-image,
html[data-theme="dark"] body.pen-site .pen-nav-art { filter: brightness(0) saturate(100%) invert(80%) sepia(19%) saturate(700%) hue-rotate(180deg); }
html[data-theme="dark"] body.pen-site .pen-figure > svg { filter: invert(1) hue-rotate(180deg) saturate(.6); }
body.pen-site .pen-figure { margin: 28px 0; max-width: 100%; }
body.pen-site .pen-figure > svg { display: block; width: 100%; height: auto; max-width: 100%; }
body.pen-site .pen-figure > figcaption { margin-top: 12px; max-width: 72ch; color: var(--sub); font-size: .78em; line-height: 1.65; }
body.pen-site .pen-ai-transfer { width: 100%; max-width: 680px; margin: 32px auto; }
body.pen-site .pen-ai-speech { width: 100%; max-width: 460px; margin: 28px 0; }
body.pen-site .pen-cover-sketch { width: 100%; }

body.pen-site .pen-nav-link { position: relative; min-height: 44px; text-decoration: none !important; }
body.pen-site .pen-nav-art {
  --pen-label-height: clamp(26px, calc(var(--font, 18px) * 1.45), 34px);
  display: block;
  flex: 0 0 auto;
  width: calc(var(--pen-label-ratio) * var(--pen-label-height));
  height: var(--pen-label-height);
  max-width: 100%;
  overflow: hidden;
  visibility: hidden;
}
body.pen-site .pen-nav-link.pen-ink-ready .pen-nav-art {visibility:visible;}
body.pen-site .pen-nav-fallback {
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  white-space:nowrap;font-size:max(14px,.8em);color:var(--pen-blue);
}
body.pen-site .pen-nav-link.pen-ink-ready .pen-nav-fallback {
  position: absolute;
  inset:auto;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
body.pen-site .pen-nav-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 2px;
  bottom: 3px;
  height: 3px;
  border-bottom: 1.5px solid var(--pen-red);
  border-radius: 50%;
  transform: rotate(-1deg);
}
body.pen-site .pen-nav-link:focus-visible { outline: 2px solid var(--pen-blue); outline-offset: 5px; }
body.pen-site[data-pen-decorated="1"] .site-header .desktop-nav { gap: 18px !important; }
body.pen-site[data-pen-decorated="1"] .site-header .desktop-nav a:hover { text-decoration: none !important; }
@media (max-width: 1100px) {
  body.pen-site[data-pen-decorated="1"] .site-header { height: 70px !important; }
  body.pen-site[data-pen-decorated="1"] .site-header .desktop-nav { display: none !important; }
  body.pen-site[data-pen-decorated="1"] .site-header .header-controls #mobile-menu-button { display: grid !important; }
  body.pen-site[data-pen-decorated="1"] .rail.open {
    display: block !important;
    position: fixed !important;
    inset: 70px 0 auto !important;
    z-index: 19 !important;
    background: var(--bg) !important;
    padding: 12px 24px 22px !important;
    border-bottom: 1px solid var(--line) !important;
    max-height: calc(100dvh - 70px) !important;
    overflow: auto !important;
  }
  body.pen-site[data-pen-decorated="1"] .rail nav { display: flex !important; flex-direction: column !important; }
  body.pen-site[data-pen-decorated="1"] .rail .pen-nav-link { display: flex !important; align-items: center !important; min-height: 54px !important; }
  body.pen-site .rail .pen-nav-art { --pen-label-height: 31px; }
  body.pen-site .rail .pen-nav-link[aria-current="page"]::after { right: auto; width: 54px; }
}
@media (forced-colors: active) {
  body.pen-site .pen-nav-art, body.pen-site .pen-before-image { display: none; }
  body.pen-site .brand .pen-before-loaded > .pen-before-image {display:none!important;}
  body.pen-site .brand .pen-before-ready > .brand-before-drawing { display: block !important; }
  body.pen-site .pen-nav-fallback, body.pen-site .pen-nav-link.pen-ink-ready .pen-nav-fallback { position: static; width: auto; height: auto; margin: 0; clip-path: none; white-space: normal; }
}
@media print {
  body.pen-site svg[data-pen-ink="true"] { filter: none; }
  body.pen-site .pen-nav-art, body.pen-site .pen-before-image { print-color-adjust: exact; }
}
/* Override the captured shell's generic 22px SVG icon rule for actual menu art. */
body.pen-site .site-header svg.pen-nav-art,
body.pen-site #rail svg.pen-nav-art {
  width:calc(var(--pen-label-ratio) * var(--pen-label-height))!important;
  height:var(--pen-label-height)!important;
  max-width:none!important;
  stroke:none!important;
}
body.pen-site[data-pen-scope="static"] .site-header {background:var(--pen-paper)!important;}
body.pen-site .pen-chapter-return {width:min(1200px,calc(100% - 80px));margin:26px auto 0;display:flex;gap:24px;align-items:center;font-size:.8em;color:var(--pen-blue);}
body.pen-site .pen-chapter-return a {min-height:44px;display:inline-flex;align-items:center;}
@media(max-width:600px){body.pen-site .pen-chapter-return{width:calc(100% - 40px);font-size:.78em;flex-wrap:wrap;gap:8px 20px;}}
