/* ═══════════════════════════════════════════════════════════
   home.css — Home page harmonica sets + their admin editor bits.
   Uses the site's existing tokens (style.css) so light/dark
   theming just works. NAME font: Anton (closest Google font to
   Impact), falling back to Impact itself.
═══════════════════════════════════════════════════════════ */

:root {
  --font-impact: 'Anton', 'Impact', 'Haettenschweiler', 'Arial Narrow Bold', sans-serif;
  --hm-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --hm-dur: 460ms;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
.home-sets { padding: 12px clamp(12px, 4vw, 48px) 48px; }
.home-sets[hidden] { display: none; }
.hm-wrap { max-width: 760px; margin: 0 auto; }

.hm-stack { display: flex; flex-direction: column; gap: 10px; }
.hm-stack:empty { display: none; }
#hmPinned:not(:empty) { margin-bottom: 4px; }

.hm-empty {
  text-align: center; padding: 28px 0;
  font-size: 13px; color: var(--text-faint);
}

/* ─── SECTION DIVIDER ────────────────────────────────────── */
.hm-section {
  display: flex; align-items: center; gap: 16px;
  margin: 34px 0 16px;
  font-family: var(--font-display);
  font-weight: 400; font-style: italic;
  font-size: clamp(20px, 3.4vw, 26px);
  letter-spacing: 0.02em;
  color: var(--text);
}
.hm-section::before, .hm-section::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.hm-section span { max-width: 80%; text-align: center; }

/* ─── FILTER BAR ─────────────────────────────────────────── */
.hm-filters {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  margin: 18px 0 4px; padding: 10px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.hm-filters[hidden] { display: none; }
.hm-filter { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hm-filter span {
  font-size: 10px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint);
}
.hm-filter select {
  font-family: var(--font-body); font-size: 12px; font-weight: 300;
  color: var(--text-mid); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; max-width: 100%;
}
.hm-filter select:focus-visible { outline: 1px solid var(--accent); }

/* ─── THE SET ────────────────────────────────────────────── */
.hm-set {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.hm-set.open { border-color: var(--text-faint); box-shadow: var(--shadow-md); }

/* Part 1 — banner. Corners: X top-left · Z top-right · Y bottom-left · M bottom-right */
.hm-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "x z"
    "n n"
    "y m";
  row-gap: 4px; column-gap: 16px;
  width: 100%;
  padding: 14px 18px 16px;
  text-align: left;
  /* Default header: dark gray. A banner picture, when set, is layered
     behind the text and clipped to this box (see .hm-banner-img). */
  --hm-banner-bg: #2b2b2e;
  --hm-banner-bg-hover: #353539;
  --hm-banner-text: #f3f1ee;
  --hm-banner-text-mid: rgba(243, 241, 238, 0.78);
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--hm-banner-bg); border: 0; color: var(--hm-banner-text); font: inherit;
  cursor: pointer;
  transition: background var(--transition);
}
div.hm-banner { cursor: default; }
button.hm-banner:hover { background: var(--hm-banner-bg-hover); }

/* Banner picture: always spans the banner's full width (cover on a
   full-size box); object-position sets the vertical focal point (per
   character, inline). A soft scrim keeps the text readable on any image. */
.hm-banner-img {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  display: block; pointer-events: none; user-select: none;
}
.hm-banner--img::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.42) 0%, rgba(0,0,0,0.18) 45%, rgba(0,0,0,0.5) 100%);
}
button.hm-banner--img:hover { background: var(--hm-banner-bg); }
button.hm-banner--img:hover::after { background: linear-gradient(180deg, rgba(0,0,0,0.34) 0%, rgba(0,0,0,0.12) 45%, rgba(0,0,0,0.42) 100%); }
button.hm-banner:focus-visible { outline: 1px solid var(--accent); outline-offset: -3px; }

.hm-x, .hm-y, .hm-z, .hm-m {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 400;
  letter-spacing: 0.08em; text-transform: uppercase;
  line-height: 1.45;
  color: var(--hm-banner-text-mid);
  min-width: 0; overflow-wrap: anywhere;
}
.hm-x { grid-area: x; text-align: left; }
.hm-y { grid-area: y; text-align: left; align-self: end; }
.hm-z { grid-area: z; text-align: right; }
.hm-m {
  grid-area: m; text-align: right; align-self: end;
  text-transform: none; letter-spacing: 0.03em; font-size: 11.5px; font-weight: 300;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hm-x:empty, .hm-y:empty, .hm-z:empty, .hm-m:empty { min-height: 0; }

.hm-name-row {
  grid-area: n;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 2px 0 4px;
}
.hm-name {
  font-family: var(--font-impact);
  font-weight: 400;
  font-size: clamp(34px, 9vw, 58px);
  line-height: 1.04;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--hm-banner-text);
  min-width: 0; overflow-wrap: anywhere;
}
.hm-chev {
  flex-shrink: 0; color: var(--hm-banner-text-mid);
  transition: transform var(--hm-dur) var(--hm-ease), color var(--transition);
}
button.hm-banner:hover .hm-chev { color: var(--hm-banner-text); }
.hm-set.open .hm-chev { transform: rotate(180deg); color: var(--hm-banner-text); }

/* Parts 2 + 3 — slide open (grid-rows 0fr → 1fr animates to the content's real height) */
.hm-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--hm-dur) var(--hm-ease);
}
.hm-set.open .hm-panel { grid-template-rows: 1fr; }
.hm-panel-inner {
  min-height: 0; overflow: hidden;
  visibility: hidden;                         /* closed links can't be tabbed to */
  opacity: 0;
  transition: visibility 0s linear var(--hm-dur), opacity calc(var(--hm-dur) * 0.8) var(--hm-ease);
}
.hm-set.open .hm-panel-inner {
  visibility: visible; opacity: 1;
  transition: visibility 0s, opacity calc(var(--hm-dur) * 0.8) var(--hm-ease) 80ms;
}
.hm-panel-inner > :first-child { border-top: 1px solid var(--border-light); }
.hm-panel-inner > * + * { border-top: 1px solid var(--border-light); }

/* Part 2 — socials: icon square + word-wrapped name rectangle, two per row */
.hm-socials {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; padding: 14px 18px;
  background: var(--surface-2);
}
.hm-social {
  display: flex; align-items: stretch; gap: 8px;
  min-width: 0; text-decoration: none; color: inherit;
}
.hm-social-icon {
  flex: 0 0 44px; width: 44px; height: 44px;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-mid);
  transition: border-color var(--transition);
}
.hm-social-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-social-name {
  flex: 1; min-width: 0; min-height: 44px;
  display: flex; align-items: center;
  padding: 6px 12px;
  font-size: 12.5px; font-weight: 400; line-height: 1.35; letter-spacing: 0.02em;
  overflow-wrap: anywhere; word-break: break-word;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color var(--transition), background var(--transition);
}
a.hm-social:hover .hm-social-icon,
a.hm-social:hover .hm-social-name { border-color: var(--text-mid); }
a.hm-social:hover .hm-social-name { background: var(--bg-2); }
a.hm-social:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* Part 3 — info. Portrait: image left, text right (left-aligned).
   Landscape: image on top, text below (centred). */
.hm-info { padding: 18px; background: var(--surface); }
.hm-info-img img { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--bg-2); }
.hm-info-head {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(19px, 3vw, 23px); line-height: 1.2; letter-spacing: 0.01em;
  color: var(--text);
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--text);
  overflow-wrap: anywhere;
}
.hm-info-text {
  font-size: 13.5px; font-weight: 300; line-height: 1.75;
  color: var(--text-mid); white-space: pre-line; overflow-wrap: anywhere;
}

.hm-info--portrait { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 18px; align-items: start; }
.hm-info--portrait .hm-info-body { text-align: left; }
.hm-info--portrait.hm-info--noimg { grid-template-columns: minmax(0, 1fr); }

.hm-info--landscape { display: flex; flex-direction: column; gap: 16px; }
.hm-info--landscape .hm-info-body { text-align: center; }
.hm-info--landscape .hm-info-head { display: inline-block; max-width: 100%; padding-left: 18px; padding-right: 18px; }

@media (max-width: 480px) {
  .hm-banner { padding: 12px 14px 14px; column-gap: 12px; }
  .hm-x, .hm-y, .hm-z { font-size: 10px; letter-spacing: 0.06em; }
  .hm-m { font-size: 10.5px; }
  .hm-socials { padding: 12px 14px; gap: 8px; }
  .hm-social-icon { flex-basis: 40px; width: 40px; height: 40px; }
  .hm-social-name { min-height: 40px; font-size: 12px; padding: 5px 10px; }
  .hm-info { padding: 14px; }
  .hm-info--portrait { gap: 14px; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
  .hm-info-text { font-size: 13px; line-height: 1.65; }
}

@media (prefers-reduced-motion: reduce) {
  .hm-panel, .hm-panel-inner, .hm-chev { transition: none !important; }
}

/* ─── GLOBE-SECTION FACTIONS HARMONICA ───────────────────── */
.globe-factions { margin: 0 clamp(12px, 4vw, 48px) 8px; }
.globe-factions[hidden] { display: none; }
.globe-factions .hm-set { max-width: 760px; margin: 0 auto; }
.hm-banner--simple { display: block; padding: 12px 18px; }
.hm-banner--simple .hm-name { font-size: clamp(26px, 6vw, 40px); }
/* Drawer groups (factions + territories) */
.hm-drawer-group { background: var(--surface-2); }
.hm-drawer-group[hidden] { display: none; }
.hm-drawer-label {
  padding: 14px 18px 0;
  font-size: 10px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint);
}
.hm-drawer-group .globe-index { padding: 4px 18px 16px; }
.hm-drawer-group .hm-factions-grid { padding-top: 10px; }
.hm-factions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px; padding: 14px 18px; background: var(--surface-2);
}
.hm-faction-btn {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 10px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius);
  cursor: pointer; transition: border-color var(--transition);
}
.hm-faction-btn:hover { border-color: var(--text-mid); }
.hm-faction-btn .faction-list-name { overflow-wrap: anywhere; font-size: 13px; }

/* ─── ADMIN: Home editor + character-form extras ─────────── */
.home-admin-section-row, .home-admin-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--border-light); border-radius: var(--radius);
  background: var(--bg-2);
}
.home-admin-row .home-admin-name {
  flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-admin-section-row input.panel-input { flex: 1; min-width: 0; }
.home-admin-row select.panel-input { width: auto; max-width: 42%; padding: 5px 8px; font-size: 12px; }
.home-admin-group-title {
  font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-faint); margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border-light);
}
.home-mini-btn {
  flex-shrink: 0; width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-mid); cursor: pointer; font-size: 13px; line-height: 1;
}
.home-mini-btn:hover:not(:disabled) { border-color: var(--text-mid); color: var(--text); }
.home-mini-btn:disabled { opacity: 0.3; cursor: default; }
.home-mini-btn.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.home-mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.cf-block { border-top: 1px solid var(--border-light); margin-top: 6px; padding-top: 12px; }
.cf-block-title { font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.cf-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.cf-social-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cf-social-icon {
  flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; overflow: hidden;
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--bg-2);
  color: var(--text-faint); cursor: pointer; font-size: 18px; padding: 0;
}
.cf-social-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cf-social-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cf-social-fields .panel-input { padding: 6px 9px; font-size: 12.5px; }
.cf-info-img-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.cf-info-img-thumb {
  width: 56px; height: 56px; flex-shrink: 0; border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-2); overflow: hidden; display: grid; place-items: center; font-size: 10px; color: var(--text-faint);
}
.cf-info-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ─── ADMIN: banner image position picker ────────────────── */
.cf-banner-preview {
  position: relative; width: 100%; aspect-ratio: 4 / 1; margin-top: 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #2b2b2e; overflow: hidden;
  display: grid; place-items: center; font-size: 11px; color: rgba(243,241,238,0.6);
}
.cf-banner-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cf-banner-preview .cf-banner-preview-label { position: relative; z-index: 1; text-shadow: 0 1px 4px rgba(0,0,0,0.7); color: #f3f1ee; font-family: var(--font-impact); font-size: 22px; letter-spacing: 0.03em; text-transform: uppercase; }
.cf-banner-y-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cf-banner-y-row input[type=range] { flex: 1; min-width: 0; }
.cf-banner-y-row .cf-banner-y-val { width: 38px; text-align: right; font-size: 12px; color: var(--text-mid); }
