/* pitmap demo: same system as classifier_explorer (serif page, light/dark via data-theme) */
:root {
  --bg: #ffffff;
  --fg: #2C2C2A;
  --muted: #5F5E5A;
  --line: #D3D1C7;
  --panel: #F7F6F2;
  --accent: #2C2C2A;
  --btn-on-bg: #2C2C2A;
  --btn-on-fg: #ffffff;
  --logo: #185FA5;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --fg: #F1EFE8;
  --muted: #B4B2A9;
  --line: #444441;
  --panel: #121211;
  --accent: #F1EFE8;
  --btn-on-bg: #F1EFE8;
  --btn-on-fg: #000000;
  --logo: #85B7EB;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; overflow-y: scroll; }

html, body { margin: 0; background: var(--bg); color: var(--fg); }

body {
  font-family: "Times New Roman", Times, serif;
  font-size: 17px;
  line-height: 1.5;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 10px 16px 16px; }

header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand titles theme";
  align-items: center;
  text-align: center;
  margin-bottom: 8px;
  column-gap: 16px;
}

.brand { grid-area: brand; justify-self: start; align-self: center; display: block; line-height: 0; }
.logo { height: 84px; width: auto; display: block; }
.titles { grid-area: titles; padding: 0 20px; height: 150px; display: flex; flex-direction: column; justify-content: center; overflow: visible; }
.dsd { grid-area: theme; justify-self: end; align-self: center; display: block; line-height: 0; }
.dsd-logo { width: 250px; height: auto; display: block; }
.dsd-dark { display: none; }
:root[data-theme="dark"] .dsd-light { display: none; }
:root[data-theme="dark"] .dsd-dark { display: block; }

@media (max-width: 820px) {
  header { grid-template-columns: 1fr auto; grid-template-areas: "brand theme" "titles titles"; align-items: center; row-gap: 8px; }
  .logo { height: 64px; }
}

.app-title {
  font-size: 21px; font-weight: 400; font-variant: small-caps; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 2px;
}
.method-name { font-weight: 700; font-size: 27px; margin: 0; line-height: 1.15; white-space: nowrap; }
.sub { color: var(--muted); font-size: 16px; height: 44px; display: flex; align-items: center; justify-content: center; line-height: 1.3; }
.formula { font-size: 19px; margin: 0; height: 64px; display: flex; align-items: center; justify-content: center; }
.formula p { margin: 0; }

/* one fixed-height row: method tabs over the plot, view controls over the sidebar */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: 20px; align-items: center; height: 44px; margin: 4px 0 6px; }
.family-tabs { display: flex; justify-content: center; gap: 8px; }
.family-tabs button { font-size: 16px; padding: 6px 16px; white-space: nowrap; }
.family-tabs .methods-btn { margin-left: 18px; color: var(--muted); }
.family-tabs .methods-btn:hover { color: var(--fg); }
.controls { display: flex; justify-content: flex-end; gap: 6px; }
.controls button { white-space: nowrap; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas: "stage aside" "byline byline";
  column-gap: 20px;
  margin-top: 8px;
  align-items: start;
}

#stage {
  grid-area: stage; position: relative; height: 600px; align-self: start;
  border: 1px solid var(--line); overflow: hidden; background: transparent;
}
#stage > .dash-graph { position: absolute; inset: 0; }
#stage .js-plotly-plot, #stage .dash-graph { height: 100%; }
.hint { position: absolute; left: 14px; bottom: 10px; font-size: 14px; color: var(--muted); pointer-events: none; z-index: 2; }

/* same height as the stage, controls pinned to its bottom, so switching methods never moves anything */
aside { grid-area: aside; height: 600px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overflow-x: hidden; }
.group { border-top: 1px solid var(--line); padding-top: 6px; }
.group:first-child { border-top: 0; padding-top: 0; }
.label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }

button {
  font: inherit; font-size: 15px; color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; cursor: pointer;
}
button:hover { border-color: var(--fg); }
button.on { background: var(--btn-on-bg); color: var(--btn-on-fg); border-color: var(--btn-on-bg); }

.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px; margin-top: 2px; }
.slider span { font-size: 15px; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.slider .dash-slider-container, .slider .rc-slider { grid-column: 1 / -1; }
.slider .rc-slider { margin: 2px 6px 8px; }
/* dcc.Slider (Dash 3 class names) ships its own stylesheet after ours, hence the weight */
.wrap .dash-slider-track { background: var(--line) !important; }
.wrap .dash-slider-range { background: var(--accent) !important; }
.wrap .dash-slider-thumb { border: 2px solid var(--accent) !important; background: var(--bg) !important; box-shadow: none !important; }
.wrap .dash-slider-mark { color: var(--muted) !important; font-family: inherit; font-size: 11px; }
.wrap .dash-slider-mark-outside-selection { color: var(--muted) !important; }
.wrap .dash-slider-tooltip { font-family: inherit; }
.wrap .dash-slider-wrapper { margin: 0 4px 2px; }
.wrap .rc-slider-rail { background: var(--line) !important; }
.wrap .rc-slider-track { background: var(--accent) !important; }
.wrap .rc-slider-handle { border: 2px solid var(--accent) !important; background: var(--bg) !important; box-shadow: none !important; opacity: 1 !important; }
.wrap .rc-slider-mark-text { color: var(--muted) !important; font-family: inherit; font-size: 11px; }
.wrap .rc-slider-mark-text-active { color: var(--fg) !important; }
.wrap .rc-slider-dot { border-color: var(--line) !important; background: var(--bg) !important; }
.wrap .rc-slider-dot-active { border-color: var(--accent) !important; }
.wrap .rc-slider-tooltip-inner { font-family: inherit; background: var(--fg); color: var(--bg); box-shadow: none; }

.seed { grid-template-columns: 1fr 90px; margin-top: 4px; }
.seed.step-row { grid-template-columns: 1fr auto; }
.seed input {
  font: inherit; font-size: 15px; width: 90px; color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; text-align: right;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { border: 1px solid var(--line); padding: 4px 10px; font-size: 14px; }
.stat b { display: block; font-weight: 500; font-size: 19px; font-variant-numeric: tabular-nums; }

.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 1px 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.bar { width: 18px; height: 3px; flex: none; }

.byline { grid-area: byline; padding-top: 8px; font-size: 15px; color: var(--fg); }
.byline strong { font-weight: 700; }
.byline .sep { color: var(--line); margin: 0 10px; }
.byline a { color: var(--logo); text-decoration: none; font-weight: 700; }
.byline a:hover { text-decoration: underline; }


.refs { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.refs h2 { font-size: 13px; font-weight: 700; color: var(--fg); margin: 0 0 2px; }
.refs ol { margin: 0; padding-left: 18px; }
.refs li { margin: 1px 0; line-height: 1.35; }
.refs a { color: var(--muted); }
.refs a:hover { color: var(--fg); }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "aside" "byline"; row-gap: 16px; }
  .toolbar { grid-template-columns: 1fr; height: auto; row-gap: 8px; }
  .controls { justify-content: center; }
  .titles { height: auto; }
  .method-name { white-space: normal; }
  aside { height: auto; overflow: visible; }
  .dsd-logo { width: 200px; }
  .method-name { font-size: 27px; }
  #stage { height: auto; aspect-ratio: 1 / 1; }
}
@media (max-width: 600px) {
  .byline { display: flex; flex-direction: column; gap: 2px; padding-bottom: 0; }
  .byline .sep { display: none; }
  .family-tabs button { font-size: 14px; padding: 5px 10px; }
}


/* Methods panel */
.modal { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); padding: 24px 12px; overflow-y: auto; }
.modal.open { display: block; }
.modal-card { max-width: 860px; margin: 0 auto; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 22px; }
.modal-body { padding: 8px 20px 20px; font-size: 15.5px; line-height: 1.5; }
.modal-body h3 { font-size: 19px; margin: 22px 0 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.modal-body p { margin: 4px 0 8px; }
.modal-body a { color: var(--logo); font-weight: 700; text-decoration: none; }
.modal-body a:hover { text-decoration: underline; }
.m-links { font-size: 14px; margin: 2px 0 8px; }
.m-cap { color: var(--muted); font-size: 14px; margin: 10px 0 4px; }
.m-fig { display: block; width: 100%; height: auto; margin: 0 auto 6px; border: 1px solid var(--line); background: #fff; }
.m-fig-narrow { width: 62%; }
.code pre { background: var(--card, rgba(127, 127, 127, 0.12)); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 13.5px; overflow-x: auto; margin: 4px 0 6px; }
.code code { font-family: Consolas, "Liberation Mono", Menlo, monospace; }
.m-table { border-collapse: collapse; font-size: 14px; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.m-table th, .m-table td { border: 1px solid var(--line); padding: 3px 10px; text-align: right; }
.m-table th { font-weight: 700; }
.m-table td:first-child, .m-table th:first-child { text-align: center; }
.code pre code, .code pre code.hljs { background: transparent !important; padding: 0 !important; }
/* highlight.js ships a light palette; set our own for both themes */
.code pre code, .code pre code.hljs, .code pre code .hljs-title, .code pre code .hljs-params { color: var(--fg) !important; }
.code pre code .hljs-keyword, .code pre code .hljs-built_in { color: #C0392B !important; }
.code pre code .hljs-number, .code pre code .hljs-string { color: #0057B7 !important; }
.code pre code .hljs-comment { color: var(--muted) !important; }
:root[data-theme="dark"] .code pre code .hljs-keyword, :root[data-theme="dark"] .code pre code .hljs-built_in { color: #FF7B6B !important; }
:root[data-theme="dark"] .code pre code .hljs-number, :root[data-theme="dark"] .code pre code .hljs-string { color: #FFD500 !important; }
