/* Contract: contracts/web/rules.md
 * The floating bottom dock + compact Arlene bar, and full-workspace app views.
 *
 * Loaded last of the numbered sheets so it overrides the full-width accent
 * footer from 11-assistant.css and the modal sizing from 17-studio.css and
 * 18-dupes.css without rewriting those sheets.
 */

/* ---------- the bottom OS rail (left-anchored app dock + centered Arlene + right utilities) ---------- */
.bottomrail {
  position: relative; z-index: 59;
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(260px, 560px) auto;
  justify-content: space-between;
  align-items: center; gap: 12px;
  padding: 6px 14px calc(8px + env(safe-area-inset-bottom));
}
body.choosing .bottomrail { display: none; }

.dock-pill {
  justify-self: start;
  display: flex; align-items: center;
  max-width: 100%;
  padding: 5px 6px;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), var(--rim);
}

.bottombar {
  position: relative;
  justify-self: center;
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  max-width: 600px;
  padding: 5px 8px;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), var(--rim);
  transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.bottombar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line-strong));
  box-shadow: var(--shadow-lg), var(--rim),
              0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
              0 8px 32px color-mix(in srgb, var(--accent) 16%, transparent);
}
.bottombar:has(.dock-send.sending) {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line-strong));
  animation: arlene-glow 1.8s ease-in-out infinite;
}
@keyframes arlene-glow {
  0%, 100% {
    box-shadow: var(--shadow-lg), var(--rim),
                0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent),
                0 6px 26px color-mix(in srgb, var(--accent) 18%, transparent);
  }
  50% {
    box-shadow: var(--shadow-lg), var(--rim),
                0 0 0 2px color-mix(in srgb, var(--accent) 44%, transparent),
                0 10px 38px color-mix(in srgb, var(--accent) 32%, transparent);
  }
}

/* On visual-canvas views (Gallery, Projects, App Launcher) on wide screens,
   float the frosted glass rail over the bottom edge of the workspace so
   scrolling artwork refracts underneath and the canvas gains ~56px of height.
   Finder, Requests, and other apps keep the rail in flow so footers and
   compose bars are never occluded; identical padding guarantees zero jump. */
@media (min-width: 721px) {
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .bottomrail,
  body[data-active-app="launcher"] .bottomrail {
    position: fixed; left: 0; right: 0; bottom: 0;
    pointer-events: none;
  }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .bottomrail > *,
  body[data-active-app="launcher"] .bottomrail > * {
    pointer-events: auto;
  }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .bottomrail::before,
  body[data-active-app="launcher"] .bottomrail::before {
    content: '';
    position: absolute; left: 0; right: 0; bottom: 0; height: 92px;
    z-index: -1; pointer-events: none;
    background: linear-gradient(to top,
      color-mix(in srgb, var(--bg) 76%, transparent) 0%,
      color-mix(in srgb, var(--bg) 32%, transparent) 55%,
      transparent 100%);
  }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .grid { padding-bottom: 92px; }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .projectcards { padding-bottom: 92px; }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .sidebar { padding-bottom: 78px; }
  body:not(.in-finder):not(.in-requests):not([data-active-app]) .inspector { padding-bottom: 92px; }
  body[data-active-app="launcher"] [data-app-surface="launcher"] .lnch-list { padding-bottom: 92px; }
}

/* In Requests the compose box lives inside the thread, so Arlene stands down
   while the left-anchored app dock stays available to switch out. */
body.in-requests .bottombar { display: none; }
body.choosing .bottombar { display: none; }

@media (max-width: 960px) {
  .bottomrail {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
  }
}

/* ---------- macOS-style app dock ---------- */
.dock {
  display: flex; align-items: center; gap: 4px;
  flex: none;
}

.dock-app {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--ink-dim);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.dock-app:hover {
  color: var(--ink);
  background: var(--panel-2);
  transform: translateY(-2px) scale(1.06);
}
.dock-app:active { transform: translateY(0) scale(.97); }
.dock-app:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dock-app.on {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}
/* Classic macOS active-app indicator dot below the icon. */
.dock-app.on::after {
  content: '';
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}

@keyframes dock-launch-hop {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-3.5px); }
  70%      { transform: translateY(0.5px); }
}
@keyframes dock-dot-pulse {
  0%, 100% { opacity: .35; transform: translateX(-50%) scale(.8); }
  50%      { opacity: 1;   transform: translateX(-50%) scale(1.25); }
}
.dock-app.is-loading .dock-ico {
  animation: dock-launch-hop 820ms var(--ease) infinite;
}
.dock-app.is-loading::after {
  animation: dock-dot-pulse 820ms var(--ease) infinite;
}

.dock-ico {
  display: grid; place-items: center;
  width: 20px; height: 20px;
}
.dock-ico svg { width: 20px; height: 20px; display: block; }

/* Hover tooltip above the icon, macOS Dock style. */
.dock-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 9px; border-radius: 7px;
  background: var(--ink); color: var(--panel);
  font-size: 11.5px; font-weight: 560; line-height: 1.2;
  white-space: nowrap; pointer-events: none;
  opacity: 0; box-shadow: var(--shadow-md);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.dock-app:hover:not(:active) .dock-tip,
.dock-app:focus-visible .dock-tip {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* Notification count badge on a dock icon (e.g. active work items). */
.dock-badge {
  position: absolute; top: 0; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px;
  background: var(--accent); color: var(--on-accent);
  font-size: 10px; font-weight: 700; line-height: 16px;
  text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--panel);
}

.dock-sep {
  flex: none; width: 1px; height: 24px; margin: 0 2px;
  background: var(--line-strong);
}

/* Drag-and-drop pinning & reordering inside the dock */
.dock-app.is-dragging {
  opacity: .38;
  transform: scale(.92);
}
.dock-app.is-transient {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}
body.dragging-dock-app[data-dock-drag-source="launcher"] .dock-pill,
.dock-pill.is-drop-over {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
  box-shadow: var(--shadow-lg), 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
/* Use ::before only so .dock-app.on::after keeps the active-app indicator dot. */
.dock-app.dock-drop-before::before,
.dock-app.dock-drop-after::before {
  content: '';
  position: absolute; top: 5px; bottom: 5px;
  width: 2.5px; border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}
.dock-app.dock-drop-before::before { left: -3.5px; }
.dock-app.dock-drop-after::before { right: -3.5px; }

/* ---------- compact Arlene inside the floating dock ---------- */
.bottombar .assistant {
  flex: 1; min-width: 0;
  background: transparent;
  z-index: auto;
}
.bottombar .assistant-line {
  padding: 0; gap: 6px;
  color: var(--ink);
}
.bottombar .assistant-mark {
  width: 10px; height: 10px; border-radius: 3.5px;
  background: var(--accent);
}
.bottombar .assistant-who {
  margin-left: -2px;
  font-size: 12px; font-weight: 620;
  color: var(--accent);
}
.bottombar .assistant-about {
  max-width: min(32%, 240px);
  padding: 3px 8px 3px 4px;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink-dim);
  font-size: 11.5px;
}
.bottombar .assistant-thumb,
.bottombar .assistant-thumb img { width: 18px; height: 18px; }
.bottombar .assistant-count,
.bottombar .assistant-over { color: var(--accent); }

.bottombar .assistant-say {
  min-height: 34px; max-height: 96px;
  padding: 6px 11px;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 13.5px; line-height: 1.4;
}
.bottombar .assistant-say:hover { background: var(--panel-hover); }
.bottombar .assistant-say:focus {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

.bottombar .assistant-line .ghost,
.bottombar .assistant-line .btn {
  height: 34px; padding: 0 11px;
  border-radius: 10px; font-size: 12.5px;
}
.bottombar .assistant-line .ghost {
  color: var(--ink-dim); border-color: var(--line);
}
.bottombar .assistant-line .ghost:hover {
  color: var(--ink); border-color: var(--line-strong);
  background: var(--panel-2);
}
.dock-icobtn {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-dim);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.dock-icobtn:hover { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.dock-icobtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dock-icobtn svg { width: 17px; height: 17px; display: block; }
.dock-icobtn .dock-badge { top: -2px; right: -2px; }

.bottombar .assistant-line .dock-send {
  flex: none; display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
}
.bottombar .assistant-line .dock-send svg { width: 16px; height: 16px; display: block; }
.bottombar .assistant-line .dock-send:hover:not([disabled]) {
  filter: brightness(1.06);
  background: var(--accent);
}
.bottombar .assistant-line .dock-send.sending svg { animation: dock-pulse 1s ease-in-out infinite; }
@keyframes dock-pulse { 50% { opacity: .4; transform: scale(.9); } }

.bottombar .assistant-bubble {
  bottom: calc(100% + 16px); left: 0;
  width: min(560px, calc(100vw - 32px));
}

/* ---------- bottom-right utility cluster (upload + refresh/activity) ---------- */
.cornertools {
  position: relative;
  justify-self: end;
  display: flex; align-items: center;
}
.cornerpill {
  display: flex; align-items: center; gap: 4px;
  padding: 5px;
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), var(--rim);
}
.cornerbtn {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--ink-dim);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cornerbtn:hover { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.cornerbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cornerbtn .ico { width: 18px; height: 18px; display: block; }
.cornerchip {
  height: 26px; padding: 0 9px; margin: 0 2px;
  border-radius: 99px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.cornerchip.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

.activitypop {
  position: absolute; right: 0; bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 28px));
  max-height: min(62vh, 460px);
  display: flex; flex-direction: column;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), var(--rim);
  overflow: hidden;
  z-index: 62;
}
.activitypop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.activitypop-close { width: 28px; height: 28px; font-size: 18px; }
.activitypop-body {
  padding: 12px 14px; overflow-y: auto;
  font-size: 13px;
}
.activitypop-body > p:first-child { margin-top: 0; }

@media (max-width: 900px) {
  .bottomrail {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 5px 8px calc(7px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  .dock-pill {
    min-width: 0; max-width: 100%;
    overflow-x: auto; scrollbar-width: none;
  }
  .dock-pill::-webkit-scrollbar { display: none; }
  .bottomrail-spacer { display: none; }
  .bottombar { width: 100%; }
}

@media (max-width: 720px) {
  .bottomrail {
    grid-template-columns: minmax(0, 1fr);
    padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 5px;
  }
  .bottombar {
    order: 1;
    max-width: none;
    padding: 4px 6px; gap: 5px;
    border-radius: 16px;
  }
  .dock-pill {
    order: 2;
    justify-self: stretch;
    width: 100%;
    padding: 4px 6px;
    border-radius: 15px;
    overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .dock-pill::-webkit-scrollbar { display: none; }
  .dock { margin: 0; padding: 0 2px; }
  .dock-app { width: 34px; height: 34px; border-radius: 10px; }
  .dock-ico, .dock-ico svg { width: 18px; height: 18px; }
  .dock-tip { display: none; }
  .cornertools { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dock-app, .dock-tip, .bottombar, .bottombar:has(.dock-send.sending),
  .bottombar .assistant-line .dock-send.sending svg,
  .dock-app.is-loading .dock-ico,
  .dock-app.is-loading::after { transition: none; animation: none; }
}
