/*
 * demo.css — the page around the window. The window itself is drawn by app.css
 * (a copy of the app's own sheets); this file adds the page furniture and
 * swaps the before and after figures.
 *
 * The switch needs no script: the state is a checked radio and :has() reads it.
 */

/* The app's global.css locks a window to its viewport; this page scrolls. */
html,
body {
  height: auto;
}

body {
  overflow: visible;
  user-select: auto;
  font-size: 17px;
  line-height: 1.55;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ----- Page furniture ----- */

.demo-shell {
  width: 100%;
  max-width: 1028px;
  margin: 0 auto;
  padding: 0 24px;
}

.demo-top {
  border-bottom: 1px solid var(--border-subtle);
}

.demo-top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-medium);
  height: 64px;
}

.demo-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}

.demo-brand img {
  border-radius: var(--radius-md);
}

.demo-back {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.12s ease-out;
}

.demo-back:hover {
  color: var(--text-primary);
}

.demo-main {
  padding-top: 56px;
  padding-bottom: 96px;
}

.demo-main h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 44px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.demo-lede {
  max-width: 62ch;
  margin: 0 0 36px;
  font-size: 18px;
  color: var(--text-secondary);
}

.demo-caption {
  margin: 18px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

.demo-notes {
  display: grid;
  gap: 14px;
  max-width: 66ch;
  margin: 44px auto 0;
  padding: 0;
  list-style: none;
}

.demo-notes li {
  position: relative;
  padding-left: 22px;
  font-size: 16px;
  color: var(--text-secondary);
}

.demo-notes li::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.demo-notes strong {
  font-weight: 800;
  color: var(--text-primary);
}

.demo-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 52px 0 0;
}

.demo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 26px;
  border-radius: var(--radius-pill);
  background: var(--action-primary);
  color: var(--on-action-primary);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.12s ease-out;
}

.demo-button:hover {
  background: var(--action-primary-hover);
}

.demo-link {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.12s ease-out;
}

.demo-link:hover {
  color: var(--text-primary);
}

/* ----- The before / after switch ----- */

.demo-switch {
  display: flex;
  justify-content: center;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--fill-secondary);
}

.demo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.demo-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.12s ease-out, background-color 0.12s ease-out;
}

.demo-option:hover {
  color: var(--text-primary);
}

.demo-input:checked + .demo-option {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.demo-input:focus-visible + .demo-option {
  outline: 2px solid var(--action-primary);
  outline-offset: 2px;
}

/* ----- The two states ----- */

.only-after {
  display: none;
}

.demo:has(#demo-after:checked) .only-before {
  display: none;
}

.demo:has(#demo-after:checked) .only-after {
  display: revert;
}

/*
 * The disk bar after the clean: the two cleaned categories give their width
 * back, and the bytes, now in the Recycle Bin, join Everything else.
 */
.demo:has(#demo-after:checked) .disk-bar-segment--app-caches,
.demo:has(#demo-after:checked) .disk-bar-segment--dev-tools {
  --grow: 0;
  min-width: 0;
}

.demo:has(#demo-after:checked) .disk-bar-segment--everything-else {
  --grow: 150.8;
}

/* ----- The window ----- */

.demo-viewport {
  overflow-x: auto;
}

.demo-window {
  width: 980px;
  height: 700px;
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-base);
  box-shadow: 0 1px 2px rgba(43, 42, 40, 0.08), 0 20px 44px rgba(43, 42, 40, 0.14);
  /* The title bar is fixed to the window, not to the browser. */
  contain: paint;
  /* A picture of a window, not a window: nothing inside is a live control. */
  pointer-events: none;
}

.demo-window .app {
  font-size: var(--type-body);
  line-height: 1.35;
  user-select: none;
}

/* The app sets these inline; here they come from --grow so the bar can move. */
.demo-window .disk-bar-segment {
  flex-grow: var(--grow);
  flex-shrink: 1;
  flex-basis: 0;
  min-width: 4px;
  transition:
    flex-grow 520ms cubic-bezier(0.33, 1, 0.68, 1),
    min-width 520ms cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.15s ease-out;
}

/* A 980px app on a narrower page: the whole window zooms down, untouchably. */
@media (max-width: 1039px) {
  .demo-window {
    zoom: 0.85;
  }
}

@media (max-width: 899px) {
  .demo-window {
    zoom: 0.73;
  }
}

@media (max-width: 779px) {
  .demo-window {
    zoom: 0.61;
  }
}

@media (max-width: 659px) {
  .demo-window {
    zoom: 0.49;
  }
}

@media (max-width: 539px) {
  .demo-window {
    zoom: 0.38;
  }
}

@media (max-width: 429px) {
  .demo-window {
    zoom: 0.34;
  }
}

@media (max-width: 379px) {
  .demo-window {
    zoom: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-window .disk-bar-segment {
    transition-duration: 1ms;
  }
}
