/* Tactile controls: the workspace's control language, carried onto the site.
   Mirrors the platform's tactile-controls.css (Aperture Chat v0.5.14):
   - Recessed: tracks hold choices, wells hold a row of related actions.
   - Lit: the current choice and the main action are the teal key.
   - Raised: everyday buttons sit up and press in when clicked.
   - Grooves: a key that stands alone sits in a channel cut into the surface, the
     way the Drafts actions sit in their well.
   Loaded after the page styles so it restyles the shared controls. */

:root {
  --key-teal: #087d8b;
  --lit: linear-gradient(160deg, var(--key-teal), color-mix(in srgb, var(--key-teal) 60%, #052e35));
  --lit-border: #ffffff35;
  --lit-shadow: 0 2px 8px #0003, inset 0 1px #ffffff40;
  --lit-hover-shadow: 0 4px 12px #0000003d, inset 0 1px #ffffff4d;
  --lit-pressed: inset 0 2px 5px #0000004d;
  --track: color-mix(in srgb, var(--bg-deep) 72%, #000);
  --track-border: color-mix(in srgb, var(--text) 13%, transparent);
  /* Shade under the top edge, a faint floor, and a lit lip below: cut in, not drawn on. */
  --track-shadow: inset 0 2px 5px #0000008c, inset 0 -1px 0 #ffffff0a, 0 1px 0 #ffffff12;
  --key: var(--surface-2);
  --key-border: color-mix(in srgb, var(--text) 12%, transparent);
  --raised: 0 1px 2px #0000004d, inset 0 1px 0 #ffffff14;
  --raised-hover: 0 2px 6px #00000059, inset 0 1px 0 #ffffff1f;
  --pressed: inset 0 2px 4px #00000059;
  --engraved: inset 0 1px 2px #00000059;
}

:root.theme-light {
  --track: color-mix(in srgb, var(--bg-deep) 72%, var(--surface-2));
  --track-border: color-mix(in srgb, var(--text) 17%, transparent);
  --track-shadow: inset 0 2px 5px #00000038, inset 0 -1px 0 #ffffff99, 0 1px 0 #ffffffe6;
  --key: var(--surface);
  --key-border: color-mix(in srgb, var(--text) 14%, transparent);
  --raised: 0 1px 2px #0000001a, inset 0 1px 0 #ffffffb3;
  --raised-hover: 0 2px 6px #0000001f, inset 0 1px 0 #ffffffb3;
  --pressed: inset 0 2px 4px #00000029;
  --engraved: inset 0 1px 2px #00000017;
}

/* --- Keys -------------------------------------------------------------------- */

/* Main actions are lit keys. */
.button,
.btn,
.theme-light .button,
.theme-light .btn {
  border: 1px solid var(--lit-border);
  border-radius: 12px;
  background: var(--lit);
  color: #fff;
  box-shadow: var(--lit-shadow);
}

.button:hover,
.btn:hover {
  transform: none;
  filter: brightness(1.07);
  box-shadow: var(--lit-hover-shadow);
}

.button:active,
.btn:active {
  filter: brightness(0.96);
  box-shadow: var(--lit-pressed);
  transform: translateY(1px);
}

/* Everyday buttons are raised keys that press in. */
.button-outline,
.btn-ghost,
.theme-light .button-outline {
  border-color: var(--key-border);
  background: var(--key);
  color: var(--text);
  box-shadow: var(--raised);
  backdrop-filter: none;
}

.button-outline:hover,
.btn-ghost:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--key-border));
  background: var(--key);
  filter: none;
  box-shadow: var(--raised-hover);
}

.button-outline:active,
.btn-ghost:active {
  box-shadow: var(--pressed);
}

.icon-button:not(.theme-toggle),
.demo-chapter,
.feature-picker-button {
  border: 1px solid var(--key-border);
  background: var(--key);
  box-shadow: var(--raised);
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}

.icon-button:not(.theme-toggle):hover,
.demo-chapter:hover,
.feature-picker-button:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--key-border));
  background: var(--key);
  box-shadow: var(--raised-hover);
}

.icon-button:not(.theme-toggle):active,
.demo-chapter:active,
.feature-picker-button:active,
.demo-chapter[aria-expanded="true"],
.feature-picker-button[aria-expanded="true"] {
  box-shadow: var(--pressed);
}

.icon-button:not(.theme-toggle):active,
.demo-chapter:active,
.feature-picker-button:active {
  transform: translateY(1px);
}

.icon-button:not(.theme-toggle) {
  border-radius: 12px;
}

.demo-chapter {
  border-radius: 14px;
}

.feature-picker-button {
  border-radius: 12px;
}

/* --- Grooves: keys sit in a channel cut into the surface ----------------------- */

.groove {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--track-border);
  border-radius: 16px;
  background: var(--track);
  box-shadow: var(--track-shadow);
  vertical-align: middle;
}

/* A groove whose key is hidden goes with it. */
.groove:has(> [hidden]) {
  display: none;
}

.groove > :is(.button, .btn, .icon-button, .demo-chapter) {
  border-radius: 11px;
}

.groove-block {
  display: flex;
  width: 100%;
}

.groove-block > * {
  flex: 1;
}

.button-row.groove {
  display: flex;
  flex-wrap: wrap;
}

.closing-section .button-row.groove {
  margin-inline: auto;
}

/* Header: the workspace key in its groove; the menu key only where it shows. */
.nav-groove .nav-cta {
  min-height: 38px;
}

@media (max-width: 900px) {
  .nav-groove {
    display: none;
  }
}

@media (min-width: 720px) {
  .menu-groove {
    display: none;
  }
}

.menu-groove .menu-toggle,
.groove [data-close-dialog] {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--key-border);
}

/* Footer motion switch: a small key that stays pressed in while motion is off. */
.groove-small {
  padding: 3px;
  border-radius: 12px;
}

.groove-small > .text-button {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--key-border);
  border-radius: 9px;
  background: var(--key);
  color: var(--muted);
  box-shadow: var(--raised);
  transition:
    box-shadow 0.2s,
    color 0.2s;
}

.groove-small > .text-button:hover {
  color: var(--text);
  box-shadow: var(--raised-hover);
}

.groove-small > .text-button[aria-pressed="true"] {
  box-shadow: var(--pressed);
}

/* Film options: chapters and captions sit in one groove, lit while on. */
.film-option-buttons {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--track-border);
  border-radius: 14px;
  background: var(--track);
  box-shadow: var(--track-shadow);
}

.film-options .film-option-buttons button {
  border: 1px solid var(--key-border);
  border-radius: 10px;
  background: var(--key);
  box-shadow: var(--raised);
}

.film-options .film-option-buttons button[aria-pressed="true"],
.film-options .film-option-buttons button[aria-expanded="true"] {
  border-color: var(--lit-border);
  background: var(--lit);
  color: #fff;
  box-shadow: var(--lit-shadow);
}

.film-options .film-option-buttons button[aria-expanded="true"] .disclosure-mark {
  color: #fff;
}

/* --- Theme switch: a recessed track with the lit key on the current theme ----- */

.icon-button.theme-toggle {
  width: 68px;
  min-width: 68px;
}

.theme-switch-track {
  width: 66px;
  height: 36px;
  justify-content: space-between;
  padding-inline: 9px;
  border: 1px solid var(--track-border);
  border-radius: 13px;
  background: var(--track);
  box-shadow: var(--track-shadow);
}

.theme-switch-track svg {
  stroke: var(--faint);
}

.theme-switch-thumb,
.theme-light .theme-switch-thumb {
  inset: 3px auto 3px 3px;
  width: 29px;
  border: 1px solid var(--lit-border);
  border-radius: 10px;
  background: var(--lit);
  box-shadow: var(--lit-shadow);
}

.theme-switch-thumb {
  transform: translateX(28px);
}

.theme-light .theme-switch-thumb {
  transform: translateX(0);
}

.theme-switch-track .theme-moon,
.theme-light .theme-switch-track .theme-sun {
  stroke: #fff;
}

.theme-light .theme-switch-track .theme-moon {
  stroke: var(--faint);
}

.theme-toggle:hover .theme-switch-track,
.theme-toggle.is-hovered .theme-switch-track {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--track-border));
}

/* --- Workspace tabs: one track, the lit key glides to the chosen capability ---- */

.feature-tabs {
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--track-border);
  border-radius: 16px;
  background: var(--track);
  box-shadow: var(--track-shadow);
}

.feature-tabs button {
  position: relative;
  z-index: 1;
  padding: 13px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  transition:
    color 0.25s,
    background 0.25s;
}

.feature-tabs button:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text);
}

.feature-tabs button[aria-selected="true"],
.feature-tabs button[aria-selected="true"]:hover {
  color: #fff;
}

.feature-tabs.has-marker button[aria-selected="true"] {
  background: transparent;
}

.feature-tabs button[aria-selected="true"] span {
  color: #ffffffb3;
}

.feature-tabs:not(.has-marker) button[aria-selected="true"] {
  border-color: var(--lit-border);
  background: var(--lit);
  box-shadow: var(--lit-shadow);
}

.tab-marker {
  border: 1px solid var(--lit-border);
  border-radius: 11px;
  background: var(--lit);
  box-shadow: var(--lit-shadow);
  transition:
    transform 0.55s var(--ease-out),
    width 0.55s var(--ease-out),
    height 0.55s var(--ease-out);
}

/* --- Menus: crisp slabs, the current choice lit ---------------------------------- */

.feature-picker-list {
  padding: 4px;
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 #ffffff12,
    0 1px 2px #00000080,
    0 22px 44px -22px #000000b3;
}

.theme-light .feature-picker-list {
  box-shadow:
    inset 0 1px 0 #ffffffb3,
    0 1px 2px #0000001a,
    0 22px 44px -22px #00000059;
}

.feature-picker-list [role="option"] {
  border: 1px solid transparent;
  border-radius: 10px;
}

.feature-picker-list [aria-selected="true"] {
  border-color: var(--lit-border);
  background: var(--lit);
  color: #fff;
  box-shadow: var(--lit-shadow);
}

/* The hero chapter list that opens from the Chapter key. */
@media (min-width: 601px) {
  .hero-tour .demo-tabs {
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--key-border);
    border-radius: 16px;
    box-shadow:
      inset 0 1px 0 #ffffff12,
      0 1px 2px #00000080,
      0 22px 44px -22px #000000b3;
  }

  .theme-light .hero-tour .demo-tabs {
    box-shadow:
      inset 0 1px 0 #ffffffb3,
      0 1px 2px #0000001a,
      0 22px 44px -22px #00000059;
  }

  .hero-tour .demo-tabs button {
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 11px;
  }

  .hero-tour .demo-tabs [aria-selected="true"] {
    border-color: var(--lit-border);
    border-radius: 11px;
    background: var(--lit);
    color: #fff;
    box-shadow: var(--lit-shadow);
  }

  .hero-tour .demo-tabs [aria-selected="true"] > span {
    color: #ffffffb3;
  }

  .hero-tour .demo-tabs i {
    background: transparent;
  }

  .hero-tour .demo-tabs [aria-selected="true"] i::after {
    background: #ffffffb3;
  }
}

/* The film's play control: a lit key seated in a round socket cut into the poster. */
.film-play {
  width: 78px;
  height: 78px;
  border: 1px solid var(--track-border);
  background: var(--track);
  color: #fff;
  box-shadow: var(--track-shadow), 0 10px 30px #0000004d;
}

.film-play::before {
  inset: 6px;
  border: 1px solid var(--lit-border);
  background: var(--lit);
  box-shadow: var(--lit-shadow);
  animation: none;
  transform: none;
  opacity: 1;
}

.film-play .site-icon {
  position: relative;
}

.film-poster:hover .film-play,
.film-poster:focus-visible .film-play {
  box-shadow: var(--track-shadow), 0 14px 36px #00000059;
}

.film-poster:hover .film-play::before,
.film-poster:focus-visible .film-play::before {
  box-shadow: var(--lit-hover-shadow);
  filter: brightness(1.07);
}

/* --- Governance roles: each index is a recessed tile, the chosen role's is lit ---- */

@media (min-width: 601px) {
  .role-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--track-border);
    border-radius: 10px;
    background: var(--track);
    box-shadow: var(--engraved);
    transition:
      color 0.25s,
      background 0.25s,
      box-shadow 0.25s;
  }

  .role-layer[aria-selected="true"] .role-icon {
    border-color: var(--lit-border);
    background: var(--lit);
    color: #fff;
    box-shadow: var(--lit-shadow);
  }
}

.role-icon .site-icon {
  width: 16px;
  height: 16px;
}

/* --- Phones: governance roles become a recessed track, the chosen role lit ------- */

@media (max-width: 600px) {
  .role-stack {
    padding: 4px;
    border: 1px solid var(--track-border);
    border-radius: 16px;
    background: var(--track);
    box-shadow: var(--track-shadow);
  }

  .governance-layout .role-layer {
    border-color: transparent;
    border-radius: 11px;
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .governance-layout .role-layer[aria-selected="true"] {
    border-color: var(--lit-border);
    background: var(--lit);
    color: #fff;
    box-shadow: var(--lit-shadow);
    transform: none;
  }

  .governance-layout .role-layer[aria-selected="true"] .role-icon {
    color: #ffffffb3;
  }

  .governance-layout .authority-connector {
    color: var(--faint);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab-marker {
    transition: none;
  }
}
