/* ═══════════════════════════════════════════════════════════════
   THE GOOD HARVEST — gh_dialog
   The shared confirm / alert dialog. Replaces native confirm() and
   alert(). Markup is built by js/gh_dialog.js; this file styles it.

   SELF-CONTAINED ON PURPOSE. Not every page that needs a dialog links
   css/gh_styles.css — good-harvest-staff.html carries its own inline
   :root, and its --gold/--cream differ from the design system's. So the
   dialog declares its own palette on .ghd-overlay rather than inheriting
   the page's, and looks the same everywhere it is opened.
   ═══════════════════════════════════════════════════════════════ */

.ghd-overlay {
  --ghd-forest:     #1B4332;
  --ghd-forest-mid: #2D6A4F;
  --ghd-gold:       #C9900C;
  --ghd-gold-pale:  #FFF8E1;
  --ghd-warm:       #F5EFE0;
  --ghd-ink:        #1A1E1C;
  --ghd-ink-soft:   #3A4038;
  --ghd-white:      #FFFFFF;
  --ghd-danger:     #E63946;
  --ghd-black-5:    rgba(0,0,0,0.05);

  position: fixed; inset: 0; z-index: 4000;
  background: rgba(12,31,23,0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  opacity: 0;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.ghd-overlay.is-open { opacity: 1; }

/* ── The card — option B: wide, with a gold title band ───────── */
.ghd {
  /* Not decoration. The overlay's backdrop-filter forces a compositing
     layer, and at phone widths admin/courses.html scrolls its table in an
     `overflow-x: auto` box which is composited too. A 390px capture taken
     the instant the dialog opened showed that page's badges and icons
     painted straight through this card — during the open transition only;
     once settled the card is clean, measured at 0 deviation from white.
     `isolation` gives the card its own stacking context, which is the
     standard remedy for exactly this. HONESTLY: the transient could not
     afterwards be reproduced on demand, so this line is a correct and free
     declaration rather than a measured fix. See the long note in
     tests/dialog_drive.mjs. */
  isolation: isolate;
  background: var(--ghd-white);
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(12,31,23,0.1), 0 8px 20px rgba(12,31,23,0.05);
  width: 100%; max-width: 520px;
  overflow: hidden;
  text-align: left;
  transform: translateY(8px) scale(0.985);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.ghd-overlay.is-open .ghd { transform: none; }

.ghd__band {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--ghd-gold-pale);
  border-bottom: 1px solid rgba(201,144,12,.28);
}
.ghd__icon {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 9999px;
  background: rgba(27,67,50,.1); color: var(--ghd-forest);
}
.ghd--danger .ghd__icon { background: rgba(230,57,70,.1); color: var(--ghd-danger); }

.ghd__title {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--ghd-forest);
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.ghd__body { padding: 1.5rem; }
.ghd__text {
  color: var(--ghd-ink-soft);
  font-size: 1rem; line-height: 1.55;
  margin: 0;
  overflow-wrap: anywhere;
}
.ghd__note {
  margin-top: 1rem; padding: 0.75rem 1rem;
  background: var(--ghd-warm);
  border-left: 3px solid var(--ghd-gold);
  border-radius: 0 6px 6px 0;
  font-size: 0.75rem; color: var(--ghd-ink-soft); line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Wraps, so two buttons whose labels do not fit one row on a phone stack,
   Cancel above, each still right-aligned and its own width. Buttons that fit
   one row are laid out exactly as before. */
.ghd__footer {
  display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--ghd-black-5);
}

/* ── Buttons ─────────────────────────────────────────────────────
   Its own classes, not .btn — the design system's .btn is only
   defined in gh_styles.css, which not every host page links.
   The convention is the course editor's: outline Cancel, then a
   solid primary. See CLAUDE.md, "UI components → Dialogs". */
.ghd__btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; font-weight: 600; font-size: 0.75rem;
  border: none; cursor: pointer;
  border-radius: 9999px;
  padding: 0.5rem 1.25rem;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.ghd__btn:focus-visible { outline: 2px solid var(--ghd-forest); outline-offset: 2px; }

.ghd__btn--cancel {
  background: transparent; color: var(--ghd-forest);
  border: 1.5px solid var(--ghd-forest);
  padding: calc(0.5rem - 1.5px) calc(1.25rem - 1.5px);
}
.ghd__btn--cancel:hover { background: var(--ghd-forest); color: var(--ghd-white); }

.ghd__btn--primary { background: var(--ghd-forest); color: var(--ghd-white); }
.ghd__btn--primary:hover { background: var(--ghd-forest-mid); }

.ghd__btn--danger { background: var(--ghd-danger); color: var(--ghd-white); font-weight: 700; }
.ghd__btn--danger:hover { background: #cf2f3c; }
.ghd__btn--danger:focus-visible { outline-color: var(--ghd-danger); }

/* ── Phone ───────────────────────────────────────────────────── */
@media (max-width: 560px) {
  /* Tighter spacing only. The buttons deliberately do NOT stretch: the
     approved option-b-phone-390 preview shows them compact and right-aligned,
     and `flex: 1` here made both full-width — a shape change, not a tightening.
     Renzo chose from that picture, so the picture governs. */
  .ghd-overlay { padding: 1rem; }
  .ghd { border-radius: 20px; }
  .ghd__band { padding: 1rem 1.125rem; gap: 0.75rem; }
  .ghd__icon { width: 38px; height: 38px; }
  .ghd__title { font-size: 1.0625rem; }
  .ghd__body { padding: 1.125rem; }
  .ghd__text { font-size: 0.9375rem; }
  .ghd__footer { padding: 0.875rem 1.125rem calc(0.875rem + env(safe-area-inset-bottom)); }
  .ghd__btn { font-size: 0.875rem; padding: 0.75rem 1rem; }
  .ghd__btn--cancel { padding: calc(0.75rem - 1.5px) calc(1rem - 1.5px); }
}

@media (prefers-reduced-motion: reduce) {
  .ghd-overlay, .ghd { transition: none; }
}
