/* ==========================================================================
   BootApp styles: public site, account page and admin.
   Colours are tokens below; dark mode redefines them.
   ========================================================================== */

:root {
  --bg: #f7f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5d6270;
  --border: #e2e4ea;
  --link: #c2410c;
  --button: #c2410c;
  --button-hover: #9a3412;
  --button-text: #ffffff;
  --accent-soft: #fff1e8;
  --error: #b42318;
  --good: #067647;
  --info-bg: #eaf1ff;
  --info-text: #1e3a8a;
  --warning-bg: #fff4d6;
  --warning-text: #7a4a00;
  --code-bg: #f1f2f5;
  --hero-glow: rgb(249 115 22 / 0.16);
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 4px 16px rgb(16 24 40 / 0.06);
  --chart-bar: #d9650b;
  --chart-hover: rgb(0 0 0 / 0.05);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --card: #171a21;
    --text: #e9ebf0;
    --muted: #a3a9b6;
    --border: #2a2f3a;
    --link: #fdba74;
    --button: #fb923c;
    --button-hover: #fdba74;
    --button-text: #1c0d02;
    --accent-soft: #2a1a0e;
    --error: #f39b93;
    --good: #6ee7b7;
    --info-bg: #15233f;
    --info-text: #bfd3ff;
    --warning-bg: #33260a;
    --warning-text: #fcd78a;
    --code-bg: #20242d;
    --hero-glow: rgb(249 115 22 / 0.14);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
    --chart-bar: #e06d14;
    --chart-hover: rgb(255 255 255 / 0.06);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

/* Inter (variable, Latin), served from this site. Licence: /fonts/Inter-LICENSE.txt */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

/* Elements with the hidden attribute stay hidden even if a rule below sets display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 32px 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
code {
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 5px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.meta { color: var(--muted); font-size: 0.85rem; }
.hint { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.error { color: var(--error); min-height: 1.5em; margin: 12px 0 0; }
.status { color: var(--error); min-height: 1.5em; margin: 0; font-size: 0.9rem; }
.status.ok { color: var(--good); }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus { left: 16px; top: 8px; z-index: 20; background: var(--card); padding: 8px 12px; border-radius: 8px; }

:focus-visible { outline: 2px solid var(--button); outline-offset: 2px; }

/* ---------- Buttons and forms ---------- */

button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--button-text);
  background: var(--button);
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
button:hover,
a.button:hover { background: var(--button-hover); }
button:disabled { opacity: 0.6; cursor: wait; }

button.secondary,
a.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.secondary:hover,
a.button.ghost:hover { border-color: var(--muted); background: transparent; }

button.small,
a.button.small { padding: 6px 12px; font-size: 0.85rem; }

button.link {
  justify-self: start;
  padding: 0;
  font-weight: 500;
  color: var(--link);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.link:hover { background: none; color: var(--text); }

button.danger { background: var(--error); color: #fff; }
button.small.danger { background: transparent; color: var(--error); border-color: var(--error); }

form { display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); font-weight: 500; }

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
}
textarea { resize: vertical; }
textarea.mono { font: 0.9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus,
textarea:focus,
select:focus { outline: 2px solid var(--button); outline-offset: 0; border-color: transparent; }

label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.checkbox input { width: auto; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.badge.warn { color: var(--error); border-color: var(--error); }
.badge.good { color: var(--good); border-color: var(--good); }

/* ---------- Public site layout ---------- */

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

body.site { display: flex; flex-direction: column; min-height: 100vh; }
body.site main { flex: 1; padding-top: 32px; padding-bottom: 64px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo { width: 30px; height: 30px; flex: none; }
.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: end; }
.site-nav a:not(.button) { color: var(--muted); text-decoration: none; font-weight: 500; }
.site-nav a:not(.button):hover,
.site-nav a[aria-current="page"]:not(.button) { color: var(--text); }

.notice { padding: 10px 0; font-size: 0.92rem; }
.notice-info { background: var(--info-bg); color: var(--info-text); }
.notice-warning { background: var(--warning-bg); color: var(--warning-text); }
.notice-inline {
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.92rem;
}
.notice-inline a { color: inherit; font-weight: 600; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 20px; padding-top: 32px; padding-bottom: 32px; }
.footer-inner nav { display: flex; gap: 20px; }
.footer-brand p { margin: 8px 0 0; max-width: 360px; }
.footer-brand .logo { width: 24px; height: 24px; }
.footer-brand .brand { font-size: 1rem; }
.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

/* Hero and sections */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  gap: 48px;
  padding: 48px 0 32px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -60px -10% auto;
  height: 420px;
  z-index: -1;
  background: radial-gradient(ellipse at 30% 30%, var(--hero-glow), transparent 60%);
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.1; letter-spacing: -0.035em; margin-bottom: 18px; }
.hero .lead { margin-left: 0; }
.hero .actions { justify-content: flex-start; }

.trust { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 24px 0 0; padding: 0; list-style: none; font-size: 0.9rem; color: var(--muted); }
.trust li { display: inline-flex; align-items: center; gap: 6px; }
.trust .icon { width: 16px; height: 16px; color: var(--good); }

/* Terminal panel in the hero (decorative) */
.terminal {
  overflow: hidden;
  background: #0f1117;
  border: 1px solid #262b36;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgb(16 24 40 / 0.18), 0 2px 6px rgb(16 24 40 / 0.08);
}
.terminal-bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; border-bottom: 1px solid #262b36; }
.terminal-bar span { width: 11px; height: 11px; border-radius: 50%; background: #3a4050; }
.terminal-bar span:nth-child(1) { background: #f87171; }
.terminal-bar span:nth-child(2) { background: #fbbf24; }
.terminal-bar span:nth-child(3) { background: #34d399; }
.terminal-bar em { margin-left: 8px; font-style: normal; font-size: 0.8rem; color: #8b93a5; }
.terminal pre {
  margin: 0;
  padding: 18px 20px 22px;
  font: 0.9rem/1.9 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #e5e7eb;
  white-space: pre-wrap;
}
.terminal .line { display: inline; }
.terminal b { color: #fb923c; font-weight: 700; }
.terminal i { color: #34d399; font-style: normal; }
.terminal u { color: #fdba74; text-decoration: none; }
.terminal .dim { color: #8b93a5; }
.terminal .cursor { display: inline-block; width: 8px; height: 1.1em; vertical-align: text-bottom; background: #e5e7eb; }

.icon { width: 22px; height: 22px; }
.icon-tile {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--link);
  background: var(--accent-soft);
  border-radius: 10px;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-top .icon-tile { width: 34px; height: 34px; border-radius: 9px; }
.card-top .icon { width: 18px; height: 18px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--link);
  background: var(--accent-soft);
  border-radius: 999px;
}
.lead { font-size: 1.15rem; color: var(--muted); margin: 0 auto 8px; max-width: 640px; }
.hero .lead { font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

.section { margin-top: 48px; }
.section > h2,
.section-head h2 { font-size: 1.4rem; margin: 0 0 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.type-card,
.item-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}
.type-card:hover,
.item-card:hover { transform: translateY(-2px); border-color: var(--button); }
.type-card p,
.item-card p { margin: 0; color: var(--muted); font-size: 0.95rem; flex: 1; }
.type-card .icon-tile { margin-bottom: 6px; }
.type-card .meta { color: var(--link); font-weight: 600; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty p { margin: 0 0 16px; }

.cta-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 56px;
  padding: 28px 32px;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.cta-band h2 { margin: 0 0 4px; font-size: 1.3rem; }
.cta-band p { margin: 0; color: var(--muted); }
.cta-band.small { margin-top: 48px; padding: 22px 26px; }
.cta-band.small h2 { font-size: 1.1rem; }

.page-head { margin-bottom: 28px; }
.page-head .lead { margin-left: 0; }
.page-head.center { text-align: center; padding: 48px 0; }
.page-head.center .lead { margin: 0 auto; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.pill {
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
}
.pill:hover { color: var(--text); border-color: var(--muted); }
.pill[aria-current="page"] { color: var(--button-text); background: var(--button); border-color: var(--button); }

/* Article */
.article { max-width: 720px; margin: 0 auto; }
.article .back { display: inline-block; margin-bottom: 20px; font-size: 0.9rem; text-decoration: none; }
.article .notice-inline { margin-bottom: 16px; }
.article h1 { margin-top: 12px; }
.article .lead { margin-left: 0; }
.prose { margin-top: 28px; font-size: 1.05rem; line-height: 1.75; }
.prose h2 { font-size: 1.45rem; margin: 40px 0 12px; }
.prose h3 { font-size: 1.2rem; margin: 32px 0 8px; }
.prose h4, .prose h5 { font-size: 1.05rem; margin: 24px 0 8px; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose pre {
  overflow-x: auto;
  padding: 16px 18px;
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--code-bg);
  border-radius: 10px;
}
.prose pre code { padding: 0; background: none; }
.prose blockquote {
  margin: 20px 0;
  padding: 4px 18px;
  color: var(--muted);
  border-left: 3px solid var(--button);
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose li { margin: 4px 0; }

/* Contact */
.contact { display: grid; grid-template-columns: 1fr 1.2fr; gap: 40px; align-items: start; }
.contact-intro .lead { margin-left: 0; }
.done h2 { margin-top: 0; }

/* ---------- Cards (account page, admin) ---------- */

.card {
  width: 100%;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin: 0 auto; }
.card.narrow h1 { font-size: 1.6rem; }
#logout { margin-top: 28px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  flex: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--button); }

.message { padding: 14px 16px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; }
.message h3 { margin: 0; }
.message .meta { margin: 2px 0 8px; }
.message-body { white-space: pre-wrap; margin: 0; }
.message .reply { margin-top: 12px; padding: 10px 14px; background: var(--accent-soft); border-radius: 8px; }
.message .reply strong { font-size: 0.85rem; }
.boxed { padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; max-height: 260px; overflow-y: auto; }

.steps { padding-left: 20px; }
.qr { display: inline-block; padding: 10px; background: #fff; border-radius: 8px; }
.qr:empty { display: none; }

/* ---------- Admin ---------- */

body.admin { padding: 24px 16px; }
.card.wide { max-width: 1080px; margin: 0 auto; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { margin: 0; font-size: 1.5rem; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar #logout { margin: 0; }
#twofa-banner { margin: 12px 0 0; }

.admin-tabs { margin: 20px 0 4px; }
.admin-tabs button { flex: 0 1 auto; }
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  font-size: 0.75rem;
  line-height: 20px;
  color: var(--button-text);
  background: var(--button);
  border-radius: 999px;
}

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.stats div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
.stats span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }

.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tool {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.tool span { font-size: 0.85rem; }
a.tool:hover { border-color: var(--button); }
.tool.placeholder { border-style: dashed; color: var(--muted); }

/* Charts */
.chart { margin: 24px 0 0; }
.chart figcaption { font-size: 0.95rem; margin-bottom: 8px; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--chart-bar); pointer-events: none; }
.chart .hit { fill: transparent; }
.chart .hit.active { fill: var(--chart-hover); }
.tooltip {
  position: fixed;
  z-index: 30;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.table-view { margin-top: 16px; font-size: 0.9rem; }
.table-view summary { cursor: pointer; color: var(--muted); }

/* Filters and tables */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 16px 0; }
.filters label { min-width: 140px; }
.filters select,
.filters input { width: auto; min-width: 140px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
#activity td:nth-child(4),
#message-list td:nth-child(2),
#content-list td:first-child { white-space: normal; min-width: 180px; }
.row-actions { display: flex; gap: 6px; justify-content: end; }

.settings { max-width: 560px; }

/* Dialogs */
dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 24px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
dialog.large { width: min(780px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dialog-actions > span { flex: 1; }
.dialog-actions a.small { font-size: 0.9rem; }

/* ---------- Motion (only for people who haven't asked their device to reduce it) ---------- */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  @keyframes appear { from { opacity: 0; } to { opacity: 1; } }
  @keyframes blink { 50% { opacity: 0; } }

  .hero-text > * { animation: rise 0.6s ease-out both; }
  .hero-text > :nth-child(2) { animation-delay: 0.06s; }
  .hero-text > :nth-child(3) { animation-delay: 0.12s; }
  .hero-text > :nth-child(4) { animation-delay: 0.18s; }
  .hero-text > :nth-child(5) { animation-delay: 0.24s; }
  .terminal { animation: rise 0.7s 0.15s ease-out both; }
  .terminal .line { animation: appear 0.3s ease-out both; }
  .terminal .l1 { animation-delay: 0.6s; }
  .terminal .l2 { animation-delay: 1.1s; }
  .terminal .l3 { animation-delay: 1.7s; }
  .terminal .l4 { animation-delay: 2.4s; }
  .terminal .l5 { animation-delay: 2.9s; }
  .terminal .l6 { animation-delay: 3.4s; }
  .terminal .cursor { animation: blink 1.1s steps(1) infinite; }
  .grid > * { animation: rise 0.5s ease-out both; }
  .grid > :nth-child(2) { animation-delay: 0.06s; }
  .grid > :nth-child(3) { animation-delay: 0.12s; }
  .grid > :nth-child(n+4) { animation-delay: 0.18s; }
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 720px) {
  .contact { grid-template-columns: 1fr; gap: 24px; }
  .hero { padding-top: 24px; }
  .terminal pre { font-size: 0.8rem; }
  .site-nav .button.small { padding: 6px 10px; }
  .site-header .brand > span { display: none; } /* logo tile only, so the menu fits on one line */
  .site-nav { gap: 14px; flex-wrap: nowrap; }
  .cta-band { padding: 22px; }
  .form-row { grid-template-columns: 1fr; }
  .site-nav { gap: 12px; font-size: 0.95rem; }
  .card { padding: 20px; }
}
