/* nekoda health journal library. Colours, type and spacing follow the nekoda health design system. */
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/archivo-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* raw palette */
  --canvas: #EBE8DF; --paper: #F5F3EC; --white: #FFFFFF; --ink: #292A24;
  --forest: #33413B; --forest-2: #42544C; --forest-3: #222C27;
  --lime: #CDE77F; --lime-pale: #E7F9B2; --sage: #709176; --taupe: #79745D; --bark: #704F2E;

  /* semantic tokens (light) */
  --surface-page: var(--canvas); --surface-card: var(--paper); --surface-raised: var(--white); --surface-inverse: var(--forest);
  --text-body: var(--ink); --text-heading: var(--ink); --text-muted: var(--taupe); --text-accent: var(--sage); --text-on-action: var(--canvas);
  --text-warn: var(--bark);
  --action-primary: var(--forest); --action-primary-hover: var(--forest-2); --action-primary-active: var(--forest-3);
  --accent: var(--lime); --accent-soft: var(--lime-pale); --focus-ring: var(--sage);
  --text-on-accent: var(--ink); --text-on-inverse: var(--canvas); --control-accent: var(--forest); --line-positive: var(--sage);
  --line: rgba(41, 42, 36, .14); --line-strong: rgba(41, 42, 36, .26); --scrim: rgba(41, 42, 36, .4);
  --shadow-card: 0 1px 2px rgba(41, 42, 36, .06); --shadow-raised: 0 6px 20px rgba(41, 42, 36, .12); --shadow-focus: 0 0 0 3px rgba(112, 145, 118, .55);

  --font-primary: "Hanken Grotesk", system-ui, sans-serif; --font-secondary: "Archivo", system-ui, sans-serif;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-1: 4px; --r-2: 8px; --r-3: 12px; --r-pill: 999px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}
[data-theme="dark"] {
  --surface-page: var(--forest-3); --surface-card: #2A362F; --surface-raised: var(--forest);
  --text-body: var(--canvas); --text-heading: var(--canvas); --text-muted: rgba(235, 232, 223, .7); --text-accent: var(--lime); --text-on-action: var(--ink);
  --action-primary: var(--lime); --action-primary-hover: var(--lime-pale); --action-primary-active: var(--lime);
  --line: rgba(235, 232, 223, .16); --line-strong: rgba(235, 232, 223, .3); --focus-ring: var(--lime);
  --shadow-focus: 0 0 0 3px rgba(205, 231, 127, .5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface-page); color: var(--text-body); font-family: var(--font-primary); font-size: 16px; line-height: 1.55; }
h1, h2, h3 { color: var(--text-heading); font-weight: 600; letter-spacing: -.01em; line-height: 1.22; margin: 0; }
h1 { font-size: 34px; } h2 { font-size: 26px; } h3 { font-size: 20px; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eyebrow { font-family: var(--font-secondary); font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--text-accent); }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--s-5); }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--r-1); }

/* header: inverse forest ground */
.top { background: var(--surface-inverse); color: var(--text-body); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: var(--s-2) var(--s-5); min-height: 72px; flex-wrap: wrap; padding-top: var(--s-2); padding-bottom: var(--s-2); }
.brand { display: flex; align-items: center; gap: var(--s-4); text-decoration: none; margin-right: auto; }
.brand-logo { height: 52px; width: 103px; display: block; }
.nav { display: flex; gap: var(--s-1); }
.nav a { display: inline-flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-2); text-decoration: none; font-size: 14px; font-weight: 500; opacity: .78; transition: opacity 160ms var(--ease); }
.nav a:hover { opacity: 1; }
.nav a[aria-current="page"] { opacity: 1; background: var(--surface-card); }
.count { font-family: var(--font-secondary); font-size: 12px; font-weight: 600; background: var(--accent); color: var(--text-on-accent); border-radius: var(--r-pill); padding: 0 var(--s-2); line-height: 20px; }
.who { display: flex; align-items: center; gap: var(--s-3); font-size: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); font: inherit; font-size: 14px; font-weight: 600; padding: var(--s-2) var(--s-4); min-height: 40px; border-radius: var(--r-2); border: 1px solid transparent; cursor: pointer; text-decoration: none; background: var(--action-primary); color: var(--text-on-action); }
.btn:hover { background: var(--action-primary-hover); }
.btn:active { background: var(--action-primary-active); }
.btn.secondary { background: transparent; color: var(--text-body); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-raised); }
.btn.quiet { background: transparent; color: var(--text-body); min-height: 32px; padding: var(--s-1) var(--s-2); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* sign in */
.signin { max-width: 520px; margin: var(--s-8) auto; background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-7); box-shadow: var(--shadow-card); display: grid; gap: var(--s-4); }

/* search band: paper tint */
.band { background: var(--surface-card); border-bottom: 1px solid var(--line); padding: var(--s-6) 0; }
.band h1 { margin: var(--s-2) 0 var(--s-4); }
.searchrow { display: flex; gap: var(--s-2); }
.field { font: inherit; color: var(--text-body); background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: var(--r-2); padding: var(--s-2) var(--s-3); min-height: 40px; }
.field:focus-visible { border-radius: var(--r-2); }
.searchrow .field { flex: 1; min-width: 0; font-size: 18px; min-height: 48px; }
.searchrow .btn { min-height: 48px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); margin-top: var(--s-3); font-size: 14px; }
.filters label { display: inline-flex; align-items: center; gap: var(--s-2); }
.filters .field { min-height: 32px; padding: var(--s-1) var(--s-2); font-size: 14px; }
.filters input[type="number"] { width: 84px; }
.filters input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--control-accent); }

main.wrap { padding: var(--s-6) var(--s-5) var(--s-8); }
.summary { margin-bottom: var(--s-4); font-size: 14px; }
.list { display: grid; gap: var(--s-3); }
.card { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); box-shadow: var(--shadow-card); display: grid; gap: var(--s-3); }
.card h3 { font-size: 18px; }
.meta { font-size: 14px; color: var(--text-muted); }
.card-head { display: flex; gap: var(--s-4); align-items: flex-start; justify-content: space-between; }
.badge { display: inline-flex; align-items: center; gap: var(--s-1); white-space: nowrap; font-family: var(--font-secondary); font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; padding: var(--s-1) var(--s-3); border-radius: var(--r-pill); border: 1px solid var(--line-strong); color: var(--text-body); }
.badge .icon { width: 14px; height: 14px; }
.badge.library { background: var(--surface-inverse); color: var(--text-on-inverse); border-color: transparent; }
.badge.open { background: var(--accent-soft); border-color: transparent; }
.badge.requested { color: var(--text-warn); }
.badge.record { color: var(--text-muted); }
.abstract { font-size: 14px; white-space: pre-line; }
.abstract.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.note { font-size: 14px; padding: var(--s-3) var(--s-4); border-radius: var(--r-2); background: var(--surface-raised); border: 1px solid var(--line); }
.note.warn { color: var(--text-warn); }
.note.ok { border-color: var(--line-positive); }
.empty { text-align: center; padding: var(--s-7) var(--s-5); color: var(--text-muted); }
.more { display: flex; justify-content: center; margin-top: var(--s-5); }

/* tables (library view) */
.tablewrap { overflow-x: auto; background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--r-3); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { font-family: var(--font-secondary); font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; text-align: left; color: var(--text-muted); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.viewhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.viewhead h2 { margin-top: var(--s-2); }

/* dialog */
dialog { border: 0; padding: 0; border-radius: var(--r-3); background: var(--surface-raised); color: var(--text-body); box-shadow: var(--shadow-raised); width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: var(--scrim); }
.dlg { padding: var(--s-6); display: grid; gap: var(--s-4); }
.dlg .abstract { max-height: 38vh; overflow: auto; padding: var(--s-4); background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--r-2); }
.dlg textarea { width: 100%; min-height: 72px; resize: vertical; }
.dlg label { display: grid; gap: var(--s-1); font-size: 14px; font-weight: 500; }
.dlg .actions { justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%); background: var(--surface-inverse); color: var(--text-on-inverse); padding: var(--s-3) var(--s-5); border-radius: var(--r-2); box-shadow: var(--shadow-raised); font-size: 14px; max-width: calc(100vw - 32px); z-index: 10; }

@media (max-width: 640px) {
  .searchrow { flex-direction: column; }
  .card-head { flex-direction: column-reverse; gap: var(--s-2); }
  .who span { display: none; }
}
