/* Home (templates/home.html) — page-specific layout; the action rows are the
   shared .doc-action* styles in styles.css.
   The amount of UI follows the amount of information: an empty attention or
   upcoming list is one line, a populated one takes the room it needs. One
   frame per list, hairlines between rows, no cards inside cards. */

/* Wider than the generic workspace column (1160): Home is a hub, and the shell
   left it a wide empty gutter on large monitors. Still capped, so a 1920px
   screen reads as a page and not as a stretched table. */
.home { max-width: 1320px; }
/* The 68px top band exists for the floating language pill, which is hidden
   whenever the rail is present (see .lang-fab in styles.css). */
body:has(#app-sidebar) .home.workspace-shell { padding-top: var(--space-8); }

/* ── Header: title · search (primary) · add ── */
.home-header {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-6);
}
.home-header h1 { margin: 0; font-size: var(--text-4xl); }
.home-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
  max-width: 560px;
  margin: 0 0 0 auto;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: var(--text-md);
  text-align: left;
  cursor: pointer;
}
.home-search:hover { background: var(--surface-soft); border-color: var(--accent-border); transform: none; }
.home-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.home-search svg { flex: 0 0 auto; }
.home-search-long, .home-search-short {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-search-short { display: none; }
.home-search kbd {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px var(--space-1);
}
.home-add {
  flex: 0 0 auto;
  margin: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}
.home-reading { margin: 0 0 var(--space-4); color: var(--ink-soft); font-size: var(--text-sm); }

/* ── Needs review: a check DocSolved asks of the owner, shown with the library
   it describes. Warm and bar-shaped, deliberately unlike the accent-railed
   "needs your attention" above, which is about what a DOCUMENT asks of them.
   One line on a wide column; text over button on a narrow one. ── */
.home-review {
  display: flex;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-warm);
  border-radius: var(--radius);
  background: var(--warn-soft);
}
.home-review[hidden] { display: none; }
.home-review-icon { flex: 0 0 auto; color: var(--warn-text); }
.home-review-text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink);
}
.home-review-title { font-weight: 600; margin-right: var(--space-1); }
.home-review-sub { color: var(--ink-soft); }
/* A compact button: the strip is a status line, not a second hero. */
.home-review-link {
  flex: 0 0 auto;
  margin: 0;
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
}
.home-review + .home-list { margin-top: var(--space-2); }

/* ── Summary: attention / upcoming / their one-line stand-ins ── */
/* A column with gap, not sibling margins: hidden halves take no space and no
   gap, so a lone quiet line never glues itself to the block above it. */
.home-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.home-summary [hidden] { display: none; }
.home-section-title {
  margin: 0;
  font-size: var(--text-xl);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.home-section-sub { font-size: var(--text-xs); font-weight: 500; color: var(--ink-soft); }
.home-count {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent-text);
}

.home-quiet {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  font-size: var(--text-md);
  color: var(--ink-soft);
}
.home-quiet-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.home-quiet-item svg { flex: 0 0 auto; }
#home-attention-empty svg { color: var(--success); }

/* Populated attention outranks everything below it: accent rail, larger
   titles, the deadline as the loudest value in the row. */
.home-attention {
  padding: var(--space-4) var(--space-5) var(--space-2);
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.home-attention .doc-actions-list { margin-top: var(--space-2); }
.home-attention .doc-action { padding: var(--space-4) 0; }
.home-attention .doc-action-title { font-size: var(--text-lg); }
.home-attention .doc-action-due { font-size: var(--text-md); }
.home-attention .doc-action-date { font-weight: 600; }
.home-attention .doc-action-when.is-overdue,
.home-attention .doc-action-when.is-soon { font-weight: 600; }

/* Wide Home with both halves populated: the attention list keeps the main
   column and "Coming up" becomes its companion column — the same column grid
   as Recently added / Shared recently below, so the page reads as two aligned
   columns instead of four stacked bands, and the library is not pushed off the
   first screen by a list of later dates. One populated half (or none) stays
   stacked: a side column holding one quiet line would be dead space. */
.home-upcoming { container: upcoming / inline-size; }
@container home (min-width: 960px) {
  #home-content[data-attention="1"][data-upcoming="1"] .home-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: var(--space-6) var(--space-8);
    align-items: start;
  }
  #home-content[data-attention="1"][data-upcoming="1"] .home-upcoming { padding-top: var(--space-4); }
}
/* In a narrow column the rows stack the way they do on a phone: words first,
   decisions under them. */
@container upcoming (max-width: 520px) {
  .home-upcoming .doc-action { flex-direction: column; gap: var(--space-2); }
  .home-upcoming .doc-action-buttons { justify-content: flex-start; }
}

/* Upcoming is context, not a task: no frame, quieter type, quotes kept (they
   are the explanation) but held to two lines. */
.home-upcoming .doc-actions-list { margin-top: var(--space-1); border-top: 1px solid var(--border); }
.home-upcoming .doc-action { padding: var(--space-3) 0; }
.home-upcoming .doc-action-title { font-size: var(--text-base); }
.home-upcoming .doc-action-evidence {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Library + shares ── */
/* The library leads; shares are its narrower companion. Laid out by the width
   Home actually has (a container query), not by the viewport: the rail comes
   and goes at 900px, so the same viewport can mean two very different columns. */
#home-content { container: home / inline-size; }
.home-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6) var(--space-8);
  align-items: start;
}
@container home (min-width: 860px) {
  .home-columns { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
}
.home-library, .home-shares { min-width: 0; }
.home-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.home-more { font-size: var(--text-sm); color: var(--accent-text); white-space: nowrap; }
/* On touch, the words stay small but the target does not: 44px of hit area
   without moving the heading row. */
@media (pointer: coarse) {
  .home-more { display: inline-flex; align-items: center; min-height: 44px; margin-block: -14px; }
}
.home-more[hidden] { display: none; }
.home-library .home-list,
.home-shares .home-list {
  margin-top: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.home-shares .home-section-title { margin-bottom: 0; }
.home-list { list-style: none; margin: 0; padding: 0; }
.home-list[hidden] { display: none; }
.home-empty {
  margin: var(--space-3) 0 0;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  max-width: 60ch;
}
.home-empty[hidden] { display: none; }
.home-empty a { color: var(--accent-text); font-weight: 600; }
.home-empty-link { white-space: nowrap; }
/* No documents yet: the library keeps its frame so the page still has a body. */
.home-library .home-empty {
  margin-top: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  max-width: none;
}
.home-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-light);
}
.home-row:first-child { border-top: 0; }
.home-row:hover { background: var(--surface-soft); }
.home-row:has(.home-row-main:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.home-row-main {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.home-row-main:focus-visible { outline: none; }
/* The whole row is the target, not just the words. */
.home-row-main::after { content: ""; position: absolute; inset: 0; }
.home-row-title {
  display: block;
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-row:hover .home-row-title { color: var(--accent-text); }
.home-row-meta {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* A narrow library (phones): the status drops under the title and date, so a
   long document name keeps the whole row instead of sharing it with
   "Wymaga sprawdzenia" or "Prüfung nötig". */
.home-library { container: library / inline-size; }
@container library (max-width: 480px) {
  .home-row { flex-wrap: wrap; row-gap: var(--space-1); }
  .home-row-main { flex-basis: 100%; }
}

/* Trust state: a dot and a word, quiet when all is well, legible when not. */
.home-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-soft);
  white-space: nowrap;
}
.home-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.home-status.is-ready::before { background: var(--success); }
.home-status.is-review_required { color: var(--warn-text); font-weight: 600; }
.home-status.is-failed { color: var(--danger-text); font-weight: 600; }

/* Narrow content: the short label fits whole where the long one would clip. */
@media (max-width: 1180px) {
  .home-search-long { display: none; }
  .home-search-short { display: block; }
}
@container home (max-width: 859.98px) {
  .home-shares .home-list { max-width: 640px; }
}

@media (max-width: 640px) {
  /* Row 1: title + add. Row 2: full-width search. */
  .home-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .home-header h1 { font-size: var(--text-3xl); }
  .home-search { grid-column: 1 / -1; grid-row: 2; max-width: none; margin: 0; }
  .home-search-long, .home-search kbd { display: none; }
  .home-search-short { display: block; }
  /* Icon + words on top, the button under them at full width. */
  .home-review { flex-wrap: wrap; align-items: flex-start; padding: var(--space-3); }
  .home-review-icon { margin-top: 2px; }
  .home-review-text { flex-basis: calc(100% - 28px); }
  .home-review-title { display: block; margin: 0 0 2px; }
  .home-review-link { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  .home-attention { padding: var(--space-3) var(--space-4) var(--space-1); }
  /* Three actions (Add to calendar · Mark done · Undo) fit two rows, not three. */
  .home-summary .doc-action-buttons { gap: var(--space-1) var(--space-2); }
  .home-summary .doc-action-buttons .tiny-btn { min-height: 40px; padding-inline: var(--space-3); }
  .home-row { padding: var(--space-3); gap: var(--space-3); }
  /* Keep more of a long name on a phone: two lines before the ellipsis. */
  .home-row-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
/* A touch screen has no Ctrl+K. */
@media (pointer: coarse) { .home-search kbd { display: none; } }
