/* 3.1.9 FINAL — Shell HUD 0.72 (legge su video chiaro/scuro); textarea 3.1.8 locked.
 * Override isolato su .annotation-popup / bottoni / textarea.
 * NON tocca logica ms, saveAnnotation o annotations.js. */

/* Contenitore popup: vetro semi-scuro (shell) — larghezza da style_4.css (224px) */
.annotation-popup {
  background: color-mix(in srgb, rgba(8, 13, 22, 0.72) 90%, var(--t1-cyan-gateway, #00f2ff) 10%);
  border: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 24%, rgba(0, 242, 255, 0.12));
  backdrop-filter: blur(calc(var(--t1-glass-blur, 18px) + 2px)) saturate(1.14);
  -webkit-backdrop-filter: blur(calc(var(--t1-glass-blur, 18px) + 2px)) saturate(1.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 14px rgba(232, 240, 250, 0.04),
    0 10px 28px rgba(0, 0, 0, 0.68),
    0 0 0 1px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 8%, transparent),
    0 0 14px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 10%, transparent);
  transition: box-shadow 0.18s ease;
}

.annotation-popup::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14%;
  right: 14%;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    transparent,
    color-mix(in srgb, var(--t1-pearl, #e8f0fa) 56%, transparent),
    color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 12%, transparent),
    color-mix(in srgb, var(--t1-pearl, #e8f0fa) 56%, transparent),
    transparent);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.annotation-popup-timestamp {
  color: color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 72%, #d7f7ff 28%) !important;
  text-shadow:
    0 0 4px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 18%, transparent),
    0 0 8px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 8%, transparent);
  transition: color 0.18s ease, text-shadow 0.18s ease;
}

/* P1 — In digitazione: guscio e timestamp più quieti, campo al centro */
.annotation-popup:focus-within {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 10px rgba(232, 240, 250, 0.03),
    0 10px 28px rgba(0, 0, 0, 0.66),
    0 0 0 1px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 5%, transparent),
    0 0 5px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 4%, transparent);
}

.annotation-popup:focus-within::before {
  opacity: 0.5;
}

.annotation-popup:focus-within .annotation-popup-timestamp {
  color: color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 52%, #9eb4c4 48%) !important;
  text-shadow: 0 0 3px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 8%, transparent);
}

/* P0 — Foglio pearl sul vetro scuro (legge anche su frame nero) */
.annotation-popup textarea {
  background:
    linear-gradient(rgba(232, 240, 250, 0.16), rgba(232, 240, 250, 0.16)),
    rgba(8, 13, 22, 0.35);
  border: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 40%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.10),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.annotation-popup textarea::placeholder {
  color: color-mix(in srgb, var(--text-dim, #aab6d2) 58%, var(--t1-pearl, #e8f0fa) 42%);
  opacity: 0.96;
}

.annotation-popup:focus-within textarea::placeholder {
  color: color-mix(in srgb, var(--text-dim, #aab6d2) 40%, var(--t1-pearl, #e8f0fa) 60%);
  opacity: 1;
}

.annotation-popup textarea:focus {
  background:
    linear-gradient(rgba(232, 240, 250, 0.20), rgba(232, 240, 250, 0.20)),
    rgba(8, 13, 22, 0.32);
  border-color: color-mix(in srgb, var(--t1-pearl, #e8f0fa) 52%, var(--t1-cyan-gateway, #00f2ff) 16%);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 14%, transparent),
    0 0 6px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 5%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.06);
  outline: none;
}

/* P2 — Salva primario · Annulla secondario */
.annotation-btn-save {
  background: color-mix(in srgb, var(--t1-pearl, #e8f0fa) 18%, rgba(8, 13, 22, 0.78));
  border: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 36%, var(--t1-cyan-gateway, #00f2ff) 22%);
  border-top: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 42%, transparent);
  color: var(--text-pure, rgba(248, 250, 255, 0.98));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 6px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 6%, transparent);
}

.annotation-btn-save:hover:not(:disabled) {
  background: color-mix(in srgb, var(--t1-pearl, #e8f0fa) 22%, rgba(8, 13, 22, 0.74));
  border-color: color-mix(in srgb, var(--t1-pearl, #e8f0fa) 40%, var(--t1-cyan-gateway, #00f2ff) 26%);
  box-shadow:
    0 0 10px color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 10%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.annotation-btn-save:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

.annotation-btn-cancel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 12%, transparent);
  color: color-mix(in srgb, var(--text-dim, #8894ae) 92%, var(--t1-pearl, #e8f0fa) 8%);
  opacity: 0.78;
  box-shadow: none;
}

.annotation-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: color-mix(in srgb, var(--t1-pearl, #e8f0fa) 18%, transparent);
  color: color-mix(in srgb, var(--text-dim, #aab6d2) 80%, var(--t1-pearl, #e8f0fa) 20%);
  opacity: 0.92;
}

/* T1.1 — Picker snippet feedback nel popup annotazione (collassato di default) */
.annotation-snippet-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.annotation-snippet-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 28px;
}

.annotation-snippet-picker__toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  margin: 0;
  border: none;
  border-radius: var(--radius-sm, 4px);
  background: rgba(255, 255, 255, 0.03);
  color: color-mix(in srgb, var(--text-dim, #8894ae) 82%, var(--t1-pearl, #e8f0fa) 18%);
  font-family: var(--font-tech, system-ui, sans-serif);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}

.annotation-snippet-picker__toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 42%, var(--t1-pearl, #e8f0fa) 58%);
}

.annotation-snippet-picker__toggle-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-snippet-picker__chevron {
  flex-shrink: 0;
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.78;
  transition: transform 0.16s ease;
}

.annotation-snippet-picker.is-expanded .annotation-snippet-picker__chevron {
  transform: rotate(90deg);
}

.annotation-snippet-picker.is-collapsed .annotation-snippet-picker__body {
  display: none;
}

.annotation-snippet-picker.is-expanded .annotation-snippet-picker__body {
  display: block;
}

/* Popup nota: scroll interno se Frasi rapide espande (evita taglio sotto transport) */
.annotation-popup:has(.annotation-snippet-picker.is-expanded) {
  max-height: min(62vh, calc(100% - 5rem));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.annotation-snippet-picker__manage {
  flex-shrink: 0;
  min-height: 28px;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 78%, var(--t1-pearl, #e8f0fa) 22%);
  font-family: var(--font-tech, system-ui, sans-serif);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
}

.annotation-snippet-picker__manage:hover {
  background: rgba(255, 255, 255, 0.05);
}

.annotation-snippet-picker__list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 112px;
  overflow-y: auto;
  padding: 2px 2px 0 0;
}

.annotation-snippet-picker__item {
  min-height: 30px;
  min-width: 0;
  padding: 6px 9px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid color-mix(in srgb, var(--t1-pearl, #e8f0fa) 22%, transparent);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-pure, rgba(248, 250, 255, 0.98));
  font-family: var(--font-main, system-ui, sans-serif);
  font-size: 0.68rem;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
  flex: 1 1 calc(50% - 6px);
  max-width: 100%;
}

.annotation-snippet-picker__item:hover {
  border-color: color-mix(in srgb, var(--t1-cyan-gateway, #00f2ff) 28%, var(--t1-pearl, #e8f0fa) 18%);
  background: rgba(255, 255, 255, 0.07);
}

.annotation-snippet-picker__empty {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.35;
  color: color-mix(in srgb, var(--text-dim, #8894ae) 90%, var(--t1-pearl, #e8f0fa) 10%);
}
