/* Public guild page editor (web/public-guild-ui.js, docs/guild-public-and-recipes-plan.md §1.5). Every class is pg-*.
   Colours come from the theme tokens in themes.css; class colours arrive as --cc through CSSOM (no inline styles). */
.pg { margin: 16px 0; padding: 16px; min-width: 0; }
.pg *, .pg *::before, .pg *::after { box-sizing: border-box; }
.pg-head { margin-bottom: 12px; }
.pg-title { margin: 0 0 4px; font-family: var(--display); font-size: 20px; color: var(--gold); letter-spacing: .04em; }
.pg-lead { margin: 0; color: var(--muted); max-width: 70ch; }
.pg-note { margin: 12px 0; color: var(--muted); }
.pg-bad { color: var(--danger); }
.pg-hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.pg-warn { margin: 6px 0 0; padding: 6px 10px; color: var(--warn); font-size: 13px; line-height: 1.4; border-left: 3px solid var(--warn); background: var(--surface-subtle); }
.pg-err { margin: 4px 0 0; color: var(--danger); font-size: 14px; line-height: 1.4; }
.pg-err[hidden], .pg-warn[hidden], .pg [hidden] { display: none; }

/* status */
.pg-status { display: grid; gap: 10px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-subtle); }
.pg-status[data-on="1"] { border-color: var(--gold-dim); }
.pg-status-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pg-status-text { flex: 1 1 200px; margin: 0; }
.pg-pill { display: inline-block; padding: 2px 10px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
.pg-pill-on { color: var(--on-accent); background: var(--heal); border-color: var(--heal); }
.pg-addr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.pg-addr { display: inline-block; padding-block: 10px; color: var(--gold); overflow-wrap: anywhere; min-width: 0; }
.pg-addr-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.pg-addr-btns .btn { min-height: 44px; padding: 0 14px; text-decoration: none; }

/* switch (role=switch button) */
.pg-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px 0 6px; color: var(--text); font: inherit; background: var(--tile); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.pg-switch:disabled { opacity: .6; cursor: not-allowed; }
.pg-switch-track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--input); border: 1px solid var(--line-strong); flex: none; }
.pg-switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); }
.pg-switch[aria-checked="true"] .pg-switch-track { background: var(--surface-selected); border-color: var(--heal); }
.pg-switch[aria-checked="true"] .pg-switch-thumb { transform: translateX(20px); background: var(--heal); }

/* stale prompt and messages */
.pg-stale { margin-bottom: 12px; padding: 12px; border: 1px solid var(--warn); border-radius: 6px; background: var(--surface-notification); }
.pg-stale p { margin: 0 0 8px; }
.pg-stale-title { font-weight: 700; color: var(--warn); }
.pg-msg { min-height: 1.4em; margin: 0 0 8px; color: var(--heal); }
.pg-msg:empty { min-height: 0; margin: 0; }
.pg-msg.pg-bad { color: var(--danger); }
.pg-msg.pg-bad, .pg-msg-near.pg-bad { padding: 10px 12px; border: 1px solid var(--danger-line); border-left: 3px solid var(--danger); border-radius: 4px; background: var(--danger-bg); }
.pg-msg:not(.pg-bad):not(:empty), .pg-msg-near:not(.pg-bad):not(:empty) { padding: 10px 12px; border: 1px solid var(--success-line); border-left: 3px solid var(--heal); border-radius: 4px; background: var(--success-bg); }
/* Below the sticky app header (72 px) and the sticky tab row (~50 px) on wide screens; phones have neither on top. */
.pg-msg:not(.pg-bad):not(:empty) { position: sticky; top: 132px; z-index: 7; scroll-margin-top: 140px; }
@media (max-width: 600px) { .pg-msg:not(.pg-bad):not(:empty) { top: 8px; scroll-margin-top: 16px; } }

/* layout: form and preview side by side on wide screens */
.pg-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) {
  .pg-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .pg-preview { position: sticky; top: calc(var(--head-h, 72px) + 12px); max-height: calc(100vh - var(--head-h, 72px) - 24px); overflow: auto; }
  .pg-grid:has(> .pg-form-wrap:not([open])) { grid-template-columns: minmax(0, 1fr); }
  .pg-grid:has(> .pg-form-wrap:not([open])) > .pg-preview { position: static; max-width: 560px; }
}
.pg-form { min-width: 0; }
.pg-sec { margin: 0 0 14px; padding: 12px; min-width: 0; border: 1px solid var(--line); border-radius: 6px; }
.pg-sec-title { padding: 0 6px; color: var(--gold); font-family: var(--display); font-size: 15px; letter-spacing: .06em; }
.pg-field { display: block; margin: 12px 0 0; padding: 0; border: 0; min-width: 0; }
.pg-field:first-of-type { margin-top: 4px; }
.pg-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pg-label { display: block; margin: 0 0 4px; padding: 0; color: var(--gold-dim); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.pg-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pg-count.pg-over { color: var(--danger); font-weight: 700; }
.pg-input { display: block; max-width: 100%; }
textarea.pg-input { min-height: 120px; }
.pg-invalid .pg-input { border-color: var(--danger); }
.pg-prefixed { display: flex; align-items: stretch; min-width: 0; }
.pg-prefix { display: flex; align-items: center; padding: 0 8px; color: var(--muted); font-size: 13px; background: var(--tile); border: 1px solid var(--line); border-right: 0; border-radius: 4px 0 0 4px; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.pg-prefixed .pg-input { border-radius: 0 4px 4px 0; min-width: 0; }
.pg-field.pg-check { margin-top: 2px; }
.pg-check-label { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.pg-check-label input { flex: none; width: 20px; height: 20px; accent-color: var(--gold); }

/* chips: classes, roles, languages, days */
.pg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--tile); cursor: pointer; }
.pg-chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--gold); }
.pg-chip:has(input:checked) { border-color: var(--gold-dim); background: var(--surface-selected); }
.pg-cls { --cc: var(--line); border-left: 3px solid var(--cc); }
.pg-cls span { color: var(--cc); }
.pg-day { min-width: 56px; justify-content: center; }

/* raid nights */
.pg-nights { display: grid; gap: 10px; margin-top: 10px; }
.pg-night { margin: 0; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 6px; min-width: 0; }
.pg-night-title { padding: 0 6px; color: var(--text); font-weight: 700; }
.pg-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pg-remove { margin-top: 10px; min-height: 44px; }
.pg-add { margin-top: 10px; }
.pg-noslots { margin-top: 8px; }

.pg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.pg-form > .pg-actions { position: sticky; bottom: calc(var(--bottom-bar, 0px) + env(safe-area-inset-bottom)); z-index: 6; margin: 12px -12px 0;
  padding: 10px 12px; background: var(--save-bar); border-top: 1px solid var(--line-strong); backdrop-filter: blur(12px); }
.pg-msg-near { flex: 1 1 100%; margin: 0; color: var(--heal); outline: none; }
.pg-msg-near:empty { display: none; }
.pg-msg-near.pg-bad { color: var(--danger); }
.pg-form > .pg-actions { gap: 8px; padding: 8px 12px; }
.pg-form > .pg-actions .pg-msg-near:not(.pg-bad) { display: none; }
/* Keep the upper error live region available to assistive technology while its near copy is visible. */
.pg-msg.pg-bad:has(~ * .pg-form-wrap[open]) { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pg-dirty:empty { display: none; }
@media (max-width: 600px) {
  .pg-form > .pg-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 14px; letter-spacing: .04em; line-height: 1.15; }
  .pg-form > .pg-actions .pg-dirty { flex: 1 1 100%; order: 3; text-align: center; }
}
@media (max-width: 380px) {
  .pg-form > .pg-actions .btn { padding-inline: 4px; letter-spacing: .02em; }
}

/* the form folds while the page is off and was never saved */
.pg-form-wrap { min-width: 0; }
.pg-form-sum { display: flex; align-items: center; min-height: 44px; padding: 0 12px; margin-bottom: 10px; color: var(--gold); font-family: var(--display); list-style: none;
  letter-spacing: .04em; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--tile); cursor: pointer; }
.pg-form-sum::-webkit-details-marker { display: none; }
.pg-form-sum::after { content: ''; margin-left: auto; width: 8px; height: 8px; border: solid var(--accent-muted); border-width: 0 2px 2px 0; rotate: 45deg; margin-bottom: 3px; }
.pg-form-wrap[open] > .pg-form-sum::after { rotate: 225deg; margin-bottom: -3px; }
.pg-form-wrap[open] > .pg-form-sum { color: var(--muted); }

/* phones and narrow windows: the preview opens in a dialog from the status box */
.pg-pv-btn { min-height: 44px; }
@media (min-width: 980px) { .pg-pv-btn { display: none; } }
@media (max-width: 979px) { .pg-grid > .pg-preview { display: none; } }
.pg-pv-dlg .pg-page { margin: 8px 0; }
.pg-pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pg-pv-close { min-height: 44px; }
.pg-dirty { color: var(--warn); font-size: 13px; }
.pg-size { margin: 0 0 8px; }

/* preview: a small version of the public page */
.pg-preview { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-detail); }
.pg-preview-head { margin-bottom: 10px; }
.pg-preview-title { margin: 0; color: var(--gold); font-family: var(--display); font-size: 15px; letter-spacing: .06em; }
.pg-page { padding: 14px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.pg-p-head { margin-bottom: 10px; }
.pg-p-name { margin: 0; font-family: var(--display); font-size: 22px; color: var(--gold); }
.pg-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pg-badge { padding: 1px 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; }
.pg-f-alliance { color: var(--text); border-color: var(--alliance); }
.pg-f-horde { color: var(--text); border-color: var(--horde); }
.pg-p-tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.pg-p-facts { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.pg-p-cta { margin: 10px 0; }
.pg-p-ghost { color: var(--gold); background: transparent; border-color: var(--line-strong); }
.pg-p-btn { display: inline-block; padding: 8px 16px; color: var(--button-text); background: linear-gradient(var(--button-top), var(--button-bottom)); border: 1px solid var(--button-border); border-radius: 6px; }
.pg-p-intro { margin: 10px 0; white-space: pre-line; }
.pg-p-sec { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.pg-p-sec h4 { margin: 0 0 6px; color: var(--gold-dim); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.pg-p-sec p { margin: 4px 0; }
.pg-p-status { display: inline-block; padding: 2px 10px; font-size: 13px; font-weight: 600; color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px; }
.pg-r-open { border-color: var(--heal); }
.pg-r-closed { color: var(--muted); }
.pg-p-classes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; padding: 0; list-style: none; }
.pg-p-classes li { padding: 1px 8px 1px 6px; color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--cc); border-radius: 6px; }
.pg-p-events, .pg-dlg-events { margin: 4px 0 0; padding-left: 18px; }
.pg-p-events li, .pg-dlg-events li { margin: 3px 0; }
.pg-p-slots { margin: 0; padding: 0; list-style: none; }
.pg-p-slots li { margin: 3px 0; }
.pg-p-note, .pg-p-contact { white-space: pre-line; }
.pg-p-foot { margin-top: 14px; padding-top: 8px; color: var(--muted); font-size: 12px; text-align: center; border-top: 1px solid var(--line); }

/* confirmation dialog */
.pg-dlg { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px; color: var(--text); background: linear-gradient(180deg, var(--panel), var(--panel2)); border: 1px solid var(--line-strong); border-top: 2px solid var(--accent); border-radius: 10px; box-shadow: var(--e3); }
.pg-dlg::backdrop { background: rgba(5, 10, 20, .72); }
.pg-dlg-title { margin: 0 0 12px; color: var(--gold); font-family: var(--display); font-size: 20px; }
.pg-dlg p { margin: 6px 0; }
.pg-dlg-list { margin: 8px 0; padding-left: 20px; }
.pg-dlg-list li { margin: 3px 0; }
.pg-dlg-actions { justify-content: flex-end; }

/* members: the read-only link */
.pg-member-link { margin: 8px 0; overflow-wrap: anywhere; }
.pg-member-label { color: var(--muted); }
.pg-member-link a { color: var(--gold); }
.pg-member-copy { min-height: 44px; margin-left: 8px; padding: 0 14px; }
.pg-member-msg { margin-left: 8px; color: var(--heal); }

@media (max-width: 600px) {
  .pg { padding: 12px; }
  .pg-sec { padding: 10px 8px; }
  .pg-times { grid-template-columns: minmax(0, 1fr); }
  .pg-actions .btn { flex: 1 1 auto; }
  .pg-day { min-width: 44px; padding: 0 6px; }
  .pg-dlg { inset: auto 0 0 0; width: 100%; max-width: none; margin: 0; border-radius: 16px 16px 0 0; border-bottom: 0; }
}
@media (hover: hover) {
  .pg-switch:hover, .pg-chip:hover { border-color: var(--accent-muted); }
  .pg-form-sum:hover { border-color: var(--accent-muted); background: var(--surface-hover); }
}
.pg-cls:hover, .pg-cls:has(input:checked) { border-left-color: var(--cc); }
@media (prefers-reduced-motion: no-preference) {
  .pg-switch-thumb { transition: transform var(--dur-2) var(--ease), background var(--dur-2); }
  .pg-msg:not(:empty), .pg-msg-near:not(:empty) { animation: view-in var(--dur-3) var(--ease-out); }
  .pg-form-sum::after { transition: rotate var(--dur-2) var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) { .pg-switch-thumb { transition: none; } }
