/* =========================================================================
   dashboard.css — the editor (setup.html).

   The dashboard is genuinely usable on a phone: the toolbar collapses into
   a menu, the side nav becomes a scrolling strip, and every control clears
   a 44px touch target. Inputs are 16px on small screens, which is what
   stops iOS from zooming in each time one is focused.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Jost:wght@400;500;600&display=swap");

:root {
  --ivory: #faf7f2;
  --paper: #fff;
  --line: #e2dccf;
  --ink: #2c2822;
  --ink-soft: #6a6255;
  --sage: #77906a;
  --sage-dark: #4c6b45;
  --gold: #c69a4e;
  --accent-btn: #b98a6a;
  --danger: #b6473f;

  --font-body: "Jost", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;

  --topbar-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: #f2ede3;
  color: var(--ink);
  overflow-wrap: break-word;
}

.serif { font-family: var(--font-display); }

img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* -------------------------------------------------------------- topbar */

.dash-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 12px clamp(14px, 4vw, 40px);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dash-brand { flex: 1; min-width: 0; }
.dash-topbar h1 { font-family: var(--font-display); font-size: clamp(19px, 4vw, 22px); font-weight: 700; }
.dash-topbar .sub { font-size: 12px; color: #cfc9bb; margin-top: 2px; }

.status-pill {
  font-size: 11.5px;
  color: #cfe8c4;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  padding: 4px 2px;
}
.status-pill.show { opacity: 1; }
.status-pill.pending { color: #e6dcc0; }
.status-pill.error { color: #f4c9c0; cursor: pointer; text-decoration: underline; }

.dash-actions-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 4px;
  min-width: 44px;
  min-height: 44px;
  font-size: 17px;
  cursor: pointer;
}

.dash-topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.file-label { cursor: pointer; }

/* -------------------------------------------------------------- buttons */

.btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  padding: 9px 14px;
  min-height: 38px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent-btn); color: var(--accent-btn); }
.btn.primary { background: var(--sage); border-color: var(--sage); color: #fff; }
.btn.primary:hover { background: var(--sage-dark); border-color: var(--sage-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 7px 11px; min-height: 34px; font-size: 11.5px; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn.ghost:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, 0.08); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --------------------------------------------------------------- layout */

.dash-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
}

.dash-sidenav {
  border-right: 1px solid var(--line);
  padding: 24px 14px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.dash-sidenav a {
  display: block;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 4px;
  margin-bottom: 2px;
}
.dash-sidenav a:hover { background: #efe9db; color: var(--ink); }

.dash-main { padding: 26px clamp(14px, 4vw, 40px) 100px; min-width: 0; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(18px, 3vw, 26px);
  margin-bottom: 24px;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}
.panel h2 { font-family: var(--font-display); font-size: clamp(21px, 4vw, 24px); margin-bottom: 6px; }
.panel .panel-desc { font-size: 13px; line-height: 1.6; color: var(--ink-soft); margin-bottom: 16px; }

/* --------------------------------------------------------------- fields */

.field { display: block; margin-bottom: 16px; }
.field .field-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 11px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fdfcf9;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px rgba(119, 144, 106, 0.15); }

input[type="color"] {
  width: 52px;
  height: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
}
input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; accent-color: var(--sage); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }

.field-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 14px;
  min-height: 40px;
  cursor: pointer;
}

.palette-editor-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.palette-editor-row input[type="text"] { flex: 1; min-width: 0; }

/* --------------------------------------------------------- section cards */

.section-card { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; background: #fdfcf8; overflow: hidden; }
.section-card.disabled { opacity: 0.6; }

.section-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: #f4efe4;
  cursor: pointer;
  flex-wrap: wrap;
}
.section-card-header .drag-num { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--ink-soft); width: 24px; flex-shrink: 0; }
.section-card-header .title-text { flex: 1 1 140px; font-size: 14.5px; font-weight: 500; min-width: 0; }
.section-card-header .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.section-card-header .tag { font-size: 10.5px; padding: 3px 8px; border-radius: 10px; background: #e5ded0; color: var(--ink-soft); white-space: nowrap; }

.section-card-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.section-card-body { padding: 16px 16px 20px; display: none; border-top: 1px solid var(--line); }
.section-card.open .section-card-body { display: block; }
.section-card.open .chevron-icon { transform: rotate(180deg); }
.chevron-icon { transition: transform 0.15s; font-size: 12px; color: var(--ink-soft); }

.blocks-heading { font-size: 17px; margin: 18px 0 10px; }

/* --------------------------------------------------------------- blocks */

.block-editor { border: 1px solid var(--line); border-radius: 5px; margin-bottom: 14px; background: #fff; }
.block-editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #f6f2e9;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.block-editor-header .btype { flex: 1 1 120px; min-width: 0; }
.block-editor-body { padding: 14px; }

.item-row { border: 1px solid var(--line); border-radius: 4px; padding: 12px; margin-bottom: 10px; background: #fdfcf9; }
.item-row-head { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 8px; }

.nested-items {
  display: block;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px dashed #cabfa8;
  border-radius: 5px;
  background: #f9f6ee;
}
.nested-items .field-label { display: block; margin-bottom: 10px; }
.nested-items .item-row { background: #fff; }

/* --------------------------------------------------------------- photos */

.thumb-holder { margin-bottom: 8px; }
.thumb-preview,
.thumb-placeholder {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  display: block;
}
.thumb-preview { object-fit: cover; border: 1px solid var(--line); background: #efe9dd; }
.thumb-placeholder {
  border: 1px dashed #cabfa8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #a99d84;
  background: repeating-linear-gradient(135deg, #efe9dd, #efe9dd 8px, #e8e1d2 8px, #e8e1d2 16px);
}
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------- add rows */

.add-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.add-row select { flex: 0 1 220px; }

.empty-note { font-size: 13px; line-height: 1.6; color: var(--ink-soft); font-style: italic; padding: 10px 0; }

.add-section-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  border: 1px dashed #cabfa8;
  border-radius: 6px;
  padding: 16px;
  margin-top: 8px;
}
.add-section-bar input[type="text"] { flex: 1 1 200px; }
.add-section-bar select { flex: 0 1 200px; }
.add-section-label { font-size: 13px; color: var(--ink-soft); }

/* ------------------------------------------------------------- history */

.revision-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.revision-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fdfcf9;
  flex-wrap: wrap;
}
.revision-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 200px; }
.revision-when { font-size: 13.5px; font-weight: 500; }
.revision-size { font-size: 11.5px; color: var(--ink-soft); }
.revision-note { font-size: 12px; color: var(--sage-dark); font-style: italic; }

.danger-zone { border: 1px solid #eccfc9; background: #fdf5f3; }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: 20px;
  left: 20px;
  max-width: 380px;
  margin-left: auto;
  background: var(--ink);
  color: #fff;
  padding: 13px 18px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* --------------------------------------------------------- breakpoints */

@media (max-width: 980px) {
  .dash-layout { grid-template-columns: 1fr; min-height: 0; }

  /* A horizontal strip keeps the section links reachable without eating
     half the screen the way a stacked list would. */
  .dash-sidenav {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px clamp(14px, 4vw, 40px);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    background: #f7f3ea;
    -webkit-overflow-scrolling: touch;
  }
  .dash-sidenav a { white-space: nowrap; margin-bottom: 0; padding: 9px 13px; }
}

@media (max-width: 720px) {
  .dash-actions-toggle { display: inline-flex; align-items: center; justify-content: center; }

  /* Six toolbar buttons will not fit; fold them into a panel under the bar. */
  .dash-topbar-actions {
    display: none;
    order: 5;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }
  .dash-topbar-actions.open { display: flex; }
  .dash-topbar-actions .btn { justify-content: flex-start; min-height: 44px; font-size: 13.5px; }

  .dash-brand .sub { display: none; }

  /* 16px is the threshold below which iOS Safari zooms on focus. */
  input[type="text"],
  input[type="password"],
  input[type="url"],
  textarea,
  select { font-size: 16px; }

  .btn.small { min-height: 38px; padding: 8px 12px; }

  /* The show/hide toggle sits on its own in the section header with no
     padded label around it, so a default 18px box is an awkward tap. */
  .section-card-controls input[type="checkbox"] { width: 26px; height: 26px; }

  .section-card-header { padding: 12px; }
  .section-card-header .id-tag { display: none; }
  .revision-row { align-items: flex-start; }
  .toast { right: 12px; left: 12px; }
}
