/* logsurf on Designsystemet (vendor/ds). Unlayered, so it wins over both the app's style.css
   (layer "app", see app.css) and Designsystemet (layer "ds"). It maps the app's colour tokens onto
   Designsystemet's, fits the components into the app's layout, and lays out the topic threads
   (views.js, topics.js) and the week table. */

/* ---- The app's tokens, from Designsystemet's theme (follows data-color-scheme) ---- */
:root, [data-color-scheme] {
  --bg: var(--ds-color-neutral-background-default);
  --fg: var(--ds-color-neutral-text-default);
  --dim: var(--ds-color-neutral-text-subtle);
  --line: var(--ds-color-neutral-border-subtle);
  --accent: var(--ds-color-accent-text-subtle);
  --accent-bg: var(--ds-color-accent-surface-tinted);
  --bullet: var(--ds-color-neutral-border-default);
  --code-bg: var(--ds-color-neutral-surface-tinted);
  --mark: var(--ds-color-warning-surface-active);
  --danger: var(--ds-color-danger-text-subtle);
  --editor-bg: var(--ds-color-neutral-surface-default);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body { font-size: 1rem; }
a { color: var(--ds-color-accent-text-subtle); }
a:hover { text-decoration: none; }

/* ---- Header: tabs for the views, a Designsystemet search field ---- */
header { padding-block: 0; min-height: 3.4rem; align-items: stretch; gap: 1.2rem; }
header > * { align-self: center; }
header nav.ds-tabs { align-self: stretch; display: flex; }
header .ds-tabs [role="tablist"] { border-bottom: 0; align-items: stretch; }
header .ds-tabs [role="tab"] { text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
.search { gap: 0.25rem; }
.search .ds-search { flex: 1; min-width: 0; }
.search .ds-input { width: 100%; }
#search-all svg, #read-only svg, .ds-button svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#read-only[aria-pressed="true"] { background: var(--ds-color-accent-surface-tinted); color: var(--ds-color-accent-text-default); }
@media (max-width: 640px) {
  header { padding-block: 0.4rem; gap: 0.3rem 0.6rem; }
  header nav.ds-tabs { order: 4; flex-basis: 100%; }
  .search { order: 5; }
  header .ds-tabs [role="tab"] { padding: 0.4rem 0.7rem; }
}

/* ---- Blocks: Designsystemet links, tags and checkboxes inside the outline ---- */
.page-ref::before, .page-ref::after { content: none; }
.content .ds-link { text-decoration-thickness: 0.06em; text-underline-offset: 0.2em; }
/* Compact versions of the tag and checkbox, so a task line is as tall as any other line. */
.marker.ds-tag, .priority.ds-tag {
  --dsc-tag-min-height: 0; --dsc-tag-padding: 0.05em 0.4em;
  margin-right: 0.4em; vertical-align: 0.1em;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; line-height: 1.35;
}
.task-cb.ds-input { --dsc-input-size: 1.05em; width: 1.05em; height: 1.05em; min-height: 0; margin: 0 0.45em 0 0; vertical-align: -0.15em; }
.task-done > .row > .content .text, .task-canceled > .row > .content .text { text-decoration: none; }
.task-done > .row > .content .text { color: var(--dim); }
.planning { margin-top: 0.1em; }

/* ---- Day headings ---- */
.day-title { display: flex; align-items: baseline; gap: 0.5rem; margin: 0 0 0.9rem; }
.day-title a { color: var(--fg); text-decoration: none; }
.day-title .weekday { margin: 0; font-weight: 400; color: var(--dim); }
.earlier-days { margin: 3rem 0 1rem; color: var(--dim); }
.page-header { align-items: center; flex-wrap: wrap; gap: 0.4rem 0.6rem; margin: 0.5rem 0 1rem; }
.page-header h1 { margin: 0 0.4rem 0 0; display: flex; align-items: baseline; gap: 0.5rem; }
.page-header .weekday { font-weight: 400; color: var(--dim); }
.section-heading { margin: 2.5rem 0 0.8rem; color: var(--dim); }

/* ---- Suggested topics ---- */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0 0 1.1rem; }
.suggest-label { color: var(--dim); font-size: 0.9rem; margin-right: 0.2rem; }
.suggest-chip.ds-chip::before { content: "+"; font-weight: 600; margin-right: 0.15em; }
.suggest-chip .ago { opacity: 0.75; font-size: 0.85em; margin-left: 0.25em; }

/* ---- A page's topic thread: a card with every day's notes under the topic ---- */
.thread.ds-card { --dsc-card-padding: 0.55rem 1rem; margin: 0 0 1rem; }

.thread-body { padding-left: 0 !important; }
.thread-body > * + * { margin-block: 0 !important; }
/* Each day in a small gutter. */
.history-day { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); }
.history-day[hidden] { display: none; }
.history-date { padding: 0.2rem 0 0 1rem; font-size: 0.8rem; color: var(--dim); white-space: nowrap; text-decoration: none; font-variant-numeric: tabular-nums; }
.history-day + .history-day { border-top: 1px solid var(--line); padding-top: 0.4rem; margin-top: 0.4rem; }
.thread-today { margin-left: 4.6rem !important; }

/* "Add a note" at the end of a thread (an empty placeholder block, as in the app). */
.add-note .empty::before { content: "Add a note…"; }
.add-note .content { color: var(--dim); }
.add-note:not(:hover) .bullet::before { opacity: 0.35; }

/* ---- Agenda: a tinted card with a details ---- */
.agenda-card { margin: 0 0 2rem; }
.agenda-card summary .ds-tag { margin-left: 0.4rem; }
.agenda-card .section-title { margin: 1rem 0 0.4rem; color: var(--fg); }
.agenda-card .agenda-overdue > .section-title { color: var(--danger); }
.agenda-card .ref-group { background: var(--editor-bg); }
.agenda-card .all-tasks { margin: 0.8rem 0 0; }
.agenda-panel { background: var(--ds-color-accent-surface-tinted); border-left-color: var(--ds-color-accent-base-default); }

/* ---- Week matrix ---- */
body[data-view="week"] main { max-width: 96rem; }
.week-controls { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1rem; color: var(--dim); }
.week-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--ds-border-radius-lg); }
table.week { width: 100%; }
table.week th, table.week td { vertical-align: top; border-left: 1px solid var(--line); }
table.week tr > :first-child { border-left: 0; }
table.week thead th { white-space: nowrap; }
table.week thead th a { color: var(--fg); text-decoration: none; }
table.week thead th span { margin-left: 0.3em; color: var(--dim); font-weight: 400; }
table.week th.topic { position: sticky; left: 0; z-index: 1; min-width: 9rem; background: var(--ds-color-neutral-surface-default); }
table.week th.topic .count { display: block; font-weight: 400; font-size: 0.78rem; color: var(--dim); }
table.week td { min-width: 11rem; font-size: 0.9rem; }
table.week .quiet { min-width: 0; width: 2.4rem; color: var(--dim); }
table.week thead th.quiet { font-weight: 400; }
table.week thead th.quiet span { display: block; margin: 0; }
table.week .is-today { background: var(--ds-color-accent-surface-tinted); }
table.week ul { list-style: none; margin: 0; padding: 0; }
table.week li { padding: 0.15rem 0; line-height: 1.4; }
table.week li + li { border-top: 1px dotted var(--line); }
table.week li .marker { margin-right: 0.35em; }
table.week li.task-done { color: var(--dim); }
table.week li .more { margin-left: 0.35em; font-size: 0.75rem; color: var(--dim); }

/* ---- All pages, tasks, login, dialogs ---- */
.pages-search { margin: 0 0 0.9rem; }
.pages-controls .pages-search { flex: 1 1 14rem; margin: 0; }
.tag-bar[hidden] { display: none; }
.tag-chip .count { margin-left: 0.35em; opacity: 0.7; }
.ds-tag.badge { margin-left: 0.5em; vertical-align: middle; font-weight: 400; }
button.ds-tag.tag-chip { cursor: pointer; margin: 0.1rem 0.25rem 0.1rem 0; border: 0; }
.ds-chip[data-removable] { text-decoration: none; }
.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; border: 0; padding: 0; margin: 0 0 0.9rem; }
.tag-bar legend { float: left; margin-right: 0.4rem; color: var(--dim); }
.show-archived { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.pages-table { width: 100%; }
.pages-table .num { text-align: right; }
.login.ds-card { max-width: 24rem; margin: 10vh auto; display: flex; flex-direction: column; gap: 1rem; }
.login.ds-card > * + * { margin-block: 0; }
.login .ds-button { align-self: flex-start; }
.login [hidden] { display: none; }
dialog.ds-dialog .buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; margin-top: 1.2rem; }
dialog.ds-dialog textarea { width: 100%; margin-top: 1rem; font-family: var(--mono); font-size: 0.85rem; }
/* Layout that must beat Designsystemet's dialog (layer ds outranks style.css in layer app):
   the daily prompt stays narrow, and the upload sheet keeps its own padding and docks to the
   bottom of the screen on phones. */
#daily.ds-dialog { --dsc-dialog-max-width: 26rem; }
dialog.sheet.ds-dialog { padding: 0; }

@media (max-width: 640px) {
  .history-day { grid-template-columns: 3.4rem minmax(0, 1fr); }
  .history-date { padding-left: 0.5rem; }
  .thread-today { margin-left: 3.4rem !important; }
  dialog.sheet.ds-dialog { margin: auto 0 0; width: 100%; max-width: none; border-radius: 14px 14px 0 0; border-bottom: 0; }
}
