/* MODDYS surfaces chassis — the studio's machine-room chrome on a built page.
   Opt-in only: every rule is scoped to body.chrome-surfaces, and the scene /
   hero keep the page's own look palette. Loaded after finish.css, so the
   paper/graphite tokens, fonts and grain are already defined. */

body.chrome-surfaces{
  --surf-strip-h:34px;
  --surf-foot-h:28px;
  --surf-pad:clamp(10px,1.6vw,18px);
}

/* ---------- top strip: mark · crumb · finish · studio ---------- */
body.chrome-surfaces .surf-strip{
  position:fixed;left:0;right:0;top:0;height:var(--surf-strip-h);z-index:70;
  box-sizing:border-box;
  display:flex;align-items:center;gap:14px;padding:0 var(--surf-pad);
  background-color:var(--panel);
  background-image:var(--grain);background-size:var(--grain-size);background-blend-mode:var(--grain-blend);
  border-bottom:1px solid var(--line2);
  color:var(--ink);
  font:500 9px/1 var(--mono,ui-monospace,Consolas,monospace);
  letter-spacing:.14em;text-transform:uppercase;
}
body.chrome-surfaces .surf-mark{
  display:inline-flex;align-items:center;gap:7px;flex:0 0 auto;
  color:var(--ink);text-decoration:none;
  font:700 10.5px/1 var(--sans,system-ui,sans-serif);letter-spacing:.18em;white-space:nowrap;
}
body.chrome-surfaces .surf-glyph{
  width:9px;height:9px;background:var(--ink);position:relative;flex:0 0 auto;
}
body.chrome-surfaces .surf-glyph::after{
  content:"";position:absolute;left:0;right:0;bottom:0;height:3px;background:var(--amber);
}
body.chrome-surfaces .surf-crumb{
  margin:0;display:flex;align-items:center;gap:7px;min-width:0;
  color:var(--ink3);white-space:nowrap;
}
body.chrome-surfaces .surf-crumb b{
  color:var(--ink);font-weight:500;overflow:hidden;text-overflow:ellipsis;
}
body.chrome-surfaces .surf-crumb-sep{color:var(--line2)}
body.chrome-surfaces .surf-spacer{flex:1 1 auto;min-width:0}

/* The shared chip is 28px tall for the studio mast; the strip is 34px. */
body.chrome-surfaces .surf-strip .finish{position:relative;display:flex;align-items:center;flex:0 0 auto}
body.chrome-surfaces .surf-strip .finish summary{
  height:22px;padding:0 7px 0 6px;box-sizing:border-box;
  border-color:var(--line2);background-color:transparent;
  font:500 8.5px/1 var(--mono,ui-monospace,Consolas,monospace);letter-spacing:.12em;
}
body.chrome-surfaces .surf-strip .finish summary .fsw{width:10px;height:10px}
body.chrome-surfaces .surf-strip .finish .fpanel{top:calc(100% + 5px);z-index:80}

body.chrome-surfaces .surf-open{
  display:inline-flex;align-items:center;gap:5px;flex:0 0 auto;
  height:22px;padding:0 9px;border:1px solid var(--ink);box-sizing:border-box;
  background:var(--ink);color:var(--ground);
  font:500 8.5px/1 var(--mono,ui-monospace,Consolas,monospace);
  letter-spacing:.1em;text-transform:uppercase;text-decoration:none;white-space:nowrap;
}
body.chrome-surfaces .surf-open:hover,
body.chrome-surfaces .surf-open:focus-visible{
  background:var(--amber);border-color:var(--amber);color:var(--amber-ink);
}
body.chrome-surfaces .surf-arrow{font-size:10px;line-height:1}

/* ---------- bottom ink bar ---------- */
body.chrome-surfaces .surf-foot{
  position:fixed;left:0;right:0;bottom:0;height:var(--surf-foot-h);z-index:70;
  box-sizing:border-box;
  display:flex;align-items:center;gap:14px;padding:0 var(--surf-pad);
  background:var(--strip);color:var(--strip-dim);
  font:500 8px/1 var(--mono,ui-monospace,Consolas,monospace);
  letter-spacing:.14em;text-transform:uppercase;
}
body.chrome-surfaces .surf-foot-full::before{
  content:"";display:inline-block;width:5px;height:5px;margin-right:8px;
  background:var(--amber);vertical-align:1px;
}
body.chrome-surfaces .surf-foot-mini{display:none}
body.chrome-surfaces .surf-foot a{
  margin-left:auto;color:var(--strip-ink);text-decoration:none;
  border-bottom:1px solid var(--strip-dim);padding-bottom:1px;white-space:nowrap;
}
body.chrome-surfaces .surf-foot a:hover,
body.chrome-surfaces .surf-foot a:focus-visible{
  color:var(--amber);border-bottom-color:var(--amber);
}

/* ---------- plate (optional; rendered only when the hero cannot collide) ---------- */
body.chrome-surfaces .surf-plate{
  position:fixed;left:var(--surf-pad);top:calc(var(--surf-strip-h) + 84px);z-index:60;
  max-width:min(270px,70vw);padding:8px 10px 9px;box-sizing:border-box;
  border:1px solid var(--line2);color:var(--ink);
  background-color:var(--panel);
  background-image:var(--grain);background-size:var(--grain-size);background-blend-mode:var(--grain-blend);
  font:500 8px/1.4 var(--mono,ui-monospace,Consolas,monospace);
  letter-spacing:.12em;text-transform:uppercase;pointer-events:none;
}
body.chrome-surfaces .surf-plate b{
  display:block;margin:4px 0 3px;
  font:600 12px/1.2 var(--sans,system-ui,sans-serif);letter-spacing:.01em;text-transform:none;
}
body.chrome-surfaces .surf-plate em{display:block;font-style:normal;color:var(--ink3)}

/* ---------- keep the page's own layout clear of the fixed strips ---------- */
/* Non-scroll hero shape: .page is fixed inset:0, so trim the box instead of
   adding padding (padding would push the bottom-aligned hero up twice). */
body.chrome-surfaces .page{top:var(--surf-strip-h);bottom:var(--surf-foot-h);--teal:#1f7f7f}
/* finish.css owns a --teal token for chrome; a dark-surface page authors
   #8fd6d2. Restore the page value so the headline never flips with the finish. */
body.chrome-surfaces.chrome-dark .page{--teal:#8fd6d2}
/* Scroll shapes already reset .page to position:relative, so reserve the strips
   with padding and keep the sticky header under the top strip. */
body.chrome-surfaces.chrome-scroll .page,
body.chrome-surfaces .page.showcase-page,
body.chrome-surfaces .page.chapters-page{
  top:auto;bottom:auto;
  padding-top:calc(clamp(20px,3.4vw,40px) + var(--surf-strip-h));
  padding-bottom:calc(clamp(20px,3.4vw,40px) + var(--surf-foot-h));
}
body.chrome-surfaces .top{top:var(--surf-strip-h)}
/* The no-WebGL notice is page UI at the bottom edge; lift it over the ink bar. */
body.chrome-surfaces #nogfx{bottom:calc(16px + var(--surf-foot-h))}

/* ---------- narrow: the strip stays one line, the footer shortens ---------- */
@media (max-width:520px){
  /* The chip sits near the right edge on a phone; anchor its menu to the
     viewport so a 246px panel can never run off the left or right. */
  body.chrome-surfaces .surf-strip .finish .fpanel{
    position:fixed;left:10px;right:10px;top:calc(var(--surf-strip-h) + 5px);
    width:auto;max-width:none;
  }
}
@media (max-width:760px){
  body.chrome-surfaces .surf-strip{gap:9px;padding:0 10px}
  body.chrome-surfaces .surf-open{padding:0 7px}
  body.chrome-surfaces .surf-crumb{font-size:8.5px}
}
@media (max-width:640px){
  body.chrome-surfaces .surf-strip{gap:8px}
  body.chrome-surfaces .surf-crumb-kicker,
  body.chrome-surfaces .surf-crumb-sep{display:none}
  body.chrome-surfaces .surf-mark{letter-spacing:.13em}
}
@media (max-width:380px){
  body.chrome-surfaces .surf-crumb{display:none}
  body.chrome-surfaces .surf-foot-full{display:none}
  body.chrome-surfaces .surf-foot-mini{display:inline}
}

@media (prefers-reduced-motion:reduce){
  body.chrome-surfaces .surf-open{transition:none}
}
