/*
 * Desktop scale — 45 D45.4 / PRD-appearance-settings FR-41–FR-43.
 *
 * The default is the adaptive ladder. A fixed choice overrides it through the html[data-scale] attribute that
 * theme.js writes before paint from the stored guest value (or the server-rendered account value on /me/settings).
 * `zoom` scales layout and type together. The viewport-unit lengths inside the zoomed subtree are divided by the
 * scale so sticky and overlay surfaces keep the height of the viewport (45 D45.4).
 */

html {
  --desktop-scale: 0.875;
}

@media (max-width: 1080px) {
  html {
    --desktop-scale: 1;
  }
}

@media (min-width: 1200px) {
  html {
    --desktop-scale: 1;
  }
}

@media (min-width: 2000px) {
  html {
    --desktop-scale: 1.25;
  }
}

@media (min-width: 2400px) {
  html {
    --desktop-scale: 1.5;
  }
}

@media (min-width: 2800px) {
  html {
    --desktop-scale: 1.75;
  }
}

@media (min-width: 3200px) {
  html {
    --desktop-scale: 2;
  }
}

html[data-scale="0.875"] {
  --desktop-scale: 0.875;
}

html[data-scale="1"] {
  --desktop-scale: 1;
}

html[data-scale="1.25"] {
  --desktop-scale: 1.25;
}

html[data-scale="1.5"] {
  --desktop-scale: 1.5;
}

html[data-scale="1.75"] {
  --desktop-scale: 1.75;
}

html[data-scale="2"] {
  --desktop-scale: 2;
}

body {
  zoom: var(--desktop-scale);
}

.shell {
  min-height: calc((100vh - 104px) / var(--desktop-scale));
}

@media (min-width: 821px) {
  .rail,
  .aside {
    max-height: calc((100vh - var(--topbar-h, 76px)) / var(--desktop-scale));
  }
}

dialog.sheet {
  width: min(460px, calc(92vw / var(--desktop-scale)));
  max-height: calc(85vh / var(--desktop-scale));
}

/* The size control reuses the .themesel / .themebtn / .picker-menu / .skin-opt vocabulary from shell.css. */
.scale-menu {
  width: 248px;
  padding: 8px;
}

.scale-menu .scale-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 4px 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--link);
}

.scale-menu .spv {
  font-variant-numeric: tabular-nums;
}

.scale-fixed {
  margin-top: 5px;
  padding: 7px 9px 6px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--control);
}

.scale-fixed[data-active="true"] {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.scale-fixed .lbl {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 800;
}

.scale-fixed .lbl .val {
  font-variant-numeric: tabular-nums;
  color: var(--link);
}

.scale-stops {
  position: relative;
  display: flex;
  align-items: flex-start;
  margin: 10px 0 2px;
}

.scale-stops::before {
  content: "";
  position: absolute;
  left: 8.333%;
  right: 8.333%;
  top: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--border);
}

.scale-stop {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.scale-stop input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.scale-stop .dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
}

.scale-stop input:checked + .dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.scale-stop input:focus-visible + .dot {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scale-stop .num {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scale-stop input:checked ~ .num {
  color: var(--ink);
}

.scale-stop .num[data-warn] {
  color: var(--tier-review);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.scale-fixed .lbl .val[data-warn] {
  color: var(--tier-review);
}

.scale-hint {
  margin: 6px 0 0;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--tier-review);
}

/* The control is inert where the adaptive ladder is flat (821–1080 px); below 821 it lives in Options. */
@media (min-width: 821px) and (max-width: 1080px) {
  .scale-sel {
    display: none;
  }
}
