/* The hub: a grid of tiles, one per tool, each with its summary (Platform §4). */

.hub {
  flex: 1 1 auto;
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
}

/* What is wrong with the instance (Platform §20.7): above the tiles, a line per
   condition, each opening Réglages at its section. As Réglages' banner (settings.css). */
.hub-alerts {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  background: var(--danger-soft);
}

.hub-alert {
  color: var(--danger);
  font-weight: 600;
}

/* Two columns on a desktop, one on a phone (Platform §4.1). */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  /* Like a card in the lamp's light (FS §12.6), its border traded for the edge ring. */
  background:
    radial-gradient(circle var(--lamp-reach) at var(--lx) var(--ly),
      var(--lamp-card-l0) 0%, var(--lamp-card-l22) 22%, transparent 52%),
    radial-gradient(circle var(--lamp-reach) at var(--lx) var(--ly), transparent 20%, var(--lamp-card-s100) 100%),
    var(--surface);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--lamp-rim) calc((0.3 + 0.7 * var(--ck)) * 100%), transparent),
    0 0 0 1px var(--lamp-edge),
    calc(var(--sx) * 0.8 * var(--lamp-cast)) calc(var(--sy) * 0.8 * var(--lamp-cast))
      calc(var(--sb) * 0.9 * var(--lamp-cast)) -6px var(--lamp-shadow);
  transition: box-shadow var(--transition);
}

.tile:hover {
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--lamp-rim) calc(min(1, 0.5 + 0.8 * var(--ck)) * 100%), transparent),
    0 0 0 1px var(--lamp-edge),
    calc(var(--sx) * 0.9 * var(--lamp-cast)) calc(var(--sy) * 0.9 * var(--lamp-cast))
      calc(var(--sb) * 0.9 * var(--lamp-cast)) -6px var(--lamp-shadow);
}

.tile-title {
  font-size: var(--fs-xl);
  font-weight: 650;
}

.tile-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  text-decoration: none;
}

/* The whole tile opens the tool: the title's link is stretched over it. The task
   lines sit above that layer, so each still opens its own task. */
.tile-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
}

.tile-link:focus-visible { outline: none; }
.tile-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.tile-counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Something to see to is in plain text; a zero stays in the background. */
.tile-count[data-zero="false"] { color: var(--text); font-weight: 650; }

.tile-tasks {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each line is coloured by urgency the way a card is: a left edge, the date in
   figures, the state in words for whoever cannot see the colour (FS §4.2, §15).
   Never as coloured text, whose contrast FS §12.1.1 weighs for cards only. */
.tile-task {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--u-later);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.tile-task:hover { background: var(--surface-3); }

.tile-task[data-urgency="today"]       { border-left-color: var(--u-today); }
.tile-task[data-urgency="second-half"] { border-left-color: var(--u-second-half); }
.tile-task[data-urgency="first-half"]  { border-left-color: var(--u-first-half); }
.tile-task[data-urgency="soon"]        { border-left-color: var(--u-soon); }
.tile-task[data-urgency="later"]       { border-left-color: var(--u-later); }

/* Past due gets the whole frame, as its card does: it should be impossible to
   scan past (FS §4.2). */
.tile-task[data-urgency="overdue"] {
  border-color: var(--u-overdue);
  border-left-width: 3px;
}

.tile-task-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-untitled { color: var(--text-faint); font-style: italic; }

.tile-task-due {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.tile-empty {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------- search (Platform §4.5) */

.hub-search { margin-bottom: var(--sp-4); }

.hub-search-input {
  min-height: 2.75rem;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
}

/* The groups take the tiles' place, in the same grid: two columns on a desktop. */
.hub-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: start;
}

.hub-results[hidden] { display: none; }

.hub-search-offline,
.hub-search-empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.hub-search-heading {
  font-size: var(--fs-lg);
  font-weight: 650;
}

.hub-search-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hub-result {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.hub-result:hover { background: var(--surface-3); }

/* The one Enter opens: the field keeps the focus, so the selection is drawn as one. */
.hub-result[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.hub-result-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* On a result's own surface the accent's soft tint is too faint: a stronger one, and weight. */
.hub-results mark {
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  color: var(--text);
  font-weight: 650;
}

.hub-search-more { align-self: flex-start; }

/* A high-contrast mode keeps no lamp (FS §12.6); the system already drops the shadows. */
@media (forced-colors: active) {
  .tile { background-image: none; }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 767px) {
  .hub { padding: var(--sp-4) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  .hub-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .hub-results { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
}
