/* Shell review overlay (public/js/review-overlay.js). Markers, toolbar and editor lie above open
   surfaces (ui-surfaces.js stacks them at 1081+) and the sidebar; positions come from custom
   properties set by the script, never from inline style attributes. */

.review-overlay {
  /* Overlay colours follow the design tokens (and therefore light/dark mode): brand green for
     markers and the primary action, card surfaces for toolbar, hint and messages. */
  --review-accent: var(--color-brand);
  --review-accent-strong: var(--color-brand-dark);
  --review-accent-soft: var(--color-brand-soft);
  --review-on-accent: var(--color-on-brand);
  --review-accent-ring: rgb(20 125 112 / 28%);
  --review-shadow: 0 12px 32px var(--color-shadow);
  --review-z-layer: 1190;
  --review-z-draw: 1195;
  --review-z-toolbar: 1200;
  --review-z-panel: 1210;
  --review-z-message: 1220;
}

.review-overlay[hidden],
.review-overlay [hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- header switch */

.review-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--color-ink-soft);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.review-mode-switch__input {
  position: relative;
  width: 2.1rem;
  height: 1.2rem;
  margin: 0;
  flex: none;
  cursor: pointer;
  appearance: none;
  background: var(--color-line-strong);
  border-radius: 999px;
  transition: background-color 0.15s ease;
}

.review-mode-switch__input::before {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.9rem;
  height: 0.9rem;
  content: "";
  background: var(--color-on-brand);
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease;
}

.review-mode-switch__input:checked {
  background: var(--color-brand);
}

.review-mode-switch__input:checked::before {
  transform: translateX(0.9rem);
}

@media (prefers-reduced-motion: reduce) {
  .review-mode-switch__input,
  .review-mode-switch__input::before {
    transition: none;
  }
}

.review-mode-switch__input:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring, 0 0 0 3px rgb(20 125 112 / 28%));
}

@media (max-width: 36rem) {
  .review-mode-switch__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------------------------------------------------------------- marker layer */

.review-layer {
  position: fixed;
  inset: 0;
  z-index: var(--review-z-layer);
  pointer-events: none;
}

.review-layer__drawings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.review-outline,
.review-hover {
  position: fixed;
  top: var(--review-box-y, 0);
  left: var(--review-box-x, 0);
  width: var(--review-box-w, 0);
  height: var(--review-box-h, 0);
  pointer-events: none;
  border-radius: 4px;
}

.review-outline {
  outline: 1.5px dashed rgb(20 125 112 / 55%);
  outline-offset: 2px;
}

.review-outline--resolved {
  outline-color: rgb(152 162 179 / 45%);
}

.review-outline--highlight {
  outline: 2px solid var(--review-accent);
  box-shadow: 0 0 0 6px var(--review-accent-ring);
}

.review-hover {
  z-index: var(--review-z-layer);
  outline: 2px solid var(--review-accent);
  outline-offset: 2px;
  background: rgb(20 125 112 / 8%);
}

.review-hover::after {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  max-width: 18rem;
  padding: 0.15rem 0.45rem;
  overflow: hidden;
  color: var(--review-on-accent);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  content: attr(data-label);
  background: var(--review-accent);
  border-radius: var(--radius-sm, 5px);
}

.review-marker {
  position: fixed;
  top: var(--review-y, 0);
  left: var(--review-x, 0);
  display: inline-grid;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.35rem;
  color: var(--review-on-accent);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  background: var(--review-accent);
  border: 2px solid var(--color-surface);
  border-radius: 999px;
  box-shadow: 0 4px 12px var(--color-shadow);
  transform: translate(-50%, -50%);
  place-items: center;
}

.review-marker:hover {
  background: var(--review-accent-strong);
}

.review-marker:focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
}

.review-marker--resolved {
  color: var(--color-muted);
  background: var(--color-surface-soft);
  border-color: var(--color-line-strong);
  box-shadow: var(--shadow-xs);
}

.review-marker--draft {
  color: var(--color-surface);
  pointer-events: none;
  background: var(--color-ink);
}

.review-marker--highlight {
  animation: review-pulse 1.2s ease-out 3;
}

@keyframes review-pulse {
  from {
    box-shadow:
      0 0 0 0 rgb(20 125 112 / 60%),
      0 4px 12px var(--color-shadow);
  }

  to {
    box-shadow:
      0 0 0 14px rgb(20 125 112 / 0%),
      0 4px 12px var(--color-shadow);
  }
}

.review-drawing__path {
  fill: none;
  stroke: var(--review-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: pointer;
  filter: drop-shadow(0 1px 1px var(--color-shadow));
}

.review-drawing__path:hover,
.review-drawing--highlight .review-drawing__path {
  stroke-width: 5;
}

.review-drawing__path:focus-visible {
  outline: none;
  stroke: var(--review-accent-strong);
  stroke-width: 5;
}

.review-drawing--resolved .review-drawing__path {
  stroke: var(--color-subtle);
  stroke-dasharray: 6 5;
}

.review-drawing__number {
  fill: var(--color-brand-text);
  font-size: 12px;
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--color-surface);
  stroke-width: 3px;
}

/* Freehand capture surface: covers the viewport (including open surfaces) while drawing. */

.review-draw {
  position: fixed;
  inset: 0;
  z-index: var(--review-z-draw);
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  background: rgb(20 125 112 / 4%);
}

.review-draw[hidden] {
  display: none;
}

.review-draw__path {
  fill: none;
  stroke: var(--review-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.review-annotating,
body.review-annotating * {
  cursor: crosshair !important;
}

/* ---------------------------------------------------------------- toolbar */

/* Floating card in the app's surface style: card background, fine line, soft shadow; buttons behave
   like the small text buttons of the design, the primary action like `btn-solid theme-primary`. */
.review-toolbar {
  position: fixed;
  top: var(--review-toolbar-y, calc(100dvh - 4.5rem));
  left: var(--review-toolbar-x, 1rem);
  z-index: var(--review-z-toolbar);
  display: flex;
  width: max-content;
  max-width: calc(100vw - 1rem);
  padding: 0.3rem;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  color: var(--color-ink-soft);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl, 12px);
  box-shadow: var(--review-shadow);
}

.review-toolbar__handle,
.review-toolbar__button,
.review-hint__button {
  display: inline-flex;
  min-height: 2.125rem;
  padding: 0.3rem 0.7rem;
  align-items: center;
  gap: 0.4rem;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 7px);
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.review-toolbar__icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  flex: none;
}

.review-toolbar__icon svg {
  width: 100%;
  height: 100%;
}

.review-toolbar__handle {
  padding-inline: 0.35rem;
  color: var(--color-subtle);
  cursor: grab;
  touch-action: none;
}

.review-toolbar__handle:active {
  cursor: grabbing;
}

.review-toolbar__button:hover,
.review-hint__button:hover,
.review-toolbar__handle:hover {
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

.review-toolbar__button[aria-pressed="true"],
.review-toolbar__button[aria-expanded="true"],
.review-hint__button[aria-pressed="true"] {
  color: var(--color-brand-text);
  background: var(--review-accent-soft);
  border-color: var(--color-brand-border);
}

.review-toolbar__button--primary {
  color: var(--review-on-accent);
  background: var(--review-accent);
  border-color: var(--review-accent);
}

.review-toolbar__button--primary:hover,
.review-toolbar__button--primary[aria-pressed="true"] {
  color: var(--review-on-accent);
  background: var(--review-accent-strong);
  border-color: var(--review-accent-strong);
}

.review-toolbar__button--primary[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--review-accent-ring);
}

.review-toolbar :focus-visible,
.review-hint :focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring, 0 0 0 3px rgb(20 125 112 / 28%));
}

.review-toolbar__count {
  display: inline-grid;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  color: var(--color-brand-dark);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--color-on-brand);
  border-radius: 999px;
  place-items: center;
}

@media (max-width: 36rem) {
  /* Narrow screens: icon-only buttons (the accessible name stays on the button). */
  .review-toolbar__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .review-toolbar__handle,
  .review-toolbar__button,
  .review-hint__button {
    transition: none;
  }
}

/* ---------------------------------------------------------------- list popover */

.review-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  width: min(24rem, calc(100vw - 1rem));
  max-height: min(24rem, 60vh);
  padding: 0.75rem;
  overflow: auto;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg, 9px);
  box-shadow: var(--review-shadow);
}

.review-toolbar--top .review-list {
  top: calc(100% + 0.5rem);
  bottom: auto;
}

.review-list__summary {
  margin: 0 0 0.5rem;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.review-list__filter {
  display: flex;
  margin-bottom: 0.5rem;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.review-list__items {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 0.25rem;
  list-style: none;
}

.review-list__item {
  display: grid;
  width: 100%;
  padding: 0.45rem 0.55rem;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.5rem;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.review-list__item:hover,
.review-list__item:focus-visible {
  background: var(--color-surface-soft);
  border-color: var(--color-line);
}

.review-list__number {
  display: inline-grid;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.3rem;
  color: var(--review-on-accent);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--review-accent);
  border-radius: 999px;
  place-items: center;
}

.review-list__item--resolved {
  color: var(--color-muted);
}

.review-list__item--resolved .review-list__number {
  color: var(--color-muted);
  background: var(--color-surface-soft);
  box-shadow: inset 0 0 0 1px var(--color-line-strong);
}

.review-list__text {
  overflow-wrap: anywhere;
}

.review-list__note {
  grid-column: 2;
  color: var(--color-warning);
  font-size: 0.75rem;
}

.review-list__empty {
  color: var(--color-muted);
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------- hint bar */

.review-hint {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  z-index: var(--review-z-toolbar);
  display: flex;
  max-width: calc(100vw - 1rem);
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-ink);
  font-size: 0.85rem;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--review-accent);
  border-radius: var(--radius-xl, 12px);
  box-shadow: var(--review-shadow);
  transform: translateX(-50%);
}

.review-hint__text {
  margin-right: 0.35rem;
}

/* ---------------------------------------------------------------- editor panel */

.review-panel {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: var(--review-z-panel);
  display: flex;
  width: min(26rem, calc(100vw - 1.5rem));
  flex-direction: column;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-top: 3px solid var(--review-accent);
  border-radius: var(--radius-xl, 12px);
  box-shadow: -12px 0 50px var(--color-shadow);
  animation: review-panel-slide 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes review-panel-slide {
  from {
    transform: translateX(2rem);
  }
}

.review-panel__header {
  display: flex;
  padding: 1rem 1.25rem 0.85rem;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 1px solid var(--color-line);
}

.review-panel__eyebrow {
  margin: 0 0 0.15rem;
  color: var(--color-brand-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.review-panel__title {
  margin: 0;
  font-size: 1.15rem;
}

.review-panel__body {
  padding: 1rem 1.25rem 1.25rem;
  overflow: auto;
  flex: 1;
  align-content: start;
}

.review-panel__target,
.review-panel__meta {
  margin: 0;
  color: var(--color-ink-soft);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.review-panel__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.review-panel__status--resolved {
  color: var(--color-success);
  font-weight: 600;
}

.review-panel__text {
  min-height: 8rem;
  resize: vertical;
}

.review-panel__roadmap {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 0.5rem;
  border: 0;
}

.review-panel__roadmap > button {
  justify-self: start;
}

.review-panel__roadmap-form {
  padding: 0.75rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md, 7px);
}

.review-panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.review-panel__actions [data-review-delete] {
  margin-right: auto;
}

/* ---------------------------------------------------------------- status message */

.review-message {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: var(--review-z-message);
  max-width: min(28rem, calc(100vw - 2rem));
  margin: 0;
  padding: 0.6rem 0.85rem;
  color: var(--color-ink);
  font-size: 0.85rem;
  pointer-events: none;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--review-accent);
  border-radius: var(--radius-md, 7px);
  box-shadow: var(--review-shadow);
}

@media (prefers-reduced-motion: reduce) {
  .review-panel,
  .review-marker--highlight {
    animation: none;
  }
}

@media print {
  .review-overlay,
  .review-mode-switch {
    display: none !important;
  }
}
