/* ===== Home Tab ===== */

/* The full-height inset comes from .tab-panel.is-workspace in shared.css, same as every other
   workspace tab — Home used to re-implement it here with its own .content and height rules. */

/* Logged-out hero (centered, no widgets) */
.home-hero {
  text-align: center;
  padding: 5rem 1rem;
}

.home-hero .hero-logo {
  margin-left: auto;
  margin-right: auto;
}

.home-hero h1 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.home-hero p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Logged-in layout: path bar + widget board, filling the tab's flex column */
.home-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* .hidden wins until login, so the shown state has to restore the flex column it needs */
#tab-home > .home-layout:not(.hidden) { display: flex; }

.home-widget-menu {
  position: relative;
}

.home-add-widget-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow-sm, rgba(0,0,0,0.12));
  z-index: var(--z-widget-menu);
}

.home-add-widget-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
}

.home-add-widget-option:hover {
  background: var(--row-selected);
}

.home-add-widget-option[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* The date the board is about, sitting quietly at the end of the trail rather than claiming a row */
.home-pathbar-day { font-size: 0.78rem; color: var(--text-faint); margin-left: 0.15rem; }

/* The day's figures, above the board rather than inside any one widget */
.home-status-strip { flex: none; margin-top: 0.15rem; }
/* the strip only exists once a widget has reported a figure, so it starts hidden rather than empty */
.home-status-strip:not(.hidden) { display: flex; }

/* The board — one hero beside a rail of three. HERO_SLOT/SLOT_COUNT in widgets.js must match this. */
.home-widget-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 0.85rem;
  padding: 0.85rem 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* nothing in the hero (it was dismissed, or dragged away) means the rail takes the whole board */
.home-widget-grid.hero-empty { grid-template-columns: minmax(0, 1fr); }
.home-widget-grid.hero-empty .home-widget-slot--hero { display: none; }

/* The rail stacks its three, each taking what its own content needs and sharing the rest */
.home-widget-rail {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  min-height: 0;
}

/* An empty rail slot still carries .covered, so it folds away and reappears as a drop target mid-drag */

/* Widgets are authored here and moved into a slot on mount, so the count of each can differ */
.home-widget-pool { display: none; }

@media (max-width: 900px) {
  /* one column, and the board scrolls rather than squeezing four widgets into the viewport */
  .home-widget-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: 16rem;
    overflow-y: auto;
  }
  /* the rail stops being a rail — its three join the one column at the same height as the hero */
  .home-widget-rail { display: contents; }
  .home-widget-slot { grid-row: auto !important; grid-column: auto !important; }
  /* the strip's figures wrap onto a second line rather than squeezing to nothing */
  .home-status-strip { flex-wrap: wrap; }
  .home-status-strip > div:first-child { padding-left: 1.1rem; }
}

/* Bulletin board — a widget now, so the panel frame and its own header are gone; what's left is
   the compose box and the post list, which the widget body and foot hold. */

.home-bulletin-compose {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.home-bulletin-textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 0.5rem 0.6rem;
}

.home-bulletin-post-btn {
  align-self: flex-end;
  font-size: 0.76rem;
  padding: 0.38rem 0.8rem;
}

.home-bulletin-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}


.home-bulletin-post {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 2.2rem 0.55rem 0.65rem; /* right padding reserves room for .home-bulletin-post-actions */
  background: var(--surface);
}

.home-bulletin-post-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.home-bulletin-post-author {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
}

.home-bulletin-post-date {
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.home-bulletin-post-body {
  font-size: 0.78rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.home-bulletin-post-actions {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.home-bulletin-post-edit,
.home-bulletin-post-delete {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1rem;
  line-height: 0;
}

.home-bulletin-post-edit:hover {
  color: var(--primary);
}

.home-bulletin-post-delete:hover {
  color: var(--danger);
}

.home-bulletin-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

/* Release notes — a widget now; the entries stack in its body with no panel of their own */
.home-widget-body > .home-changelog-entry + .home-changelog-entry { margin-top: 0.9rem; }

.home-changelog-entry {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.home-changelog-version {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.home-changelog-date {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.home-changelog-category {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.35rem;
  margin-bottom: 0.1rem;
  color: var(--text-muted);
}

.home-changelog-added::before   { content: '+ '; }
.home-changelog-changed::before { content: '~ '; }
.home-changelog-fixed::before   { content: '✓ '; }
.home-changelog-removed::before { content: '− '; }

.home-changelog-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.home-changelog-list li {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.changelog-tab-icon {
  display: inline-flex;
  vertical-align: -2px;
  width: 13px;
  height: 13px;
  margin-right: 0.2rem;
  color: var(--text-muted);
}

.changelog-tab-icon + .changelog-tab-icon {
  margin-left: -0.05rem;
}

.home-widget-slot {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.home-widget-slot.covered {
  display: none;
}

.home-widget-slot.covered.drag-available {
  display: block;
  border-style: dashed;
  border-color: var(--border);
  background: color-mix(in srgb, var(--border) 8%, transparent);
}

.home-widget-slot.drag-over {
  border-style: dashed;
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

/* Widget wrapper — fills its slot */
.home-widget-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.home-widget-drag-handle {
  position: absolute;
  top: 0.4rem;
  left: 0.55rem;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.45;
  font-size: 0.72rem;
  line-height: 1;
  z-index: var(--z-raise-1);
}

.home-widget-drag-handle:hover { opacity: 1; }
.home-widget-wrapper:active .home-widget-drag-handle { cursor: grabbing; }

.home-widget-remove-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.45rem;
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.55;
  z-index: var(--z-raise-1);
}

.home-widget-remove-btn:hover {
  opacity: 1;
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}

/* the 2rem sides leave room for the drag handle and the remove button pinned in the corners */
.home-widgets-header {
  padding: 0.45rem 2rem 0.4rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
}

/* The body scrolls; header and foot stay put, so a widget never grows past its slot */
.home-widget-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.35rem 0.7rem 0.5rem;
}

/* A pinned row under the body — the task widget's quick-add, the bulletin's compose box */
.home-widget-foot {
  flex-shrink: 0;
  padding: 0.45rem 0.7rem 0.55rem;
  border-top: 1px solid var(--border-light);
}

/* Nothing-to-show line, centred in whatever body it lands in */
.home-widget-clear {
  display: grid;
  place-items: center;
  min-height: 100%;
  color: var(--text-faint);
  font-size: 0.8rem;
  text-align: center;
}

/* A count in the subtitle that wants reading before the words around it */
.home-widget-alert { color: var(--danger); font-weight: 600; }

.home-widget-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.home-widget-title svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--primary);
  opacity: 0.85;
}

.home-widget-title-sep {
  margin: 0 0.28rem;
}

/* A control the widget puts in its own title row, ranged to the far end */
.home-widget-head-select {
  margin-left: auto;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0;
  max-width: 8rem;
}

.home-widget-dot {
  margin: 0 0.38rem;
}

.home-widget-subtitle {
  margin-top: 0.2rem;
  font-size: 0.74rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-widget-subtitle .dashboard-stats-label {
  font-size: 0.68rem;
}

.home-widget-shift {
  font-weight: 700;
}

.home-widget-shift-sep {
  margin: 0 0.6rem;
  opacity: 0.35;
}

.home-widget-metric {
  display: inline-flex;
  align-items: center;
}

/* Compact machine cards inside the home widget — .home-widget-body is the scroller now, so this
   sets neither padding nor overflow of its own */
/* Machines read as a list of lines, not a grid of cards — the rail has no room for two abreast,
   and one line each is what makes nine machines legible at a glance. Expanding one swaps in the
   full dashboard card in its place. */
#home-widget-cards.mw-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.home-quality-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.45rem 0.5rem;
  overflow-y: auto;
  min-height: 0;
}


/* A ticket is a row, not an inset card — a rail of bordered boxes inside a bordered widget reads as clutter */
.home-quality-item {
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
  min-width: 0;
}

.home-quality-item:hover {
  background: var(--row-hover);
}

.home-quality-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.home-quality-machine {
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the kind reads as a tag now that the row has no card edge to sit against */
.home-quality-stage {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-deep);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  flex-shrink: 0;
}

.home-quality-reason,
.home-quality-meta {
  margin-top: 0.2rem;
  font-size: 0.73rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One machine's line — the expand button only appears under the cursor, so nine rows stay quiet */
#home-widget-cards .mw-row-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.3rem;
  border-radius: 6px;
  min-width: 0;
}

#home-widget-cards .mw-row-item:hover { background: var(--row-hover); }

/* the dot carries the session type's own colour, the same one its chart bar carries */
#home-widget-cards .mw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

#home-widget-cards .mw-row-name {
  font-size: 0.78rem;
  color: var(--text);
  width: 5.2rem;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the bar takes whatever the name and the figure leave, so the column of figures still lines up */
#home-widget-cards .mw-row-item .stat-track { flex: 1 1 auto; height: 0.4rem; min-width: 1.5rem; }

#home-widget-cards .mw-row-util {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  width: 3rem;
  text-align: right;
  flex-shrink: 0;
}

#home-widget-cards .mw-expand-btn { opacity: 0; }
#home-widget-cards .mw-row-item:hover .mw-expand-btn { opacity: 1; }

#home-widget-cards .mw-expand-btn {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  flex-shrink: 0;
}

#home-widget-cards .mw-expand-btn svg {
  width: 0.58rem;
  height: 0.58rem;
}

#home-widget-cards .mw-expand-btn-corner {
  margin-left: auto;
}

#home-widget-cards .mw-dashboard-card {
  box-shadow: none;
}

#home-widget-cards .mw-empty {
  padding: 0.85rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* the old narrow-screen block hid the widget strip and stacked the two side panels — with every
   panel a widget, the single-column board above covers it and those rules matched nothing */
