/* standalone-sheet — floating bottom sheets for the standalone pages
 * (changelog.html, ideas.html), which do not load style.css or app.js.
 *
 * Mockup: .tmp/changelog-hig-mockup.html (sections 3, 4, 6) and the idea sheet
 * in .tmp/roadmap-hig-mockup.html. Audit: docs/design/phase-d-hig-audit.md.
 * Script: public/js/lib/standalone-sheet.js (openModal / closeModal).
 *
 * Markup: <div class="scrim" id="..."><div class="glass-sheet glass is-thick">…</div></div>
 *
 * Uses ONLY var(--v2-*) tokens, all defined in /css/canopy-v2.css (section 20
 * holds the glass tokens). No raw colour in this file.
 *
 * Glass: the sheet is the only glass here. Every control ON the sheet is a
 * plain fill (never glass on glass). The default is opaque; the translucent
 * tint and the blur apply only where backdrop-filter is supported, and are
 * dropped again for Reduce Transparency and Increase Contrast.
 */

/* ─── Base resets for the sheet's own controls (the pages load no global reset) ─── */
.scrim, .scrim *, .scrim *::before, .scrim *::after { box-sizing: border-box; }
.scrim button, .scrim textarea { font-family: inherit; margin: 0; -webkit-tap-highlight-color: transparent; }
.scrim button { cursor: pointer; }
.scrim [hidden] { display: none !important; }

/* The .glass surface is in glass.css (loaded by both standalone pages). */

/* ─── Scrim and sheet ─── */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--v2-bg-overlay);
  font-family: var(--v2-font-body);
  -webkit-font-smoothing: antialiased;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--v2-transition-base) var(--v2-ease-out), visibility 0s linear var(--v2-transition-base);
}
.scrim.open {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--v2-transition-base) var(--v2-ease-out), visibility 0s;
}

.glass-sheet {
  position: absolute;
  z-index: 201;
  left: calc(var(--v2-sheet-inset) + var(--v2-safe-left));
  right: calc(var(--v2-sheet-inset) + var(--v2-safe-right));
  bottom: var(--v2-sheet-inset);
  max-width: 560px;
  margin: 0 auto;
  max-height: calc(100% - var(--v2-safe-top) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--v2-radius-sheet);
  padding-bottom: max(calc(var(--v2-safe-bottom) - var(--v2-sheet-inset)), var(--v2-space-md));
  color: var(--v2-text-primary);
  outline: none;
  transform: translateY(calc(100% + var(--v2-sheet-inset)));
  transition: transform var(--v2-transition-base) var(--v2-ease-out);
}
.scrim.open .glass-sheet { transform: translateY(0); }

/* One of several whole-sheet views (a form and its discard confirmation). */
.sheet-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.sheet-grabber {
  width: 36px;
  height: 5px;
  flex-shrink: 0;
  margin: 8px auto 0;
  border-radius: var(--v2-radius-full);
  background: var(--v2-sheet-handle-bg);
}
.sheet-bar { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 4px 12px 0; flex-shrink: 0; }
.sheet-bar-spacer { width: var(--v2-space-touch); flex: 0 0 var(--v2-space-touch); }
.sheet-close {
  width: var(--v2-space-touch);
  height: var(--v2-space-touch);
  flex: 0 0 var(--v2-space-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: var(--v2-radius-full);
  background: var(--v2-glass-control-fill);
  color: var(--v2-text-primary);
}
.sheet-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  font-family: var(--v2-font-display);
  font-weight: 600;
  font-size: var(--v2-font-size-body);
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
}
.sheet-action {
  min-width: 72px;
  height: var(--v2-space-touch);
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--v2-radius-full);
  background: var(--v2-accent-botanical);
  color: var(--v2-text-on-accent);
  font-family: var(--v2-font-body);
  font-size: var(--v2-font-size-subhead);
  font-weight: 700;
}
.sheet-action[aria-disabled="true"] { background: var(--v2-glass-control-fill); color: var(--v2-text-support); cursor: default; }
.sheet-close:active, .sheet-action:active { opacity: 0.8; }
.sheet-close:focus-visible, .sheet-action:focus-visible { outline: 2px solid var(--v2-accent-text); outline-offset: 2px; }
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 4px;
}

/* ─── Content on a sheet: opaque ─── */
.input-label {
  display: block;
  font-size: var(--v2-font-size-caption2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--v2-text-support);
  margin: 0 0 8px;
}

/* Tags chips: canonical shape (24px, 4px radius, uppercase), text at the 11px floor */
.type-chip, .state-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: var(--v2-chip-height);
  padding: 0 7px;
  border-radius: var(--v2-chip-radius);
  font-size: var(--v2-font-size-caption2);
  font-weight: 600;
  letter-spacing: var(--v2-chip-tracking);
  text-transform: var(--v2-chip-transform);
  white-space: nowrap;
  line-height: 1;
}
.type-chip, .state-chip.is-closed { background: var(--v2-pill-shade-bg); color: var(--v2-pill-shade-text); }
.state-chip.is-open    { background: var(--v2-pop-slate-bg); color: var(--v2-pop-slate-text); }
.state-chip.is-shipped { background: var(--v2-pop-sage-bg);  color: var(--v2-accent-text); }
.state-chip svg { width: 12px; height: 12px; margin-right: 4px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dark .type-chip, .dark .state-chip.is-closed { background: var(--v2-bg-secondary); color: var(--v2-text-support); box-shadow: inset 0 0 0 1px var(--v2-edge); }

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--v2-font-size-footnote);
  font-weight: 500;
  line-height: 1.4;
  color: var(--v2-pop-coral-text);
  margin: 8px 0 0;
}
.field-error svg { width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.trust-card {
  scroll-margin-bottom: calc(var(--v2-safe-bottom) + var(--v2-tabbar-height) + 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  padding: 14px 16px;
  background: var(--v2-pop-sage-bg);
  border: 1px solid var(--v2-accent-botanical);
  border-radius: var(--v2-radius-md);
}
.trust-card .icon-circle {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--v2-accent-botanical);
  color: var(--v2-text-on-accent);
}
.trust-card .icon-circle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trust-card .copy { flex: 1; font-size: var(--v2-font-size-callout); font-weight: 500; line-height: 1.3; color: var(--v2-text-primary); }

.sheet-shimmer { height: 14px; margin: 10px 0; border-radius: 6px; background: var(--v2-glass-control-fill); animation: sheet-shimmer 1.4s ease-in-out infinite; }
.sheet-shimmer.is-short { width: 45%; }
@keyframes sheet-shimmer { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.9; } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: sheet-spin 800ms linear infinite; }
@keyframes sheet-spin { to { transform: rotate(360deg); } }

/* ─── Idea detail: title, type, state and release only ─── */
.idea-sheet-num { margin: 4px 0 2px; font-family: var(--v2-font-display); font-size: var(--v2-font-size-subhead); font-variant-numeric: tabular-nums; color: var(--v2-text-support); }
.idea-sheet-title {
  margin: 0;
  font-family: var(--v2-font-display);
  font-weight: 500;
  font-size: var(--v2-font-size-title2);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--v2-text-primary);
  overflow-wrap: anywhere;
}
.idea-sheet-chips { display: flex; flex-wrap: wrap; gap: var(--v2-chip-gap); margin-top: 14px; }
.idea-sheet-release {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  padding: 12px 14px;
  border-radius: var(--v2-radius-sheet-inner);
  background: var(--v2-glass-control-fill);
  font-size: var(--v2-font-size-subhead);
  line-height: 1.35;
  color: var(--v2-text-primary);
  overflow-wrap: anywhere;
}
.idea-sheet-release svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: var(--v2-text-support); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.idea-sheet-release .input-label { margin: 0 0 2px; color: var(--v2-text-primary); }
/* Issue 750: the person's full text, then who sent it and when. */
.idea-sheet-text { margin: 14px 0 0; font-size: var(--v2-font-size-subhead); line-height: 1.5; color: var(--v2-text-primary); white-space: pre-wrap; overflow-wrap: anywhere; }
.idea-sheet-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--v2-border-soft); font-size: var(--v2-font-size-footnote); line-height: 1.4; }
.idea-sheet-meta dt { color: var(--v2-text-secondary); font-weight: 500; }
.idea-sheet-meta dd { margin: 0; color: var(--v2-text-primary); font-weight: 600; overflow-wrap: anywhere; }
.idea-sheet-none { margin: 16px 0 8px; font-size: var(--v2-font-size-subhead); line-height: 1.45; color: var(--v2-text-support); }

/* ─── Discard confirmation: shown only when a typed note would be lost ─── */
.confirm-title { margin: 12px 20px 2px; font-family: var(--v2-font-display); font-weight: 600; font-size: var(--v2-font-size-title3); text-align: center; }
.confirm-text { margin: 0 20px 16px; font-size: var(--v2-font-size-subhead); line-height: 1.4; text-align: center; color: var(--v2-text-support); }
.confirm-actions { display: grid; gap: 8px; padding: 0 16px 4px; }
.destructive-cta, .keep-cta { width: 100%; min-height: 50px; border-radius: var(--v2-radius-full); font-size: var(--v2-font-size-callout); font-weight: 700; }
.destructive-cta { border: 1px solid var(--v2-pop-coral); background: transparent; color: var(--v2-pop-coral-text); }
.keep-cta { border: none; background: var(--v2-glass-control-fill); color: var(--v2-text-primary); }
.destructive-cta:active, .keep-cta:active { opacity: 0.8; }
.destructive-cta:focus-visible, .keep-cta:focus-visible { outline: 2px solid var(--v2-accent-text); outline-offset: 2px; }

/* Reduce Motion: no travel, no pulsing, no spinning. The sheet appears in place. */
@media (prefers-reduced-motion: reduce) {
  .scrim, .scrim.open, .glass-sheet { transition: none; }
  .sheet-shimmer, .spinner { animation: none; }
}
