/* ask-sheet.css — Ask sheet (Tier-2 AI) + Quick Action Sheet */

/* ============================================================
   ASK SHEET LAYOUT
   ============================================================ */
#ask-sheet.half,
#ask-sheet.full {
  /* Sheet occupies what BottomSheet snap gives it.
     Inner wrapper fills via flex so scroll area can grow. */
}

.ask-sheet-inner {
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-6);
  gap: var(--space-4);
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
}

/* Keep the input reachable when the sheet is taller than a short viewport. */
#ask-sheet.full {
  max-height: 100dvh;
}

#ask-sheet.full .ask-sheet-inner {
  overflow-y: auto;
}

/* ── Header ──────────────────────────────────────────────── */
.ask-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.ask-sheet-title {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  letter-spacing: -0.01em;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-sheet-title span {
  font-weight: var(--font-normal);
  color: var(--text-muted);
}

.ask-sheet-close {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  margin-right: calc(-1 * var(--space-2));
}

.ask-sheet-close:hover {
  color: var(--text-primary);
  background: var(--surface-inset);
}

/* ── Verbosity bar (full-snap only) ──────────────────────── */
.ask-verbosity-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
  justify-content: center;
}

/* Hidden unless sheet is in full-snap */
#ask-sheet:not(.full) .ask-verbosity-bar {
  display: none;
}

.ask-verbosity-btn {
  flex: 1;
  max-width: 100px;
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-default, var(--border-subtle));
  background: transparent;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ask-verbosity-btn.active {
  background: var(--button-bg, var(--color-primary, #6366f1));
  color: var(--button-text, var(--text-inverse, #fff));
  border-color: transparent;
}

/* ── Prompt chips ────────────────────────────────────────── */
.ask-sheet-chips {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ask-chip {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: var(--surface-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  min-height: var(--touch-min);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

@media (hover: hover) {
  .ask-chip:hover {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    color: var(--color-primary);
  }
}
.ask-chip:active {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Input bar ───────────────────────────────────────────── */
.ask-sheet-input-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.ask-sheet-input {
  flex: 1;
  font-family: var(--font-ui);
  /* 16px — below this, iOS Safari auto-zooms the viewport on focus. */
  font-size: var(--text-base, 1rem);
  color: var(--text-primary);
  background: var(--surface-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  min-height: var(--touch-min);
  resize: none;
  outline: none;
  line-height: var(--leading-body);
  -webkit-appearance: none;
  transition: border-color var(--transition-fast);
}

.ask-sheet-input::placeholder {
  color: var(--text-disabled);
}

.ask-sheet-input:focus {
  border-color: var(--color-primary);
}

.ask-sheet-send {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity var(--transition-fast);
}

.ask-sheet-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.ask-sheet-send svg {
  width: 18px;
  height: 18px;
}

/* ── Mic button ──────────────────────────────────────────── */
.ask-sheet-mic {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ask-sheet-mic:active {
  opacity: 0.7;
}

.ask-sheet-mic.listening {
  background: var(--color-voice-listening-subtle);
  color: var(--color-voice-listening);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ============================================================
   QUICK ACTION SHEET
   Appears when user long-presses a paragraph on mobile.
   ============================================================ */
#quick-action-sheet {
  /* Uses .bottom-sheet base from shell.css */
}

/* This sheet is content-height, so the shared .half (translateY(50%) of the
   sheet's OWN height) hid every action below the first row, including
   "Feedback to author". Show the whole sheet when opened. */
#quick-action-sheet.half {
  transform: translateY(0);
}

.qa-sheet-inner {
  padding: var(--space-3) var(--space-6) var(--space-4); /* .bottom-sheet already pads the home-indicator area */
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Paragraph preview */
.qa-sheet-preview {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-body);
  /* 2-line clamp */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* Action grid — 3 columns (5 actions → 2 rows) */
.qa-sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.qa-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 64px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  border: 1px solid var(--edge-strong);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-family: var(--font-ui);
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
}

@media (hover: hover) {
  .qa-action:hover {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
  }
}
.qa-action:active {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
}

.qa-action-icon {
  font-size: 20px;
  line-height: 1;
}

.qa-action-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-align: center;
}

@media (hover: hover) {
  .qa-action:hover .qa-action-label {
    color: var(--color-primary);
  }
}
.qa-action:active .qa-action-label {
  color: var(--color-primary);
}

/* One-tap feedback row: sends the tag at once (author-feedback-sheet.js quickSend). */
.qa-quick-feedback {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.qa-quick-label {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  flex-basis: 100%;   /* own line, so the three buttons keep their full width */
}

.qa-quick {
  flex: 1 1 0;
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-full, 999px);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  font: var(--font-semibold) var(--text-sm) var(--font-ui);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.qa-quick:active {
  background: var(--color-primary);
  color: var(--text-inverse, #fff);
}

@media (hover: none) {
  .qa-quick:focus-visible,
  .qa-action:focus-visible {
    outline: none;
  }
}

/* 'Write…' opens the feedback sheet; plain outline so it doesn't read as a one-tap tag. */
.qa-quick-more {
  background: transparent;
  border-style: dashed;
}
