/* Mechanical Flower — Exploded View : poster overlay styling.
   1 poster pixel (reference image is 1122 x 1402) == var(--u) inside #overlay. */

:root {
  --serif: "Times New Roman", Times, "Liberation Serif", "Nimbus Roman", "Tinos", serif;
  --ink: #1c1813;
  --ink2: #4a4339;
  --ink3: #6a6256;
  --gold: #b08a55;
  --gold-d: #8a6430;
  --gold-soft: rgba(176, 138, 85, 0.55);
  --leader: #4a3a2a;
  --parch: #ece5d3;
  --parch-d: #e3dac2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #14110d;
  color: var(--ink);
  font-family: var(--serif);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #241d15 0%, #14110d 70%);
}

/* ---------- the poster: uniform scale-to-fit, aspect 1122:1402 ---------- */
#poster {
  position: relative;
  flex: none;
  aspect-ratio: 1122 / 1402;
  width: min(100vw, calc(100dvh * 1122 / 1402));
  container-type: size;
  background: #eae3d1;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.55);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--serif);
  color: var(--ink);
  --u: calc(100cqw / 1122);
  --fade: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  user-select: none;
}

#overlay svg.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.ov-abs { position: absolute; margin: 0; white-space: nowrap; }
.ln { display: block; white-space: nowrap; }

/* ---------- static art (frame, rules, boxes, sketches) ---------- */
.gl { fill: none; stroke: var(--gold); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.gl.soft { stroke-opacity: 0.55; }
.gl.thin { stroke-width: 0.8; }
.gfill { fill: var(--gold); stroke: none; }
.sk { fill: none; stroke: #6d655a; stroke-width: 0.8; stroke-linecap: round; stroke-linejoin: round; }
.sk.faint { stroke: #8f877b; stroke-width: 0.55; }
.sk.fillp { fill: rgba(238, 232, 218, 0.96); }
.dim { fill: none; stroke: #3d352c; stroke-width: 0.9; }
.dimhead { fill: #3d352c; stroke: none; }
.guide { fill: none; stroke: #7c7468; stroke-width: 0.6; stroke-opacity: 0.6; }

/* ---------- titles / taglines ---------- */
.ov-title {
  font-size: calc(26 * var(--u));
  line-height: calc(30 * var(--u));
  font-weight: 700;
  letter-spacing: 0.1em;
  padding-left: 0.1em;
  text-align: center;
  color: #15110c;
}
.ov-sub {
  font-size: calc(17 * var(--u));
  line-height: calc(20 * var(--u));
  font-style: italic;
  letter-spacing: 0.015em;
  text-align: center;
  color: #1f1a14;
}
.ov-tag-head {
  font-size: calc(13.2 * var(--u));
  line-height: calc(18 * var(--u));
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-align: center;
  color: #26211a;
}
.ov-tag-body {
  font-size: calc(15 * var(--u));
  line-height: calc(17 * var(--u));
  font-style: italic;
  text-align: center;
  color: #3b342b;
}
.ov-footer {
  font-size: calc(13.2 * var(--u));
  line-height: calc(21 * var(--u));
  letter-spacing: 0.33em;
  padding-left: 0.33em;
  text-align: center;
  color: #3a352d;
}

/* ---------- callouts ---------- */
.callout {
  position: absolute;
  margin: 0;
  pointer-events: auto;
  cursor: pointer;
  outline: none;
  opacity: var(--fade);
  -webkit-tap-highlight-color: transparent;
}
#overlay.co-off .callout,
#overlay.co-off .co-dot { visibility: hidden; pointer-events: none; }

.co-title {
  display: inline-block;
  margin: 0;
  padding: 0 0 calc(5 * var(--u));
  font-size: calc(17.5 * var(--u) * var(--ts, 1));
  line-height: calc(21 * var(--u));
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink);
  -webkit-text-stroke: calc(0.35 * var(--u)) currentColor;
  border-bottom: calc(1 * var(--u)) solid rgba(168, 128, 72, 0.85);
  white-space: nowrap;
  transition: color 0.18s, border-color 0.18s;
}
.co-body {
  margin: calc(2 * var(--u)) 0 0;
  font-size: calc(13.2 * var(--u));
  line-height: calc(15.2 * var(--u));
  letter-spacing: 0.012em;
  color: #332d25;
  -webkit-text-stroke: calc(0.15 * var(--u)) currentColor;
  transition: color 0.18s, opacity 0.18s;
}
.callout:focus-visible { outline: 1px dotted var(--gold-d); outline-offset: calc(5 * var(--u)); }
.callout.hot .co-title { color: #6a4510; border-bottom-color: #a9741c; }
.callout.hot .co-body { color: #2b2418; }
.has-hot .callout:not(.hot) .co-title,
.has-hot .callout:not(.hot) .co-body { opacity: 0.5; }

/* leaders: one full-poster svg */
.leader { fill: none; stroke: var(--leader); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.leader .dash { stroke-dasharray: 3 2.6; }
.leader .end { fill: var(--leader); stroke: none; }
.leader.hot { stroke: #7a4e10; stroke-width: 1.7; }
.leader.hot .end { fill: #7a4e10; }

/* narrow-mode dots (hidden on wide layout) */
.co-dot {
  display: none;
  position: absolute;
  pointer-events: auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: var(--fade);
  transform: translate(-50%, -50%);
}
.co-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(15 * var(--u));
  height: calc(15 * var(--u));
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--parch);
  border: calc(3 * var(--u)) solid var(--leader);
}
.co-dot.hot::after { border-color: #a9741c; background: #a9741c; }
.co-dot:focus-visible::after { outline: 2px solid var(--gold-d); outline-offset: 2px; }

/* ---------- inset frames ---------- */
.inset-title {
  font-size: calc(11.6 * var(--u));
  line-height: calc(14 * var(--u));
  letter-spacing: 0.14em;
  color: #2a241c;
}
.inset-cap {
  font-size: calc(13 * var(--u));
  line-height: calc(15 * var(--u));
  font-style: italic;
  color: #4a4339;
}
.inset-win {
  position: absolute;
  border: 1px solid var(--gold);
  background: transparent;
  pointer-events: none;
}

/* ---------- bloom sequence ---------- */
.ov-bloom-title {
  font-size: calc(11.2 * var(--u));
  line-height: calc(14 * var(--u));
  letter-spacing: 0.19em;
  color: #2a241c;
}
.stage {
  position: absolute;
  pointer-events: auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: var(--ink3);
  -webkit-tap-highlight-color: transparent;
}
.stage svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.stage .bs-label {
  position: absolute;
  left: -6%;
  right: -6%;
  text-align: center;
  font-size: calc(9.4 * var(--u));
  line-height: calc(12 * var(--u));
  letter-spacing: 0.13em;
  padding-left: 0.13em;
  color: #3b352c;
  white-space: nowrap;
  transition: color 0.2s;
}
.stage .lp { fill: rgba(238, 232, 218, 0.96); stroke: #6d655a; stroke-width: 0.8; stroke-linejoin: round; transition: stroke 0.2s; }
.stage .lv { fill: none; stroke: #8f877b; stroke-width: 0.5; stroke-linecap: round; }
.stage .st { fill: none; stroke: #6d655a; stroke-width: 0.8; stroke-linecap: round; stroke-linejoin: round; }
.stage .gr { stroke: #7c7468; stroke-width: 0.8; fill: none; }
.stage .ax { stroke: #8f877b; stroke-width: 0.7; stroke-dasharray: 2 2; fill: none; }
.stage:hover .lp, .stage.on .lp { stroke: #6a4a1c; }
.stage:hover .gr, .stage.on .gr { stroke: var(--gold-d); }
.stage.on .bs-label, .stage:hover .bs-label { color: var(--gold-d); }
.stage.on .bs-label { font-weight: 700; }
.stage:focus-visible { outline: 1px dotted var(--gold-d); outline-offset: 3px; }

/* ---------- dimension panel ---------- */
.ov-dim-label {
  font-size: calc(13.7 * var(--u));
  line-height: calc(16 * var(--u));
  color: #1f1a14;
}
.ov-dim-caption {
  font-size: calc(9.2 * var(--u));
  line-height: calc(12 * var(--u));
  letter-spacing: 0.135em;
  padding-left: 0.14em;
  text-align: center;
  color: #3a342b;
}

/* ---------- controls dock ---------- */
.dock {
  position: absolute;
  left: 48.1%; /* centred on poster x=540 so it clears the Modular Stem callout text */
  bottom: calc(22.5 * var(--u));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.25em 0.8em 0.25em 0.35em;
  font-family: var(--serif);
  font-size: clamp(9px, calc(10 * var(--u)), 14px);
  line-height: 1.1;
  color: var(--ink2);
  white-space: nowrap;
  pointer-events: auto;
  background: rgba(236, 229, 211, 0.86);
  border: 1px solid rgba(176, 138, 85, 0.75);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0.8;
  transition: opacity 0.2s;
}
.dock:hover, .dock:focus-within { opacity: 1; }
.dock label { display: flex; align-items: center; gap: 0.5em; letter-spacing: 0.04em; }
.dock .sep { width: 1px; align-self: stretch; margin: 0.15em 0; background: var(--gold-soft); }

.dock button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.dock .ctl-play {
  width: 2em;
  height: 2em;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--gold-d);
  background: var(--parch);
}
.dock .ctl-play svg { width: 0.95em; height: 0.95em; fill: var(--gold-d); }
.dock .ctl-play .i-pause { display: none; }
.dock .ctl-play.is-playing .i-pause { display: block; }
.dock .ctl-play.is-playing .i-play { display: none; }
.dock .ctl-play:hover { background: #f4eedd; }

.dock input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 5em;
  height: 1.6em;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}
.dock input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--gold-d) var(--p), rgba(176, 138, 85, 0.4) var(--p));
}
.dock input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1em;
  height: 1em;
  margin-top: calc(-0.5em + 1.5px);
  border-radius: 50%;
  border: 1.5px solid var(--gold-d);
  background: var(--parch);
}
.dock input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(176, 138, 85, 0.4);
}
.dock input[type="range"]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--gold-d); }
.dock input[type="range"]::-moz-range-thumb {
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  border: 1.5px solid var(--gold-d);
  background: var(--parch);
}
.dock input[type="range"]:focus-visible { outline: 1px dotted var(--gold-d); outline-offset: 2px; border-radius: 4px; }
.dock .ctl-play:focus-visible,
.dock .seg button:focus-visible { outline: 1px dotted var(--gold-d); outline-offset: 2px; }

.dock .seg { display: flex; border: 1px solid var(--gold-d); border-radius: 999px; overflow: hidden; }
.dock .seg button {
  padding: 0.25em 0.7em;
  border: 0;
  background: transparent;
  letter-spacing: 0.04em;
}
.dock .seg button[aria-pressed="true"] { background: var(--gold-d); color: var(--parch); }

.hint {
  position: absolute;
  left: 50%;
  top: calc(60 * var(--u));
  transform: translateX(-50%);
  padding: 0.15em 0.9em;
  font-size: clamp(9px, calc(11.5 * var(--u)), 14px);
  font-style: italic;
  letter-spacing: 0.06em;
  color: var(--ink3);
  white-space: nowrap;
  pointer-events: none;
  background: rgba(236, 229, 211, 0.6);
  border-radius: 999px;
  transition: opacity 1.2s ease;
}
.hint.gone { opacity: 0; }

/* ---------- loading ---------- */
#loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #ebe4d2;
  color: var(--ink3);
  font-family: var(--serif);
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
}
#loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
.ld-ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(176, 138, 85, 0.35);
  border-top-color: var(--gold-d);
  animation: ld-spin 1.1s linear infinite;
}
.ld-text { margin: 0; font-style: italic; letter-spacing: 0.06em; font-size: 15px; }
@keyframes ld-spin { to { transform: rotate(360deg); } }

.noscript { color: #ddd3bd; text-align: center; padding: 1em; }

/* ---------- readout sheet (narrow viewports only) ---------- */
#sheet {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 30px;
  background: var(--parch);
  border-top: 1px solid var(--gold);
  color: var(--ink);
  font-family: var(--serif);
}
#sheet .dock {
  position: static;
  transform: none;
  width: 100%;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 18px;
  opacity: 1;
  background: rgba(255, 252, 244, 0.6);
}
#sheet .dock label { flex: 1 1 130px; }
#sheet .dock input[type="range"] { flex: 1; width: auto; min-width: 70px; height: 28px; }
#sheet .dock .ctl-play { width: 38px; height: 38px; }
#sheet .dock .seg button { padding: 7px 12px; }
#sheet .hint { position: static; transform: none; align-self: center; font-size: 12.5px; background: none; }

#readout {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 108px;
}
#readout .ro-btn {
  flex: none;
  width: 44px;
  border: 1px solid var(--gold-d);
  border-radius: 10px;
  background: rgba(255, 252, 244, 0.6);
  color: var(--gold-d);
  font: 28px/1 var(--serif);
  cursor: pointer;
}
#readout .ro-btn:active { background: var(--parch-d); }
#readout .ro-btn:focus-visible { outline: 2px solid var(--gold-d); outline-offset: 2px; }
#readout .ro-text { flex: 1; min-width: 0; }
#readout .ro-title {
  margin: 0 0 8px;
  padding-bottom: 6px;
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.03em;
  -webkit-text-stroke: 0.3px currentColor;
  border-bottom: 1px solid rgba(168, 128, 72, 0.85);
}
#readout .ro-body { margin: 0; font-size: 16px; line-height: 1.4; color: var(--ink2); }
#readout .ro-count { display: block; margin-top: 8px; font-size: 12px; letter-spacing: 0.15em; color: var(--ink3); }

@media (max-width: 760px) {
  html, body { height: auto; background: var(--parch); }
  body { justify-content: flex-start; overflow-x: hidden; overflow-y: auto; background: var(--parch); }
  #poster { width: 100vw; box-shadow: none; }
  #sheet { display: flex; flex: 1 0 auto; }
  .callout .co-title, .callout .co-body { visibility: hidden; }
  .callout { pointer-events: none; }
  .co-dot { display: block; }
  .leader { stroke-width: 2.4; }
  .leader.hot { stroke-width: 3.6; }
  .leader .end { r: 4.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .ld-ring { animation: none; }
  * { transition-duration: 0.01s !important; }
}

/* ---------- studio theme: light type on the dark backdrop ---------- */
#poster[data-theme="studio"], #poster[data-tone="dark"] {
  --ink: #f1e8d4;
  --ink2: #d9cdb4;
  --ink3: #b9ab90;
  --gold: #c9a063;
  --gold-d: #e0b873;
  --leader: #cdb88f;
}
#poster:is([data-theme="studio"], [data-tone="dark"]) :is(.ov-title, .ov-sub, .ov-tag-head, .ov-tag-body, .ov-footer, .inset-title, .ov-bloom-title, .ov-dim-label, .ov-dim-caption) { color: #eadfc6; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .co-body,
#poster:is([data-theme="studio"], [data-tone="dark"]) .inset-cap { color: #cfc2a8; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .callout.hot .co-title { color: #ffd98f; border-bottom-color: #e0b873; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .callout.hot .co-body { color: #f6ecd6; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .dim { stroke: #cdbf9f; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .dimhead { fill: #cdbf9f; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .stage .bs-label { color: #cdbf9f; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .leader.hot { stroke: #e0b873; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .leader.hot .end { fill: #e0b873; }
#poster :is(.ov-title, .ov-sub, .ov-tag-head, .ov-tag-body, .ov-footer, .inset-title, .inset-cap, .ov-bloom-title, .ov-dim-label, .ov-dim-caption, .bs-label) { transition: color 0.5s; }

#poster:is([data-theme="studio"], [data-tone="dark"]) .dock { background: rgba(28, 23, 18, 0.82); border-color: rgba(201, 160, 99, 0.7); color: #e6dac0; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .dock .ctl-play { background: #2a221a; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .dock .seg button[aria-pressed="true"] { background: var(--gold-d); color: #1c1813; }
#poster:is([data-theme="studio"], [data-tone="dark"]) .hint { background: rgba(28, 23, 18, 0.7); color: #cdbf9f; }
