/* ==========================================================================
   Home editor (static/js/home-editor.js): the real Home page in edit mode.
   Modules keep their exact shape. Edit mode fades them, draws a dashed edge
   and adds a drag handle and a gear. The controls live in the sidebar, or in
   a bottom dock below 1280px where the sidebar is a drawer.
   Every colour is a tl token. Pico styles buttons, so every button here
   resets what it relies on.
   ========================================================================== */

.hme-sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- modules in edit mode -------------------------------------------------- */
body.hme-editing .hm-mod { position: relative; border-radius: var(--tl-r-card); outline: 1.5px dashed var(--tl-line-18); outline-offset: 3px; }
body.hme-editing .hm-mod.is-band { border-radius: 0; outline-offset: -2px; }
body.hme-editing .hm-mod > :not(.hme-tools) { opacity: 0.55; pointer-events: none; user-select: none; -webkit-user-select: none; }
body.hme-editing .hm-mod.is-dragging { outline: 2px solid var(--tl-ink); }
body.hme-editing .hm-mod.is-dragging > :not(.hme-tools) { opacity: 0.9; }
/* The sticky News bar would ride over modules while dragging. */
body.hme-editing .hm-news-bar { position: static; }
/* Modules that have nothing to show today still take their place. */
.hm-mod.is-empty { display: none; }
body.hme-editing .hm-mod.is-empty { display: flex; }
.hme-empty { padding: 14px 18px 18px; }
.hme-empty .tl-card-title { margin: 0 0 6px; }
.hme-empty-note { margin: 0; font-size: 13px; color: var(--tl-ink-55); }

.hme-tools {
  position: absolute; z-index: 5; top: -15px; right: 14px;
  display: flex; align-items: center; gap: 2px; padding: 2px;
  border: 1px solid var(--tl-line-10); border-radius: var(--tl-r-btn);
  background: var(--tl-card); box-shadow: var(--tl-card-shadow);
}
.hm-mod.is-band > .hme-tools { top: 50%; right: 28px; transform: translateY(-50%); }
.hme-tool {
  display: inline-grid !important; place-items: center; width: 28px !important; height: 28px; margin: 0 !important; padding: 0 !important;
  border: 0 !important; border-radius: 6px !important; background: transparent !important; box-shadow: none !important;
  color: var(--tl-ink-60) !important; cursor: pointer;
}
.hme-tool:hover { color: var(--tl-ink) !important; background: var(--tl-fill-05) !important; }
.hme-tool:focus-visible { outline: none; box-shadow: var(--tl-focus-ring) !important; }
.hme-grip { cursor: grab; touch-action: none; }
body.hme-dragging, body.hme-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

.hme-ghost {
  position: fixed; z-index: 90; left: 0; top: 0; pointer-events: none;
  padding: 6px 10px; border-radius: 6px; background: var(--tl-ink); color: var(--tl-on-ink);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--tl-card-shadow-hover);
}

/* ---- gear popover ------------------------------------------------------------- */
.hme-pop {
  position: absolute; z-index: 80; width: 250px; padding: 12px;
  border: 1px solid var(--tl-line-10); border-radius: var(--tl-r-card);
  background: var(--tl-card); box-shadow: var(--tl-card-shadow-hover);
}
.hme-pop-title { margin: 0 0 10px; font-size: 13.5px; font-weight: 650; color: var(--tl-ink); }
.hme-pop-label { margin: 0 0 6px; font-family: var(--tl-mono); font-size: 10.5px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--tl-ink-45); }
.hme-pop-note { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--tl-ink-55); }
.hme-widths { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 2px; border-radius: var(--tl-r-chip); background: var(--tl-fill-05); }
.hme-width {
  height: 28px; margin: 0 !important; padding: 0 !important; width: auto !important;
  border: 0 !important; border-radius: var(--tl-r-seg-in) !important; background: transparent !important; box-shadow: none !important;
  font-size: 12.5px; font-weight: 600; color: var(--tl-ink-60) !important; cursor: pointer;
}
.hme-width.is-on { background: var(--tl-control) !important; color: var(--tl-ink) !important; box-shadow: var(--tl-seg-on-shadow) !important; }
.hme-width:disabled { opacity: 0.35; cursor: default; }
.hme-pop > .hme-btn { width: 100%; margin-top: 12px !important; }

/* ---- controls panel ------------------------------------------------------------ */
.hme-panel { display: flex; flex-direction: column; gap: 8px; }
.hme-panel[hidden] { display: none; }
.hme-label { font-family: var(--tl-mono); font-size: 10.5px; letter-spacing: 0.6px; color: var(--tl-ink-40); }
.hme-switch { position: relative; }
.hme-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 32px; margin: 0 !important; padding: 0 12px !important;
  border: 1px solid var(--tl-line-12) !important; border-radius: var(--tl-r-btn) !important;
  background: var(--tl-control) !important; box-shadow: none !important;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--tl-ink) !important; cursor: pointer;
}
.hme-btn:hover:not(:disabled) { background: var(--tl-page) !important; border-color: var(--tl-line-18) !important; }
.hme-btn:disabled { opacity: 0.45; cursor: default; }
.hme-btn:focus-visible { outline: none; box-shadow: var(--tl-focus-ring) !important; }
.hme-btn--solid { background: var(--tl-ink) !important; border-color: transparent !important; color: var(--tl-on-ink) !important; }
.hme-btn--solid:hover:not(:disabled) { background: var(--tl-ink-hover) !important; border-color: transparent !important; }
.hme-btn--danger { border-color: var(--tl-down) !important; color: var(--tl-down) !important; }
.hme-btn--danger:hover:not(:disabled) { background: var(--tl-down) !important; color: #fff !important; }
.hme-select { justify-content: space-between; }
.hme-select::after { content: ''; width: 7px; height: 7px; margin: -3px 2px 0 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); flex: none; }
.hme-select[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: 3px; }
.hme-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hme-status { margin: 0; font-size: 12px; line-height: 1.4; color: var(--tl-down); }

.hme-menu {
  position: absolute; z-index: 70; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 60vh; overflow: auto; padding: 5px;
  border: 1px solid var(--tl-line-08); border-radius: var(--tl-r-card);
  background: var(--tl-card); box-shadow: var(--tl-card-shadow-hover);
}
.hme-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; margin: 0 !important; padding: 6px 9px 6px 26px !important;
  border: 0 !important; border-radius: 6px !important; background: transparent !important; box-shadow: none !important;
  font: inherit; font-size: 13px; font-weight: 550; text-align: left; color: var(--tl-ink) !important; cursor: pointer; position: relative;
  justify-content: flex-start !important;
}
.hme-item:hover, .hme-item:focus-visible { background: var(--tl-fill-05) !important; outline: none; }
.hme-item.is-on::before { content: ''; position: absolute; left: 11px; top: 50%; width: 6px; height: 10px; margin-top: -7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.hme-rule { display: block; height: 1px; margin: 5px 4px; background: var(--tl-line-08); }

/* In the sidebar: under the Home head, above SPORT. */
.tl-side-home .hme-panel { padding: 0 8px; margin: -4px 0 20px; }

/* Below 1280px the sidebar is a drawer: the controls dock to the bottom. */
.hme-panel.is-dock {
  position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 8px;
  padding: 10px; border: 1px solid var(--tl-line-10); border-radius: var(--tl-r-card);
  background: var(--tl-card); box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.16);
}
.hme-panel.is-dock[hidden] { display: none; }
.hme-panel.is-dock .hme-label { display: none; }
.hme-panel.is-dock .hme-menu { top: auto; bottom: calc(100% + 6px); }
.hme-panel.is-dock .hme-status { grid-column: 1 / -1; }
body.hme-editing:has(.hme-panel.is-dock:not([hidden])) .hm-page { padding-bottom: 90px; }
@media (max-width: 560px) {
  .hme-panel.is-dock { grid-template-columns: 1fr 1fr; }
  .hme-panel.is-dock .hme-actions { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .hme-select::after { transition: none; }
}
