/*
  Caelion workspace · v5 · what is still borrowed from v4

  v5 has its own shell (shell.css) and its own components (base.css). Two small parts of the
  v4 shell are still in use by pages that have not been redrawn yet, and they live here until
  those pages are: the segmented control the Appearance page uses, and the Moon's small face.
  Nothing else from the v4 shell is loaded in v5.
*/

:root[data-layout="v5"] {
  font-family: var(--font-ui);
  background: var(--s-frame);
  interpolate-size: allow-keywords;

  body {
    background: var(--s-frame);
    color: var(--t-1);
  }

  ::selection {
    background: color-mix(in oklch, var(--a-fill) 36%, transparent);
  }

  :focus-visible {
    outline: 2px solid var(--a-ring);
    outline-offset: 2px;
  }

  /* ---------- Segmented control (v5.js measures the thumb) ---------- */

  .v4-seg {
    --thumb-x: 0px;
    --thumb-w: 0px;
    position: relative;
    display: flex;
    padding: 3px;
    border-radius: calc(min(var(--r-ctl), 12px) + 1px);
    background: var(--f-hover);
    box-shadow: inset 0 0 0 1px var(--b-0);
  }

  .v4-seg::before {
    content: "";
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: var(--thumb-w);
    border-radius: min(var(--r-ctl), 10px);
    background: var(--s-1);
    box-shadow: var(--sh-1), 0 0 0 1px var(--b-0);
    transform: translateX(var(--thumb-x));
    transition: transform var(--d-3) var(--e-out), width var(--d-3) var(--e-out);
  }

  .v4-seg:not([data-ready])::before {
    display: none;
  }

  .v4-seg > :is(button, a) {
    position: relative;
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: min(var(--r-ctl), 10px);
    background: transparent;
    color: var(--t-3);
    font-size: .8rem;
    font-weight: 560;
    white-space: nowrap;
    transition: color var(--d-1) ease;
  }

  .v4-seg > :is(button, a) .icon {
    width: 15px;
    height: 15px;
  }

  .v4-seg > :is(button, a):hover,
  .v4-seg > :is([aria-pressed="true"], [aria-checked="true"], [aria-current="true"]) {
    color: var(--t-1);
  }

  .v4-seg:not([data-ready]) > :is([aria-pressed="true"], [aria-checked="true"], [aria-current="true"]) {
    background: var(--s-1);
    box-shadow: var(--sh-1), 0 0 0 1px var(--b-0);
  }

  /* ---------- The Moon's small face (until the agent window draws its own) ---------- */

  .v4-orb {
    --orb: #ece7dd;
    --orb-size: 28px;
    position: relative;
    display: block;
    flex: none;
    width: var(--orb-size);
    height: var(--orb-size);
    border-radius: 50%;
    background:
      radial-gradient(circle at 32% 26%, oklch(1 0 0 / .85), transparent 42%),
      radial-gradient(circle at 70% 82%, oklch(0 0 0 / .2), transparent 60%),
      var(--orb);
    box-shadow: inset 0 -1px 2px oklch(0 0 0 / .14), 0 1px 2px oklch(0 0 0 / .16);
  }

  .v4-orb i {
    position: absolute;
    top: 40%;
    width: 11%;
    height: 22%;
    border-radius: 50%;
    background: oklch(.22 .02 265);
    transform-origin: 50% 60%;
  }

  .v4-orb[data-eye="light"] i {
    background: oklch(.97 0 0);
  }

  .v4-orb i:first-child {
    left: 33%;
  }

  .v4-orb i:last-child {
    right: 33%;
  }

  .v4-orb:not(.is-awake) i {
    height: 6%;
    top: 49%;
  }

  .v4-orb.is-waiting::after {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: var(--a-fill);
    box-shadow: 0 0 0 2px var(--s-frame);
  }
}

/* ---------- Between pages ---------- */

/*
  Only the sheet changes from page to page, so the chrome is left out of the transition and the
  new page simply fades in over the old one.
*/
:root[data-layout="v5"]::view-transition-old(root) {
  animation: none;
}

:root[data-layout="v5"]::view-transition-new(root) {
  animation: w5-page-in 150ms ease both;
}

:root[data-layout="v5"].theme-reveal::view-transition-new(root) {
  animation: none;
}

@keyframes w5-page-in {
  from { opacity: 0 }
}

@media (prefers-reduced-motion: no-preference) {
  :root[data-layout="v5"]:not([data-motion="reduced"]) {
    .v4-orb.is-awake i {
      animation: w5-blink 6.4s infinite;
    }

    .v4-orb.is-awake i:last-child {
      animation-delay: .02s;
    }
  }
}

@keyframes w5-blink {
  0%, 46%, 50%, 100% { transform: scaleY(1) }
  48% { transform: scaleY(.12) }
}

:root[data-layout="v5"][data-motion="reduced"] *,
:root[data-layout="v5"][data-motion="reduced"] *::before,
:root[data-layout="v5"][data-motion="reduced"] *::after {
  transition-duration: 1ms !important;
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
}
