/* Yaoyorozu AI ToolBox — unified site shell (portal) styles.
   Injected by the build on every treated page, after the page's own stylesheets.
   Scope: everything here is gated to body[data-site-shell] so guide pages keep their
   own typography; shared tokens use the --sy-* prefix. Mobile-first: 320px and 390px
   are the base, the desktop nav takes over at 900px, matching styles.css breakpoints. */

:root {
  --sy-paper: #f2eee3;
  --sy-paper-deep: #e7e1d0;
  --sy-field: #fbf9f3;
  --sy-ink: #17150f;
  --sy-ink-soft: #4f4a3f;
  --sy-rule: rgba(23, 21, 15, 0.2);
  --sy-accent: #b83900;

  /* Guide identity accents: 茜 (motion), 藍 (slides), 萌黄 (ui-ux). */
  --sy-c-motion: #b7282e;
  --sy-c-slides: #2f4d7d;
  --sy-c-uiux: #65720f;

  --sy-focus: #cbef3a;

  --sy-mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "BIZ UDPMincho", "Noto Serif JP", serif;
  --sy-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "YuGothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;

  --sy-max: 80rem;
  --sy-gutter: 1.25rem;
  /* Two rows like styles.css --header-h: wordmark row + specialist guide row. */
  --sy-header-h: 5.75rem;
  --sy-dock-h: 3.5rem;
}

/* In-page anchors stop below the sticky shell header on every treated page. */
html:has(body[data-site-shell]) {
  scroll-padding-top: calc(var(--sy-header-h) + env(safe-area-inset-top) + 0.75rem);
}
@media (max-width: 899px) {
  html:has(body[data-site-shell]) {
    scroll-padding-bottom: calc(var(--sy-dock-h) + env(safe-area-inset-bottom));
  }
}

/* Room for the fixed bottom dock on phones; desktop pages keep their own spacing. */
@media (max-width: 899px) {
  body[data-site-shell] { padding-bottom: calc(var(--sy-dock-h) + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  body[data-site-shell] { padding-bottom: 0; }
}

/* ---------------------------------------------------------------- header */

body[data-site-shell] .sy-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--sy-paper);
  color: var(--sy-ink);
  border-bottom: 1px solid var(--sy-ink);
}

body[data-site-shell] .sy-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1rem;
  max-width: var(--sy-max);
  margin-inline: auto;
  min-height: calc(var(--sy-header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top)
    max(var(--sy-gutter), env(safe-area-inset-right))
    0
    max(var(--sy-gutter), env(safe-area-inset-left));
}

body[data-site-shell] .sy-brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  /* Same Latin wordmark treatment as styles.css; fluid so it fits a 320px screen. */
  font-family: "Segoe UI", Arial, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 4vw, 1.25rem);
  line-height: 1.2;
  letter-spacing: -0.035em;
  text-decoration: none;
  white-space: nowrap;
}

/* Main in-page navigation: desktop row beside the wordmark. Phones use the
   specialist guide row plus the bottom dock. */
body[data-site-shell] .sy-nav { display: none; }

/* Specialist guides: one compact horizontally scrolling row at the top of every
   page and width (mirrors .masthead-sites), never a wrapped stack. */
body[data-site-shell] .sy-sites {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.125rem 1.5rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
}

body[data-site-shell] .sy-sites a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  text-decoration: none;
  white-space: nowrap;
}

body[data-site-shell] .sy-sites a[aria-current] {
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--sy-accent);
}

body[data-site-shell] .sy-header a:focus-visible,
body[data-site-shell] .sy-dock a:focus-visible,
body[data-site-shell] .sy-breadcrumb a:focus-visible,
body[data-site-shell] .sy-guide-local a:focus-visible,
body[data-site-shell] .sy-footer a:focus-visible,
body[data-site-shell] .hub-card a:focus-visible,
body[data-site-shell] .hub-card-more:focus-visible {
  outline: 3px solid var(--sy-ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--sy-focus);
}

/* ------------------------------------------------------------- breadcrumb */

body[data-site-shell] .sy-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.125rem 0.25rem;
  max-width: var(--sy-max);
  margin-inline: auto;
  padding: 0.375rem
    max(var(--sy-gutter), env(safe-area-inset-right))
    0
    max(var(--sy-gutter), env(safe-area-inset-left));
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--sy-ink-soft);
}

body[data-site-shell] .sy-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: var(--sy-ink-soft);
  text-decoration-color: var(--sy-rule);
}

body[data-site-shell] .sy-breadcrumb a:hover { color: var(--sy-ink); }

body[data-site-shell] .sy-breadcrumb [aria-current] {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: var(--sy-ink);
  font-weight: 700;
}

body[data-site-shell] .sy-breadcrumb > span[aria-hidden] { margin: 0 0.3rem; }

/* ----------------------------------------------- in-guide local menu */

/* Existing guide navs are re-hosted inside this wrapper; let their links wrap. */
body[data-site-shell] .sy-guide-local {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: var(--sy-max);
  margin-inline: auto;
  padding: 0.25rem
    max(var(--sy-gutter), env(safe-area-inset-right))
    1rem
    max(var(--sy-gutter), env(safe-area-inset-left));
}

body[data-site-shell] .sy-guide-local a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.25rem 0.875rem;
  border: 1px solid var(--sy-rule);
  background: var(--sy-field);
  color: var(--sy-ink);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

body[data-site-shell] .sy-guide-local a:hover { background: var(--sy-paper-deep); }

/* ------------------------------------------------------------------- dock */

/* Bottom bar on phones: same tabs as the header, scrolling sideways rather than
   stacking, so 320/390px screens keep a single restrained row (44px targets). */
body[data-site-shell] .sy-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  background: var(--sy-paper);
  color: var(--sy-ink);
  border-top: 1px solid var(--sy-ink);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body[data-site-shell] .sy-dock a {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-width: 2.75rem;
  min-height: var(--sy-dock-h);
  padding: 0.25rem 0.75rem 0.375rem;
  font-size: 0.8125rem;
  line-height: 1.2;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

body[data-site-shell] .sy-dock a[aria-current] {
  background: var(--sy-ink);
  color: var(--sy-paper);
  font-weight: 700;
  box-shadow: inset 0 2px 0 var(--sy-accent);
}

/* While a text field has focus the dock steps aside, like the old tabbar. */
html.is-editing body[data-site-shell] .sy-dock { display: none; }

/* ----------------------------------------------------------------- footer */

body[data-site-shell] .sy-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 2.5rem;
  border-top: 1px solid var(--sy-ink);
  background: var(--sy-paper);
  color: var(--sy-ink);
  padding-top: 2.25rem;
  padding-bottom: 2.5rem;
  padding-left: max(max(var(--sy-gutter), env(safe-area-inset-left)), calc((100% - var(--sy-max)) / 2));
  padding-right: max(max(var(--sy-gutter), env(safe-area-inset-right)), calc((100% - var(--sy-max)) / 2));
  font-size: 0.9375rem;
  line-height: 1.7;
}

body[data-site-shell] .sy-footer > div {
  flex: 2 1 18rem;
  min-width: 0;
}

body[data-site-shell] .sy-footer-brand {
  margin: 0 0 0.375rem;
  font-family: "Segoe UI", Arial, system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.035em;
}

body[data-site-shell] .sy-footer nav {
  flex: 1 1 10rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}

body[data-site-shell] .sy-footer nav a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--sy-rule);
  color: var(--sy-ink);
  text-decoration: none;
}

body[data-site-shell] .sy-footer nav a:hover { text-decoration: underline; text-underline-offset: 0.22em; }

body[data-site-shell] .sy-footer-note {
  flex-basis: 100%;
  min-width: 0;
  max-width: 46em;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--sy-ink-soft);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- desktop switch */

@media (min-width: 900px) {
  :root { --sy-gutter: clamp(2rem, 4vw, 3.5rem); }

  body[data-site-shell] .sy-dock { display: none; }

  body[data-site-shell] .sy-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem 1.5rem;
    font-size: 0.9375rem;
  }

  body[data-site-shell] .sy-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.125rem;
    color: var(--sy-ink);
    text-decoration: none;
    box-shadow: inset 0 -2px 0 transparent;
  }

  body[data-site-shell] .sy-nav a:hover {
    text-decoration: underline;
    text-underline-offset: 0.3em;
    text-decoration-thickness: 2px;
  }

  body[data-site-shell] .sy-nav a[aria-current] {
    font-weight: 700;
    box-shadow: inset 0 -2px 0 var(--sy-accent);
  }
}

/* ================================================================= */
/* Hub components: guides index, sitemap.                            */
/* ================================================================= */

/* Shared band padding, same max line as the rest of the site.
   (.hub-cards nested in a .hub-band takes its padding from the band.) */
body[data-site-shell] :is(.hub-band, .hub-page-head, .hub-cards-page, .hub-page-note, .sy-map-grid) {
  padding-left: max(var(--pad-l, var(--sy-gutter)), calc((100% - var(--max, var(--sy-max))) / 2));
  padding-right: max(var(--pad-r, var(--sy-gutter)), calc((100% - var(--max, var(--sy-max))) / 2));
}

body[data-site-shell] .hub-kicker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--sy-ink-soft);
}

body[data-site-shell] .hub-kicker::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  flex: none;
  background: var(--sy-accent);
}

/* ------------------------------------------------------------ guide cards */

body[data-site-shell] .hub-cards {
  list-style: none;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

body[data-site-shell] .hub-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.125rem 1.125rem 1.25rem;
  background: var(--sy-field);
  border: 1px solid var(--sy-rule);
  border-top: 3px solid var(--hub-c, var(--sy-ink));
}

body[data-site-shell] .hub-card-fig {
  margin: 0 0 0.875rem;
  padding: 0.75rem;
  border: 1px solid var(--sy-rule);
  background: var(--sy-paper);
}

body[data-site-shell] .hub-card-fig svg {
  display: block;
  width: 100%;
  max-width: 15rem;
  height: auto;
  margin-inline: auto;
}

body[data-site-shell] .hub-card-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--hub-c, var(--sy-accent));
}

body[data-site-shell] .hub-card-title {
  margin: 0.25rem 0 0.375rem;
  font-family: var(--sy-mincho);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.4;
  text-wrap: balance;
}

body[data-site-shell] .hub-card-goal {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.7;
}

body[data-site-shell] .hub-card-topics {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0.625rem 0 0;
  border-top: 1px solid var(--sy-rule);
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--sy-ink-soft);
}

body[data-site-shell] .hub-card-topics li {
  position: relative;
  padding-left: 1em;
}

body[data-site-shell] .hub-card-topics li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 0.45rem;
  height: 1px;
  background: var(--hub-c, var(--sy-ink));
}

body[data-site-shell] .hub-card-cta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.875rem;
  min-height: 2.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--sy-ink);
  text-decoration: none;
}

body[data-site-shell] .hub-card-cta::after { content: "→"; }

body[data-site-shell] .hub-card-more {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.125rem;
  min-height: 2.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sy-ink-soft);
}

body[data-site-shell] .hub-card-more::after { content: "→"; font-weight: 400; }

@media (hover: hover) and (pointer: fine) {
  body[data-site-shell] .hub-card:hover { box-shadow: 0 10px 28px -18px rgba(23, 21, 15, 0.45); }
  body[data-site-shell] .hub-card-cta:hover,
  body[data-site-shell] .hub-card-more:hover { text-decoration: underline; text-underline-offset: 0.22em; }
}

@media (prefers-reduced-motion: no-preference) {
  body[data-site-shell] .hub-card { transition: box-shadow 180ms ease-out; }
  body[data-site-shell] .hub-card-cta::after,
  body[data-site-shell] .hub-card-more::after { transition: transform 150ms ease-out; }
  body[data-site-shell] .hub-card-cta:hover::after,
  body[data-site-shell] .hub-card-more:hover::after { transform: translateX(2px); }
}

@media (min-width: 900px) {
  body[data-site-shell] .hub-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
  }

  /* Deliberate editorial stagger: the three guides step down to the right. */
  body[data-site-shell] .hub-cards > li:nth-child(2) { margin-top: 1.5rem; }
  body[data-site-shell] .hub-cards > li:nth-child(3) { margin-top: 3rem; }
}

/* ------------------------------------------- sub page head (guides/map) */

body[data-site-shell] .hub-page-head {
  padding-top: 1.5rem;
  padding-bottom: 1.25rem;
}

body[data-site-shell] .hub-page-title {
  margin: 0;
  font-family: var(--sy-mincho);
  font-weight: 700;
  font-size: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

body[data-site-shell] .hub-page-lead {
  margin: 0.625rem 0 0;
  max-width: 40em;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--sy-ink-soft);
}

body[data-site-shell] .hub-cards-page { padding-bottom: 1.5rem; }

body[data-site-shell] .hub-page-note {
  margin: 0;
  padding-top: 1rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--sy-ink);
  max-width: none;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--sy-ink-soft);
}

@media (min-width: 900px) {
  body[data-site-shell] .hub-page-head { padding-top: 2.5rem; padding-bottom: 1.75rem; }
}

/* --------------------------------------------------------------- sitemap */

/* Generated site map: group columns of plain link lists. */
body[data-site-shell] .sy-map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem 2.5rem;
  padding-bottom: 3rem;
}

body[data-site-shell] .sy-map-group { min-width: 0; }

body[data-site-shell] .sy-map-group h2 {
  margin: 0 0 0.25rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--sy-ink);
  font-family: var(--sy-mincho);
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.5;
}

body[data-site-shell] .sy-map-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

body[data-site-shell] .sy-map-group a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--sy-rule);
  color: var(--sy-ink);
  text-decoration: none;
}

body[data-site-shell] .sy-map-group a:hover { text-decoration: underline; text-underline-offset: 0.22em; }

@media (min-width: 700px) {
  body[data-site-shell] .sy-map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  body[data-site-shell] .sy-map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-site-shell] * {
    transition: none !important;
    animation: none !important;
  }
}
