/* Shared reading preferences for the standalone homepage and inner pages. */
.accessibility-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line, var(--border));
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.accessibility-trigger svg { width: 22px; height: 22px; }
.accessibility-trigger:hover { background: var(--surface); }
.accessibility-trigger[data-customized]::after { content: ""; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.nav-actions { display: flex; align-items: center; justify-self: end; gap: 8px; }
.mobile-menu { position: relative; }
.mobile-menu summary { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; width: 44px; height: 44px; list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 5px; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu summary > span { height: 1px; width: 18px; background: var(--ink); }
.mobile-menu ul { position: absolute; top: 53px; right: 0; width: min(260px, calc(100vw - 40px)); padding: 9px; z-index: 60; background: var(--paper); border: 1px solid var(--border); border-radius: 7px; box-shadow: 0 10px 25px #18232b12; }
.mobile-menu a { display: block; min-height: 44px; padding: 11px 12px; font-size: var(--text-sm); }
.a11y-panel {
  box-sizing: border-box;
  width: min(420px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  margin: 96px clamp(16px, 4.5vw, 64px) auto auto;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line, var(--border));
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  line-height: 1.5;
  box-shadow: 0 16px 64px #0003;
}
.a11y-panel::backdrop { background: #0005; }
html[data-a11y-panel-open] { overflow: hidden; }
.a11y-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body .a11y-panel h2 { min-width: 0; margin: 0; font-size: var(--text-xl); line-height: 1.3; letter-spacing: -.025em; overflow-wrap: anywhere; }
.a11y-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line, var(--border)); border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }
.a11y-close:hover, .a11y-reset:hover { background: var(--surface); }
.a11y-panel p { margin: 0; }
#a11y-description { margin: 4px 0 24px; color: var(--muted); }
.a11y-size-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 20px; }
.a11y-size-row label, .a11y-option-title { font-weight: 500; }
.a11y-size-row select { max-width: 100%; min-height: 44px; padding: 8px 28px 8px 10px; border: 1px solid var(--line, var(--border)); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; }
.a11y-option { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 72px; padding-block: 16px; border-top: 1px solid var(--line, var(--border)); cursor: pointer; }
.a11y-option > span { min-width: 0; }
.a11y-option-title, .a11y-hint { display: block; }
.a11y-hint { margin-top: 4px; color: var(--muted); font: 400 var(--text-xs)/1.6 var(--font-secondary); }
.a11y-option input { flex: 0 0 22px; width: 22px; height: 22px; margin: 0; accent-color: var(--accent-ink, var(--accent)); cursor: pointer; }
.a11y-option input:disabled { cursor: default; }
.a11y-footer { border-top: 1px solid var(--line, var(--border)); padding-top: 20px; }
.a11y-reset { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line, var(--border)); border-radius: 4px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.a11y-footer .a11y-hint { margin-top: 12px; }
body :is(input, select, textarea, .accessibility-trigger, .a11y-panel button):focus-visible { outline: 2px solid var(--accent-ink, var(--accent)); outline-offset: 4px; }

html[data-a11y-size="125"] { font-size: 125%; }
html[data-a11y-size="150"] { font-size: 150%; }
html[data-a11y-links] a { text-decoration-line: underline !important; text-underline-offset: .2em; text-decoration-thickness: .08em; }
html[data-a11y-spacing] :is(main p, main li, main h1, main h2, main h3, main h4, main a, main button, main figcaption, main .annotation) {
  letter-spacing: .12em !important;
  word-spacing: .16em !important;
  line-height: 1.8 !important;
}
html:is([data-a11y-spacing], [data-a11y-size="125"], [data-a11y-size="150"]) main { overflow-wrap: anywhere; }
html[data-a11y-contrast] {
  --paper: #fff; --white: #fff; --surface: #f3f5fa; --ink: #0b0f19;
  --muted: #374151; --line: #6b7280; --border: #6b7280;
  --accent: #4338ca; --accent-hover: #3730a3; --accent-ink: #3730a3;
  --action: #4338ca; --action-hover: #3730a3;
  --on-accent: #fff;
  --secondary: #3730a3; --secondary-on-dark: #3730a3; --accent-on-dark: #3730a3;
  --dark: #eef2ff; --tint: rgba(99, 102, 241, .06); --diagram-line: #64748b;
  --footer-bg: #080f1c; --footer-panel: #111b2e; --footer-ink: #fff;
  --footer-muted: #e2e8f0; --footer-accent: #c7d2fe; --footer-line: #94a3b8;
}
html[data-a11y-contrast] .site-header { background: var(--paper); }
html[data-a11y-contrast] .contact-band-copy > p { color: var(--muted); }
html[data-a11y-contrast] .code-comment { color: var(--muted); }

html[data-a11y-motion="reduce"], html[data-a11y-motion="reduce"] *, html[data-a11y-motion="reduce"] *::before, html[data-a11y-motion="reduce"] *::after {
  scroll-behavior: auto !important;
  transition: none !important;
  animation: none !important;
}
/* Keep the phone layers and their descriptions readable when motion is disabled. */
html[data-a11y-motion="reduce"] .exploded { height: auto; }
html[data-a11y-motion="reduce"] .hero-pin { position: relative; top: 0; height: 840px; min-height: 840px; }
html[data-a11y-motion="reduce"] .diagram { height: 90%; }
html[data-a11y-motion="reduce"] .layer-ui { transform: translate(-50%,-50%) translate(-46px,-152px) rotateX(38deg) rotateY(-18deg) rotateZ(14deg); }
html[data-a11y-motion="reduce"] .layer-state { transform: translate(-50%,-50%) translate(-15px,-50px) rotateX(38deg) rotateY(-18deg) rotateZ(14deg); }
html[data-a11y-motion="reduce"] .layer-network { transform: translate(-50%,-50%) translate(15px,52px) rotateX(38deg) rotateY(-18deg) rotateZ(14deg); }
html[data-a11y-motion="reduce"] .layer-data { transform: translate(-50%,-50%) translate(46px,154px) rotateX(38deg) rotateY(-18deg) rotateZ(14deg); }
html[data-a11y-motion="reduce"] .annotation { opacity: 1; }
html[data-a11y-motion="reduce"] .source-study { height: auto; }
html[data-a11y-motion="reduce"] .source-pin { position: static; }

/* Let larger and more widely spaced text grow outside the original sticky frames. */
html[data-a11y-reading] .exploded { height: auto; }
html[data-a11y-reading] .hero-pin { position: relative; top: 0; height: auto; min-height: 0; overflow: visible; }
html[data-a11y-reading] .hero-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); height: auto; gap: 48px; align-items: start; }
html[data-a11y-reading] .hero-copy { position: static; width: auto; padding-top: 48px; }
html[data-a11y-reading] .hero-description { max-width: 36rem; }
html[data-a11y-reading] .diagram { position: relative; top: auto; right: auto; width: 100%; height: auto; margin-top: 48px; }
html[data-a11y-reading] .figure-label { position: static; margin-bottom: 24px; }
html[data-a11y-reading] .diagram-stage { display: block; position: relative; height: 800px; }
html[data-a11y-reading] .diagram-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 32px; }
html[data-a11y-reading] .diagram-key .annotation { position: static; width: auto; opacity: 1 !important; transform: none !important; }
html[data-a11y-reading] .diagram-key .annotation::before, html[data-a11y-reading] .diagram-key .annotation::after { display: none; }
html[data-a11y-reading] .hero-baseline { position: static; grid-column: 1 / -1; flex-wrap: wrap; padding-bottom: 24px; }
html[data-a11y-reading] .diagram-node, html[data-a11y-reading] .release-canvas .diagram-node { height: auto; min-height: 144px; gap: 16px; }
html[data-a11y-reading] :is(.node-heading, .engineering-heading, .engineering-caption, .code-head, .screen-head, .source-title, .state-buttons, .live-ticket, .study-controls) { flex-wrap: wrap; }
html[data-a11y-reading] .source-study { height: auto; }
html[data-a11y-reading] .source-pin { position: static; min-height: 0; }
html[data-a11y-reading] .code-window pre { white-space: pre-wrap; overflow-wrap: anywhere; }
html[data-a11y-reading] #booking-button { max-width: 100%; white-space: normal; }
html[data-a11y-reading] [data-booking-label] { min-width: 0; }

@media (max-width: 1100px) {
  html[data-a11y-reading] .hero-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .site-nav > :is(.nav-links, .nav-github) { display: none; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .mobile-menu { display: block; }
}
@media (max-width: 760px) {
  .nav-actions { gap: 4px; }
  body .header .nav { inset-block: 10px; padding-block: 6px; }
  .a11y-panel { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: 16px auto; padding: 20px; }
  html[data-a11y-motion="reduce"] .hero-pin { height: auto; min-height: 0; }
  html[data-a11y-motion="reduce"] .diagram { top: auto; height: auto; }
  html[data-a11y-motion="reduce"] .diagram-stage { height: 640px; }
  html[data-a11y-motion="reduce"] .layer-ui { transform: translate(-50%,-50%) translateY(-204px) rotateX(50deg) rotateZ(-8deg); }
  html[data-a11y-motion="reduce"] .layer-state { transform: translate(-50%,-50%) translateY(-68px) rotateX(50deg) rotateZ(-8deg); }
  html[data-a11y-motion="reduce"] .layer-network { transform: translate(-50%,-50%) translateY(68px) rotateX(50deg) rotateZ(-8deg); }
  html[data-a11y-motion="reduce"] .layer-data { transform: translate(-50%,-50%) translateY(204px) rotateX(50deg) rotateZ(-8deg); }
  html[data-a11y-reading] .hero-copy { padding-top: 32px; }
  html[data-a11y-reading] .diagram { margin-top: 32px; }
  html[data-a11y-reading] .diagram-stage { height: 440px; }
  html[data-a11y-reading][data-a11y-motion="reduce"] .diagram-stage { height: 640px; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .header { height: 142px; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .header .nav { grid-template-columns: 1fr auto; align-content: center; gap: 8px; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .header .nav-links { grid-row: 2; grid-column: 1 / -1; justify-self: stretch; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .header .nav-links a { flex: 1; min-height: 40px; }
  html:is([data-a11y-size="125"], [data-a11y-size="150"]) .nav-actions { grid-row: 1; grid-column: 2; }
  html:is([data-a11y-spacing], [data-a11y-size="125"], [data-a11y-size="150"]) .intro-baseline { flex-wrap: wrap; }
  html:is([data-a11y-spacing], [data-a11y-size="125"], [data-a11y-size="150"]) :is(.engineering-heading, .physics-top, .state-buttons, .physics-help, .contact-card-row) { flex-wrap: wrap; }
  html[data-a11y-reading] .contact-main { flex-wrap: wrap; }
  html:is([data-a11y-spacing], [data-a11y-size="125"], [data-a11y-size="150"]) :is(.visual-index, .visual-note, .figure-label, .annotation) { white-space: normal; }
}
@media (max-width: 420px) {
  .header .identity-short { display: none; }
  .brand-copy > span { display: none; }
  .site-nav .brand { min-width: 0; white-space: normal; }
  .site-nav .brand-copy { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
}
@media (max-width: 360px) {
  body .header .nav { padding-inline: 6px; gap: 4px; }
  body .header .nav-links a, body .header .nav-links a[href="#about"] { padding-inline: 1px; letter-spacing: 0; }
  .a11y-panel { padding: 16px; }
  .a11y-heading { gap: 8px; }
  html[data-a11y-reading] .site-nav .brand { gap: 6px; }
  html[data-a11y-reading] .site-nav .brand-mark { font-size: 36px; letter-spacing: -4px; }
  html[data-a11y-reading] .site-nav .brand-copy { overflow-wrap: normal; }
}
