/* Web 1.0 aesthetics, web 2.0 optimization — spec grabatool-spec.md §9.3. No
   rounded corners, no shadows, no gradients, no transitions. */

* {
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Helvetica,
    Arial,
    sans-serif;
  font-size: 15px;
  color: #111;
  background: #fff;
  margin: 0;
}

a {
  color: #0645ad;
  text-decoration: underline;
}

a:visited {
  color: #551a8b;
}

header.site {
  padding: 8px 16px;
  border-bottom: 1px solid #999;
  background: #f2f2f2;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header.site .brand {
  font-weight: bold;
  text-decoration: none;
  color: #111;
}

header.site nav a {
  margin-right: 12px;
}

header.site .user {
  margin-left: auto;
  font-size: 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

header.site .user-name {
  font-weight: bold;
}

header.site .user form {
  margin: 0;
}

/* Hamburger toggle (checkbox hack — no JS). Hidden entirely above the
   mobile breakpoint below; visually hidden but still focusable/keyboard-
   operable above it, per the label it controls. */
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-toggle-label {
  display: none;
}

main {
  padding: 16px;
  max-width: 1100px;
}

h1 {
  font-size: 20px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border: 1px solid #999;
  padding: 4px 8px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #eee;
}

tbody tr:nth-child(even) {
  background: #f7f7f7;
}

tbody tr:hover {
  background: #f0f0f0;
}

/* Selectable /library rows: the whole row toggles the checkbox on click
   (public/islands/row-select.js) — cursor:pointer signals that beyond the
   checkbox cell itself, everywhere except the real links/buttons in the row. */
tr.row-selectable {
  cursor: pointer;
}

tr.row-selectable a,
tr.row-selectable button,
tr.row-selectable input {
  cursor: auto;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

input,
select,
textarea,
button {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid #999;
  background: #fff;
}

button {
  background: #f0f0f0;
  cursor: pointer;
}

.field-row {
  position: relative;
  margin-bottom: 10px;
  max-width: 480px;
}

.field-row label {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.field-row input,
.field-row select,
.field-row textarea {
  width: 100%;
}

.error {
  color: #b3261e;
  font-size: 13px;
}

.empty {
  color: #555;
}

.actions {
  margin: 12px 0;
}

/* Grouped sections (currently just the homepage dashboard) — a grey box
   header over a bordered body, the same light-grey-bar-over-white-panel
   pattern Craigslist uses for its category groupings. Panels lay out
   side by side via .dashboard-grid instead of stacking the full page
   width, so wide viewports show more than one column of nearly-empty
   whitespace. */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.panel {
  border: 1px solid #999;
}

.panel > h2 {
  margin: 0;
  padding: 6px 10px;
  background: #eee;
  border-bottom: 1px solid #999;
  font-size: 15px;
}

.panel-body {
  padding: 10px;
}

.panel-body ul {
  margin: 0;
  padding-left: 18px;
}

.panel-body .empty {
  margin: 0;
}

/* Borrower combobox dropdown (spec §9.1) — plain list, matches table borders. */
.combobox-list {
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #999;
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
}

.combobox-list li {
  padding: 4px 6px;
  cursor: pointer;
}

.combobox-list li.active,
.combobox-list li:hover {
  background: #f0f0f0;
}

/* Loan state — a plain coloured word, never a pill or chip (spec §9.3). */
.state-available {
  color: #146c2e;
}

.state-out {
  color: #8a6d00;
}

@media (max-width: 640px) {
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }
  thead {
    display: none;
  }
  /* A bottom-border separator between rows, not a bordered box around each
     one — full-border "cards" plus one-field-per-line stacking below is what
     made the mobile library view read as gigantic; this is a plain compact
     list instead. overflow:hidden clears the floated thumb/checkbox cells
     below so the border sits under them rather than cutting through. */
  tbody tr {
    border-bottom: 1px solid #ccc;
    padding: 6px 2px;
    overflow: hidden;
  }
  td {
    border: none;
    padding: 1px 4px;
    font-size: 13px;
  }
  td[data-label]::before {
    content: attr(data-label) ': ';
    font-weight: bold;
  }
  /* Empty-label cells (checkbox, thumbnail) have nothing worth a "label: "
     prefix — without this, attr() renders a stray ": " with nothing after
     it. Same specificity as the rule above; wins because it comes later. */
  td[data-label='']::before {
    content: none;
  }
  /* Library rows: float the checkbox/thumbnail left so the title sits
     beside them and the rest of the row wraps below — two compact lines
     per item instead of one full-width line per field. */
  .col-select,
  .col-thumb {
    float: left;
    padding: 0 6px 0 0;
  }
  .col-title {
    overflow: hidden; /* clears the float without a guessed fixed margin */
    padding-top: 2px;
    font-weight: bold;
  }
  .col-title a {
    display: inline;
    min-height: auto;
    line-height: 1.3;
    padding: 0;
  }
  .col-thumb a {
    display: block;
    min-height: auto;
    line-height: 1;
    padding: 0;
  }
  td[data-label='Title']::before {
    content: none;
  }
  /* Secondary metadata (not the title, not the state/actions) is de-
     emphasized and packed tighter — it's context, not the point of the row. */
  td[data-label='Owner'],
  td[data-label='Tags'] {
    clear: both;
    color: #555;
    font-size: 12px;
  }
  input,
  select,
  button {
    min-height: 44px;
  }
  /* Checkboxes render at their OS-native (small) size regardless of
     min-height, so they need explicit dimensions to be a real 44px target
     — the surrounding cell already has room since td padding grew above.
     Excludes .nav-toggle, which is deliberately kept invisible-but-focusable
     at every width (see its own rule) — same specificity, and this rule
     comes later in the file, so without the exclusion it would win and
     make the hamburger checkbox visible again on mobile. */
  input[type='checkbox']:not(.nav-toggle) {
    width: 22px;
    height: 22px;
  }
  /* Nav and action links are as tappable as buttons everywhere else on the
     page — same 44px minimum, via padding since a link has no min-height
     effect on its own inline box the way a form control's does. */
  header.site nav a,
  .actions a,
  td a {
    display: inline-block;
    min-height: 44px;
    line-height: 44px;
    padding: 0 4px;
  }
  .combobox-list li {
    min-height: 44px;
    line-height: 44px;
    padding: 0 6px;
  }
  /* Filter rows (search + tag select + button) stack full-width instead of
     cramming into whatever space three inline flex items happen to get on a
     narrow screen — same "stack below 640px" treatment as the table above. */
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filters > * {
    width: 100%;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Hamburger breakpoint — deliberately wider than the 640px touch/table
   breakpoint above. With nine nav links plus the brand and user block, the
   nav's natural width runs to roughly 1000px+ (rough estimate, not measured
   in a real browser — see CLAUDE.md's other notes on that limitation in this
   environment); leaving the hamburger switch at 640px would let the nav wrap
   onto a second header line on ordinary narrow-desktop/tablet widths well
   above phone size, breaking the "chrome is one header line" rule (spec
   §9.3). 1100px matches `main`'s own max-width, so the two breakpoints where
   the layout visibly changes line up instead of being two arbitrary numbers.
   Collapses nav + the user/logout block behind the toggle, leaving only the
   brand and the toggle button on the header's first line; both reappear,
   stacked full-width, once checked. */
@media (max-width: 1100px) {
  .nav-toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    border: 1px solid #999;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }
  .nav-toggle:focus-visible + .nav-toggle-label {
    outline: 2px solid #0645ad;
    outline-offset: 2px;
  }
  header.site nav,
  header.site .user {
    display: none;
    width: 100%;
    margin-left: 0;
  }
  header.site nav {
    flex-direction: column;
  }
  header.site .user {
    align-items: center;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid #ccc;
  }
  .nav-toggle:checked ~ nav,
  .nav-toggle:checked ~ .user {
    display: flex;
  }
}
