/* ── Hero Settings Drawer — Phase 5 inline editor ────────────────────────
   Right-side panel (320 px) that slides in when the hero section is
   selected. Only active in inline-edit-active mode.
   ─────────────────────────────────────────────────────────────────────── */

.hsd-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  z-index: 9600;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: -6px 0 32px rgba(15, 23, 42, 0.12);
  transform: translateX(calc(100% + 2px)); /* +2px ensures no sub-pixel leakage */
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  visibility: hidden;
  will-change: transform;
  overflow: hidden; /* prevent the closed drawer from expanding viewport on iOS */
}
.hsd-drawer.is-open {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
}

/* dark mode */
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-drawer {
  background: rgba(18, 24, 38, 0.99);
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: -6px 0 32px rgba(0, 0, 0, 0.4);
}

/* ── Header ──────────────────────────────────────────────────────────── */
.hsd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  flex-shrink: 0;
  background: #f8fafc;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-header {
  background: rgba(22, 30, 46, 0.95);
  border-color: rgba(148, 163, 184, 0.14);
}
.hsd-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-title {
  color: rgba(226, 232, 240, 0.75);
}
.hsd-close {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}
.hsd-close:hover { color: #1e293b; background: #e2e8f0; }
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-close:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
}

/* ── Body (scrollable) ───────────────────────────────────────────────── */
.hsd-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.3rem 0;
}
.hsd-body::-webkit-scrollbar { width: 4px; }
.hsd-body::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 2px; }

/* ── Accordion groups ────────────────────────────────────────────────── */
.hsd-group {
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-group {
  border-color: rgba(148, 163, 184, 0.10);
}
.hsd-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  user-select: none;
  transition: background 120ms ease;
}
.hsd-group-header:hover { background: #f1f5f9; }
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-group-header {
  color: rgba(226, 232, 240, 0.85);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-group-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.hsd-group-header::-webkit-details-marker { display: none; }
.hsd-group-icon { color: #6366f1; font-size: 0.68rem; width: 0.9rem; text-align: center; }
.hsd-chevron {
  margin-left: auto;
  font-size: 0.6rem;
  color: #94a3b8;
  transition: transform 200ms ease;
}
.hsd-group[open] .hsd-chevron { transform: rotate(180deg); }
.hsd-group-body { padding: 0.4rem 0.9rem 0.75rem; }

/* ── Form controls ───────────────────────────────────────────────────── */
.hsd-label {
  display: flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0.6rem 0 0.25rem;
}
.hsd-label:first-child { margin-top: 0; }
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-label {
  color: rgba(148, 163, 184, 0.8);
}
.hsd-val {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  color: #6366f1;
  font-variant-numeric: tabular-nums;
}
.hsd-input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.45rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 130ms ease, box-shadow 130ms ease;
  box-sizing: border-box;
}
.hsd-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-input {
  background: rgba(22, 30, 46, 0.9);
  border-color: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-input:focus {
  border-color: rgba(99, 102, 241, 0.6);
}

.hsd-range {
  width: 100%;
  margin: 0.25rem 0 0;
  accent-color: #6366f1;
  cursor: pointer;
}

.hsd-textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.45rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  resize: vertical;
  min-height: 3.5rem;
  font-family: inherit;
  transition: border-color 130ms ease, box-shadow 130ms ease;
  box-sizing: border-box;
}
.hsd-textarea:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-textarea {
  background: rgba(22, 30, 46, 0.9);
  border-color: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
}

/* ── Toggle switch ───────────────────────────────────────────────────── */
.hsd-toggle-row {
  display: flex;
  align-items: center;
  margin: 0.65rem 0 0.35rem;
}
.hsd-toggle {
  position: relative;
  width: 2.2rem;
  height: 1.2rem;
  border-radius: 999px;
  background: #e2e8f0;
  border: none;
  cursor: pointer;
  transition: background 180ms ease;
  flex-shrink: 0;
  margin-left: auto;
}
.hsd-toggle.is-on { background: #6366f1; }
.hsd-toggle-dot {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 180ms ease;
}
.hsd-toggle.is-on .hsd-toggle-dot { transform: translateX(1rem); }

/* ── Chip row ────────────────────────────────────────────────────────── */
.hsd-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.hsd-chip {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  text-align: center;
  transition: background 110ms ease, border-color 110ms ease, color 110ms ease;
}
.hsd-chip:hover { background: #f1f5f9; color: #1e293b; }
.hsd-chip.is-active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
  color: #4338ca;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-chip {
  color: rgba(226, 232, 240, 0.7);
  border-color: rgba(148, 163, 184, 0.2);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-chip:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-chip.is-active {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
}

/* ── Action buttons ──────────────────────────────────────────────────── */
.hsd-action-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  font-size: 0.77rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  margin-bottom: 0.45rem;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.hsd-action-btn:hover { background: #f1f5f9; border-color: rgba(99, 102, 241, 0.3); color: #4338ca; }
.hsd-action-btn i { font-size: 0.72rem; color: #6366f1; }
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-action-btn {
  color: rgba(226, 232, 240, 0.75);
  border-color: rgba(148, 163, 184, 0.18);
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

/* ── Slides list ─────────────────────────────────────────────────────── */
.hsd-slide-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ── Expanded slide card ─── */
.hsd-slide-card {
  border-radius: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #f8fafc;
  overflow: hidden;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-slide-card {
  background: rgba(22, 30, 46, 0.8);
  border-color: rgba(148, 163, 184, 0.14);
}

.hsd-slide-top {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.45rem;
}

/* Image button — thumbnail with camera overlay */
.hsd-slide-img-btn {
  position: relative;
  flex-shrink: 0;
  width: 3rem;
  height: 2.25rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-slide-img-btn {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(148, 163, 184, 0.16);
}
.hsd-slide-img-btn .hsd-slide-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hsd-slide-thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #94a3b8;
}
.hsd-slide-img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.65rem;
  opacity: 0;
  transition: opacity 130ms ease;
}
.hsd-slide-img-btn:hover .hsd-slide-img-overlay { opacity: 1; }

/* Inline inputs for title and subtitle */
.hsd-slide-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}
.hsd-slide-input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.3rem;
  background: #fff;
  color: #1e293b;
  font-size: 0.73rem;
  padding: 0.22rem 0.45rem;
  outline: none;
  transition: border-color 120ms ease;
}
.hsd-slide-input:focus { border-color: #6366f1; }
.hsd-slide-input-sm { font-size: 0.68rem; color: #64748b; }
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-slide-input {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-slide-input:focus {
  border-color: #6366f1;
}

.hsd-slide-del {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.3rem;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 120ms ease, background 120ms ease;
  margin-top: 0.1rem;
}
.hsd-slide-del:hover { background: #fee2e2; color: #dc2626; }

/* CTA row */
.hsd-slide-cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  padding: 0 0.45rem 0.45rem;
}

.hsd-slide-empty {
  font-size: 0.73rem;
  color: #94a3b8;
  padding: 0.4rem 0.2rem;
  font-style: italic;
}
.hsd-add-slide-btn { color: #6366f1; border-color: rgba(99, 102, 241, 0.3); }
.hsd-add-slide-btn:hover { background: rgba(99, 102, 241, 0.07); border-color: rgba(99, 102, 241, 0.5); color: #4338ca; }
.hsd-add-slide-btn i { color: inherit; }

/* ── Utility ─────────────────────────────────────────────────────────── */
.hsd-hidden { display: none !important; }
.hsd-field-group { margin-top: 0.6rem; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.hsd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  flex-shrink: 0;
  background: #f8fafc;
}
:is(body.theme-dark, body.ui-mode-dark, body.public-site-body.preset-mode-dark) .hsd-footer {
  background: rgba(22, 30, 46, 0.95);
  border-color: rgba(148, 163, 184, 0.12);
}
.hsd-status {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  transition: color 200ms ease;
}
.hsd-status.is-saving { color: #f59e0b; }
.hsd-status.is-saved  { color: #16a34a; }
.hsd-status.is-error  { color: #dc2626; }
.hsd-settings-link {
  font-size: 0.68rem;
  font-weight: 600;
  color: #6366f1;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  opacity: 0.75;
  transition: opacity 130ms ease;
}
.hsd-settings-link:hover { opacity: 1; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .hsd-drawer {
    width: 100vw;
    top: auto;
    bottom: 0;
    height: auto;
    max-height: 78vh;
    transform: translateY(calc(100% + 2px));
    border-left: none;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.18);
    z-index: 9700;             /* above toolbar (10000 toolbar is hidden by body class anyway) */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .hsd-drawer.is-open { transform: translateY(0); }

  /* Grab handle affordance */
  .hsd-drawer::before {
    content: '';
    display: block;
    width: 2.25rem;
    height: 0.25rem;
    margin: 0.45rem auto 0.1rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.45);
    flex-shrink: 0;
  }

  /* Backdrop is a sibling div injected by JS — see hero-settings-drawer.js */
  .hsd-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 9690;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }
  .hsd-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .hsd-header {
    padding: 0.55rem 0.9rem 0.65rem;
  }
  .hsd-close {
    width: 2rem;
    height: 2rem;
    font-size: 0.85rem;
  }
  /* Larger touch targets inside */
  .hsd-group-header {
    padding: 0.75rem 0.9rem;
    font-size: 0.82rem;
  }
  .hsd-input,
  .hsd-textarea {
    font-size: 0.88rem;
    padding: 0.55rem 0.7rem;
  }
  .hsd-action-btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }
  .hsd-chip {
    padding: 0.5rem 0.55rem;
    font-size: 0.78rem;
  }
}
