/* TCBC site admin. Large, high-contrast, touch-friendly: it's used by the
   club's webmasters, often on a phone or tablet. */
:root {
  --brand: #0d1f3c;
  --brand-dark: #081428;
  --accent: #c9a84c;
  --bg: #faf6ee;
  --card: #fff;
  --ink: #222;
  --muted: #666;
  --border: #e8dfcc;
  --danger: #b3261e;
  --ok: #1e7b34;
  --warn: #b35c00;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--brand); }
h1 { font-size: 1.7rem; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.25rem; margin: 0 0 0.6em; }
h3 { font-size: 1.05rem; }

/* ---- header ---- */
header#nav { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.nav-top { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; }
.app-version { font-weight: 400; font-size: 0.75rem; opacity: 0.7; margin-left: 0.35rem; }
.app-version .update-btn { margin-left: 0; padding: 0; font-size: 0.75rem; }
#logout-btn, .view-site { white-space: nowrap; }
.nav-top .view-site + .link-btn { margin-left: 4px; }
@media (max-width: 600px) { .app-version { display: block; margin-left: 0; } }
.link-btn { background: none; border: 0; color: #fff; font: inherit; font-size: 0.95rem; text-decoration: underline; cursor: pointer; margin-left: auto; padding: 4px; }
.link-btn.dark { color: var(--brand); margin: 0; }
.nav-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.nav-links a { color: #fff; text-decoration: none; padding: 10px 14px; border-radius: var(--radius) var(--radius) 0 0; font-weight: 600; opacity: 0.85; }
.nav-links a.active { background: var(--bg); color: var(--brand); opacity: 1; }
.publish-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; margin: 0 -16px; padding: 8px 16px; background: #f0e8d5; color: var(--ink); font-size: 0.95rem; }
.publish-bar.has-changes { background: #fff3cd; }
.publish-actions { display: flex; gap: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); margin-right: 4px; }

main#app { max-width: 760px; margin: 0 auto; padding: 16px; }
.centered { min-height: 80vh; display: flex; align-items: center; justify-content: center; }

/* ---- cards / forms ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.login { width: 100%; max-width: 420px; }
.login h1 { text-align: center; }
.login small { font-size: 0.6em; color: var(--muted); font-weight: 400; }
.notice { padding: 10px 12px; margin: 0 0 16px; background: #f5e9c8; border-left: 4px solid var(--accent); border-radius: 6px; font-size: 0.95rem; }
label, .field__label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="tel"], input[type="date"], select, textarea {
  width: 100%; margin-top: 4px; padding: 12px; font: inherit; border: 1px solid #cfc6b4; border-radius: var(--radius); background: #fff;
}
/* typed text stays regular weight inside a bold <label> */
label > input, label > select, label > textarea { font-weight: 400; }
input:focus, select:focus, textarea:focus, .richtext-editor:focus { outline: 3px solid rgba(13, 31, 60, 0.35); outline-offset: 1px; }
.field { margin-bottom: 20px; }
.field-hint, .hint { color: var(--muted); font-size: 0.9rem; margin: 2px 0 6px; font-weight: 400; }
.req { color: var(--danger); }
label.checkbox { display: flex; gap: 10px; align-items: center; font-weight: 600; }
label.checkbox input { width: 24px; height: 24px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.richtext-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.richtext-btn { min-width: 44px; min-height: 40px; border: 1px solid #cfc6b4; background: #fff; border-radius: 6px; font-size: 1rem; cursor: pointer; }
.richtext-editor { min-height: 120px; padding: 12px; border: 1px solid #cfc6b4; border-radius: var(--radius); background: #fff; }
.richtext-editor ul { margin: 0; padding-left: 1.4em; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; border: 0; border-radius: var(--radius); font: 600 1rem/1.2 inherit; font-family: inherit; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn.big { min-height: 56px; font-size: 1.15rem; padding: 14px 26px; }
.btn.full-width { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn { min-width: 40px; min-height: 40px; border: 1px solid #cfc6b4; background: #fff; border-radius: 6px; font-size: 1.1rem; cursor: pointer; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* ---- lists ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
ul.item-list { list-style: none; margin: 0 0 20px; padding: 0; }
.item-row { display: flex; gap: 14px; align-items: center; padding: 14px; margin-bottom: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.item-row:hover { border-color: var(--brand); }
.item-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.item-thumb.placeholder { display: inline-block; }
.item-title { display: block; font-weight: 700; }
.item-meta { display: block; color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); padding: 20px; text-align: center; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #fff3cd; color: #6b4c00; font-size: 0.8rem; font-weight: 600; vertical-align: middle; }


/* ---- events ---- */
.toolbar h1 { margin-bottom: 0.3em; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--brand); font: inherit; font-size: 0.9rem; cursor: pointer; }
.chip:hover { border-color: var(--brand); }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-list label.checkbox { font-weight: 600; }
.danger-zone { border-color: #f0c7c3; }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--danger); }

/* ---- results grid ---- */
.save-bar { position: sticky; bottom: 0; z-index: 5; margin: 0 0 18px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.counts label { font-size: 0.9rem; }
@media (max-width: 560px) { .counts { grid-template-columns: repeat(2, 1fr); } }
.placement { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 10px; margin-bottom: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.placement__fields { display: grid; grid-template-columns: 2fr 1fr; gap: 6px 10px; }
.placement__fields label { font-size: 0.85rem; margin: 0; }
.placement__fields input, .placement__fields select { padding: 8px; }
.placement__dog { grid-column: 1 / -1; }
.placement__photo { grid-column: 1; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.placement__photo label { font-size: 0.85rem; margin: 0; }
.placement__photo input { padding: 8px; }
.placement__photo-side { flex: 1; min-width: 180px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.placement__tools { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 6px; }
.crop-thumb { position: relative; overflow: hidden; flex: none; width: 160px; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: 6px; background-color: #eee; }
.crop-thumb img { position: absolute; max-width: none; display: block; }
.photo-tile .crop-thumb { width: 100%; }

/* ---- crop dialog ---- */
dialog.crop-dialog { width: min(900px, 96vw); }
.crop__stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto 12px; overflow: hidden; line-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop__img { display: block; max-width: 100%; max-height: 62vh; }
.crop__box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); cursor: move; touch-action: none; }
.crop__box:focus-visible { outline: 3px solid var(--accent); }
.crop__handle { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; background: #fff; border-top-left-radius: 8px; cursor: nwse-resize; }

/* ---- PDF picker, history ---- */
.doc-filter { margin-bottom: 8px; }
.doc-list { list-style: none; margin: 0; padding: 0; max-height: 45vh; overflow-y: auto; }
.doc-list li { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.doc-item { flex: 1; padding: 10px 4px; border: 0; background: none; color: var(--brand); font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.doc-item:hover, .doc-item:focus { text-decoration: underline; }
.history-panel summary, details.card > summary { cursor: pointer; font-weight: 700; }
.history { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.95rem; }
.history li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---- photos ---- */
.image-field { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.image-field img { width: 140px; height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.image-field__actions { display: flex; flex-direction: column; gap: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 10px; }
.photo-tile { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.photo-tile input { font-size: 0.85rem; padding: 6px; }
.photo-tile__actions { display: flex; justify-content: space-between; margin-top: 6px; }
dialog.picker { width: min(720px, 94vw); max-height: 88vh; border: 0; border-radius: 12px; padding: 18px; }
dialog.picker::backdrop { background: rgba(0, 0, 0, 0.5); }
.picker__head { display: flex; justify-content: space-between; align-items: center; }
.upload-btn { display: inline-flex; width: 100%; }
.picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.picker__item { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.picker__item:hover, .picker__item:focus { border-color: var(--brand); }
.picker__item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }

/* ---- list fields ---- */
.list-row { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; background: #fffdf8; }
.list-row[open] { border-color: var(--brand); background: #fff; }
.list-row__head { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 90px 12px 14px; cursor: pointer; list-style: none; }
.list-row__head::-webkit-details-marker { display: none; }
.list-row__head::before { content: "▸ Edit"; position: absolute; right: 14px; top: 12px; color: var(--brand); font-size: 0.85rem; font-weight: 600; }
.list-row[open] > .list-row__head::before { content: "▾ Close"; }
.list-row__title { font-weight: 700; }
.list-row__summary { color: var(--muted); font-size: 0.9rem; }
.list-row__tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; border-bottom: 1px solid var(--border); }
.list-row__body { padding: 14px; }

/* where a section's photos go: little page diagrams */
.layout-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.layout-option { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius); font-weight: 400; font-size: 0.9rem; text-align: center; cursor: pointer; }
.layout-option:has(input:checked) { border-color: var(--brand); background: #f5e9c8; font-weight: 600; }
.layout-option input { position: absolute; opacity: 0; }
.layout-option:has(input:focus-visible) { outline: 3px solid rgba(13, 31, 60, 0.35); }
.layout-diagram { display: grid; gap: 3px; width: 72px; height: 52px; padding: 5px; background: #fff; border: 1px solid #cfc6b4; }
.layout-diagram i { display: block; background: #e3dccb; border-radius: 2px; }
.layout-diagram .ph { background: var(--accent); opacity: 0.7; }
.layout-diagram--above { grid-template: 2fr 1fr 1fr 1fr / 1fr; }
.layout-diagram--below { grid-template: 1fr 1fr 1fr 2fr / 1fr; }
.layout-diagram--below .ph { order: 4; }
.layout-diagram--left, .layout-diagram--right { grid-template: repeat(3, 1fr) / 1fr 1fr; }
.layout-diagram--left .ph { grid-row: 1 / 4; grid-column: 1; }
.layout-diagram--right .ph { grid-row: 1 / 4; grid-column: 2; }


/* ---- settings ---- */
.theme-list { list-style: none; padding: 0; }
.theme-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }

/* ---- misc ---- */
.loading { color: var(--muted); }
.error { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: 92vw; padding: 14px 20px; border-radius: var(--radius); background: #222; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.3); z-index: 100; font-weight: 600; }
.toast--error { background: var(--danger); }

/* ---- phones: sections along the bottom (index.html #tabbar) ---- */
:root { --tabbar-h: 56px; --tabbar-space: 0px; }
#tabbar, .brand-short { display: none; }
@media (max-width: 700px) {
  :root { --tabbar-space: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .nav-links, .view-site, .brand-long { display: none; }
  .brand-short { display: inline; }
  .nav-top .view-site + .link-btn { margin-left: auto; }
  #tabbar:not([hidden]) {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: var(--tabbar-space);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--brand); box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
  }
  #tabbar a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: rgba(255, 255, 255, 0.78); text-decoration: none; font-size: 0.72rem; font-weight: 600;
  }
  #tabbar svg { width: 24px; height: 24px; }
  #tabbar a[aria-current="page"] { color: var(--accent); }
  #tabbar a:active { opacity: 0.6; }
  body { padding-bottom: var(--tabbar-space); }
  .save-bar { bottom: var(--tabbar-space); }
  .toast { bottom: calc(var(--tabbar-space) + 12px); }
  /* the keyboard covers the bottom of the screen while typing (app.js) */
  body.keyboard-open { --tabbar-space: 0px; }
  body.keyboard-open #tabbar { display: none; }
}
