/* Shared stylesheet for the bespoke CMS. Reuses the public site's own
   palette, but deliberately larger and plainer than the public pages —
   this is for a 70-year-old sole editor, not a visitor: fewer choices
   per screen, large touch targets, plain English, nothing that can
   leave him stuck. */

:root {
  --green-900: #1f4d3a;
  --green-700: #2c6b4f;
  --gold-600: #b9822f;
  --cream: #faf6ee;
  --line: #ddd6c4;
  --ink: #22281f;
  --muted: #5a6054;
  --danger: #9b2c2c;
  --danger-bg: #fbeaea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 19px;
  line-height: 1.5;
}

a { color: var(--green-700); }

h1 { color: var(--green-900); font-size: 1.7rem; margin: 0 0 10px; }
h2 { color: var(--green-900); font-size: 1.3rem; margin: 24px 0 12px; }

.cms-header {
  background: var(--green-900);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.cms-header a { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }

.cms-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.cms-breadcrumb { margin: 0 0 18px; }
.cms-breadcrumb a { text-decoration: none; font-weight: 600; }

.cms-intro { color: var(--muted); margin: 0 0 20px; max-width: 640px; }

#cms-error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

/* --- Buttons --- */

.cms-btn {
  display: inline-block;
  border: none;
  border-radius: 14px;
  padding: 16px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  min-height: 48px;
}
.cms-btn-primary { background: var(--green-900); color: #fff; }
.cms-btn-primary:hover { background: var(--gold-600); }
.cms-btn-secondary { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.cms-btn-secondary:hover { background: #f3f0e6; }
.cms-btn-danger { background: var(--danger-bg); color: var(--danger); border: 2px solid var(--danger); }
.cms-btn-danger:hover { background: var(--danger); color: #fff; }
.cms-btn:disabled { opacity: 0.55; cursor: default; }

/* --- Home tiles --- */

.cms-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.cms-tile {
  display: block;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  text-decoration: none;
  color: var(--green-900);
  font-weight: 700;
  font-size: 1.15rem;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cms-tile:hover { border-color: var(--gold-600); background: #fffaf0; }

/* The single most common action (adding a photo) — filled gold so it
   reads as "start here" at a glance, not just another tile in the grid. */
.cms-tile-primary {
  background: var(--gold-600);
  border-color: var(--gold-600);
  color: #fff;
  font-size: 1.25rem;
}
.cms-tile-primary:hover { background: #a6711f; border-color: #a6711f; }

/* --- Photo category grid --- */

.cms-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 10px 0 20px;
}
.cms-category-grid button {
  display: block;
  width: 100%;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 18px 10px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--green-900);
  cursor: pointer;
  min-height: 56px;
}
.cms-category-grid button:hover { border-color: var(--gold-600); background: #fffaf0; }

/* --- Colour swatches (category admin) --- */

.cms-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0;
}
.cms-color-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--line);
  cursor: pointer;
  padding: 0;
}
.cms-color-swatch:hover { box-shadow: 0 0 0 2px var(--gold-600); }
.cms-color-swatch-selected { box-shadow: 0 0 0 3px var(--green-900); }
.cms-color-swatch-static { cursor: default; width: 36px; height: 36px; }
.cms-color-swatch-static:hover { box-shadow: 0 0 0 2px var(--line); }

.cms-color-list { list-style: none; margin: 0; padding: 0; }
.cms-color-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.cms-field { margin-bottom: 20px; }
.cms-field label { display: block; font-weight: 700; margin-bottom: 8px; }
.cms-field input[type="text"],
.cms-field input[type="file"],
.cms-field textarea {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.cms-field textarea { min-height: 120px; text-align: left; resize: vertical; }
.cms-field input[type="text"]:focus,
.cms-field textarea:focus { outline: 3px solid var(--gold-600); outline-offset: 1px; }
.cms-hint { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.cms-checkbox-field { display: flex; align-items: flex-start; gap: 10px; }
.cms-checkbox-field input { width: 24px; height: 24px; margin-top: 2px; flex: none; }
.cms-checkbox-field label { margin: 0; font-weight: 500; }

details.cms-more {
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  margin: 10px 0 24px;
  background: #fff;
}
details.cms-more summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--green-900);
  font-size: 1.05rem;
  padding: 6px 0;
}
details.cms-more[open] summary { margin-bottom: 10px; }

/* --- Browse lists --- */

.cms-entry-list { list-style: none; margin: 0; padding: 0; }
.cms-entry-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.cms-entry-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.cms-entry-title { font-weight: 700; flex: 1 1 auto; }
.cms-entry-meta { color: var(--muted); font-size: 0.9rem; }
.cms-entry-edit { font-weight: 700; text-decoration: none; }
.cms-empty { color: var(--muted); font-style: italic; }

/* --- Click-to-place photo stage (numbering, pin-placing) --- */

.cms-stage-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  cursor: crosshair;
  border-radius: 10px;
  overflow: hidden;
}
.cms-stage-wrap img { max-width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
.cms-marker {
  position: absolute;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  margin-top: -15px;
  border-radius: 50%;
  background: var(--gold-600);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer;
}
.cms-marker:hover { background: var(--danger); }
.cms-marker.cms-marker-ref { background: #2b6ea8; width: 22px; height: 22px; margin-left: -11px; margin-top: -11px; }
.cms-marker.cms-marker-current { background: var(--danger); }

/* --- Status / feedback --- */

.cms-status { font-weight: 700; padding: 10px 0; }
.cms-status-pending { color: var(--gold-600); }
.cms-status-ok { color: var(--green-700); }
.cms-status-error { color: var(--danger); }

@media (max-width: 480px) {
  body { font-size: 18px; }
  .cms-main { padding: 18px 14px 70px; }
  .cms-btn { width: 100%; text-align: center; margin-bottom: 10px; }
}
