/* Layout and components. Colors, fonts and corner radius come from the
   theme file (ui/themes/<name>.css), which sets the --gh-* variables. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gh-bg);
  color: var(--gh-text);
  font-family: var(--gh-font-body);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--gh-font-heading); line-height: 1.2; margin: 0 0 0.6em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
a { color: var(--gh-link); }
a:hover { text-decoration-thickness: 2px; }
p { margin: 0 0 0.75em; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }

/* Header */

.site-header { background: var(--gh-header-bg); color: var(--gh-header-text); border-bottom: 3px solid var(--gh-accent); }
.header-row { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none;
  font-family: var(--gh-font-heading); font-weight: 700; font-size: 1.2rem; }
.brand-logo { height: 32px; width: auto; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.main-nav a { color: inherit; text-decoration: none; padding: 6px 12px; border-radius: var(--gh-radius); opacity: 0.85; }
.main-nav a:hover { opacity: 1; background: rgb(255 255 255 / 0.1); }
.main-nav a[aria-current="page"] { opacity: 1; background: rgb(255 255 255 / 0.16); }
.user-menu { position: relative; }
@media (max-width: 700px) {
  .header-row { gap: 4px 12px; padding-top: 8px; }
  .user-menu { margin-left: auto; }
  .main-nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .main-nav a { white-space: nowrap; }
}
.user-menu summary { color: inherit; margin: 0; cursor: pointer; list-style: none; padding: 6px 10px; border-radius: var(--gh-radius); }
.user-menu summary::after { content: " ▾"; }
.user-menu[open] summary { background: rgb(255 255 255 / 0.16); }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 180px;
  background: var(--gh-surface); color: var(--gh-text); border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius); padding: 6px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.15); }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left; padding: 6px 10px;
  color: var(--gh-text); text-decoration: none; border-radius: calc(var(--gh-radius) - 4px); }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--gh-bg); }

.site-footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--gh-muted); font-size: 0.85rem; padding-bottom: 24px; }

/* Layout helpers */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid-main-side { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-main-side > .stack { gap: 20px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.narrow { max-width: 560px; }
section.narrow { margin: 0 auto; }

.card { background: var(--gh-surface); border: 1px solid var(--gh-border); border-radius: var(--gh-radius);
  padding: 20px; overflow-x: auto; }
.card > :last-child { margin-bottom: 0; }

.crumbs { margin-bottom: 4px; font-size: 0.9rem; }
.muted { color: var(--gh-muted); }
.small { font-size: 0.875rem; }
.empty { color: var(--gh-muted); font-style: italic; }
.pre { white-space: pre-wrap; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--gh-border); }
ul.plain li:last-child { border-bottom: 0; }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { background: var(--gh-surface); border: 1px solid var(--gh-border); border-radius: var(--gh-radius);
  padding: 8px 14px; text-transform: capitalize; }
.stat strong { font-family: var(--gh-font-heading); font-size: 1.25rem; margin-right: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: var(--gh-radius); border: 1px solid var(--gh-border);
  background: var(--gh-surface); text-decoration: none; color: var(--gh-text); }
.tabs a[aria-current="page"] { background: var(--gh-primary); border-color: var(--gh-primary); color: var(--gh-primary-text); }

/* Tables */

table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gh-border); vertical-align: middle; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gh-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
tr.overdue td:first-child { color: var(--gh-danger); font-weight: 600; }
.rel-table select { min-width: 130px; }
tr:has(+ tr.notes-row) td { border-bottom: 0; }
tr.notes-row td { padding-top: 0; }

/* Timeline */

.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { border-left: 3px solid var(--gh-accent); padding: 2px 0 12px 14px; margin-left: 4px; }
.timeline-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline p { margin: 4px 0 0; }

/* Badges */

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--gh-badge-bg); color: var(--gh-badge-text); text-transform: capitalize; vertical-align: middle; }
.badge-committed, .badge-active, .badge-done, .badge-write { background: var(--gh-success-bg); color: var(--gh-success-text); }
.badge-declined, .badge-overdue, .badge-disabled { background: var(--gh-danger-bg); color: var(--gh-danger-text); }
.badge-contacted, .badge-planning, .badge-meeting, .badge-call { background: var(--gh-info-bg); color: var(--gh-info-text); }

/* Forms */

form.inline { display: inline; }
form.stack { gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.label { font-weight: 600; font-size: 0.875rem; }
.hint { font-size: 0.8rem; color: var(--gh-muted); }
input:not([type="checkbox"]), select, textarea {
  font: inherit; color: var(--gh-text); background: var(--gh-input-bg);
  border: 1px solid var(--gh-border-strong); border-radius: calc(var(--gh-radius) - 4px);
  padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--gh-focus); outline-offset: 1px;
}
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
fieldset.checks { border: 0; padding: 0; margin: 0; }
fieldset.checks legend { font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; }

button { font: inherit; font-weight: 600; cursor: pointer; border-radius: calc(var(--gh-radius) - 4px);
  padding: 7px 16px; border: 1px solid var(--gh-primary); background: var(--gh-primary); color: var(--gh-primary-text); }
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--gh-text); border-color: var(--gh-border-strong); }
button.secondary:hover { background: var(--gh-bg); filter: none; }
button.link { background: none; border: 0; padding: 0 4px; color: var(--gh-link); font-weight: 400; text-decoration: underline; }

.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input[type="search"] { width: 260px; }

details > summary { cursor: pointer; color: var(--gh-link); margin: 8px 0; }
details[open] > summary { margin-bottom: 12px; }

pre { background: var(--gh-bg); border: 1px solid var(--gh-border); border-radius: calc(var(--gh-radius) - 4px);
  padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: 0.85rem; }
pre.token { font-size: 1rem; font-weight: 600; }

.flash { padding: 10px 14px; border-radius: var(--gh-radius); margin-bottom: 16px; }
.flash-error { background: var(--gh-danger-bg); color: var(--gh-danger-text); }
.flash-notice { background: var(--gh-success-bg); color: var(--gh-success-text); }
