/* Centas Labs — »mörkt labb« visual identity v1 (docs/DESIGN.md).
   Tokens are authoritative: both this Go-served CSS and island CSS reference
   these names. Single-accent discipline: --labs-signal is the only saturated
   color in chrome. */

/* ---------------------------------------------------------------- fonts
   Vendored woff2 (via @fontsource) live in /static/fonts/; the frontend
   build supplies the files. Every family has a real fallback stack, so
   nothing breaks while they are missing. Latin + latin-ext (åäö). */

/* Space Grotesk — display */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/space-grotesk-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/space-grotesk-latin-ext-500.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/space-grotesk-latin-700.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/space-grotesk-latin-ext-700.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* Instrument Sans — body/UI */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-ext-500.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-600.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/instrument-sans-latin-ext-600.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* JetBrains Mono — timecode, dimensions, technical values */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/jetbrains-mono-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/jetbrains-mono-latin-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/jetbrains-mono-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/jetbrains-mono-latin-ext-500.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* ---------------------------------------------------------------- tokens
   Verbatim from docs/DESIGN.md. */
:root {
  --labs-bg:      #0B0D10;   /* page ground — near-black, cool          */
  --labs-surface: #14171C;   /* panels, timeline, cards                 */
  --labs-raised:  #1B1F26;   /* hover / active surfaces                 */
  --labs-line:    #262B33;   /* hairlines, borders                      */
  --labs-text:    #E9ECF1;   /* primary text                            */
  --labs-muted:   #8C96A3;   /* secondary text, labels                  */
  --labs-signal:  #59E3A7;   /* THE accent: phosphor green — actions,
                                playhead, focus ring, active states     */
  --labs-signal-ink: #06251A;/* text on signal                          */
  --labs-warn:    #E5A03C;   /* warnings (amber)                        */
  --labs-danger:  #E06456;   /* destructive / errors                    */
  --labs-radius:  4px;
  --labs-font-display: "Space Grotesk", system-ui, sans-serif;
  --labs-font-body:    "Instrument Sans", system-ui, sans-serif;
  --labs-font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

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

html {
  color-scheme: dark; /* labs commits to dark — no light theme */
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--labs-bg);
  color: var(--labs-text);
  font-family: var(--labs-font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--labs-font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.6em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }

p { margin: 0 0 1em; }

a { color: var(--labs-text); text-decoration-color: var(--labs-line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--labs-signal); }

code, .mono {
  font-family: var(--labs-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
}

::selection { background: var(--labs-signal); color: var(--labs-signal-ink); }

:focus-visible {
  outline: 2px solid var(--labs-signal);
  outline-offset: 3px;
}

button, input { font: inherit; color: inherit; }

/* Micro-labels: uppercase, wide tracking, muted (docs/DESIGN.md). */
.micro-label {
  font-family: var(--labs-font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--labs-muted);
  margin: 0 0 0.5rem;
}

.muted { color: var(--labs-muted); }

/* htmx request indicators — htmx's own defaults, vendored here because the
   library's injected inline <style> is blocked by the strict style-src 'self'
   CSP (base.html sets includeIndicatorStyles:false to stop the injection). */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Section labels with the measurement-tick motif: a short ruler strip on the
   leading edge — the identity's signature detail. */
.section-label {
  font-family: var(--labs-font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--labs-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}
.section-label::before {
  content: "";
  width: 34px;
  height: 8px;
  flex: none;
  background-image: repeating-linear-gradient(
    to right,
    var(--labs-line) 0 1px,
    transparent 1px 6px
  );
  border-bottom: 1px solid var(--labs-line);
}

/* ---------------------------------------------------------------- layout */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--labs-line);
}

.wordmark {
  font-family: var(--labs-font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark span { color: var(--labs-signal); }

.site-nav {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.site-nav a, .site-nav .linklike {
  font-family: var(--labs-font-body);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--labs-muted);
  text-decoration: none;
}
.site-nav a:hover, .site-nav .linklike:hover { color: var(--labs-text); }
.site-nav a[aria-current="page"] { color: var(--labs-signal); }
.nav-form { display: inline; margin: 0; }
.linklike {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

main {
  flex: 1;
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--labs-line);
}
.site-footer .micro-label { margin: 0; }

/* ---------------------------------------------------------------- hero */
.hero { max-width: 44rem; margin-bottom: 1rem; }
.hero h1 { font-size: 2.1rem; }
.lede { font-size: 1.05rem; color: var(--labs-muted); max-width: 44rem; }

/* ---------------------------------------------------------------- cards */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--labs-surface);
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  text-decoration: none;
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
}
.card:hover { background: var(--labs-raised); border-color: var(--labs-muted); }

.card-title {
  font-family: var(--labs-font-display);
  font-weight: 700;
  font-size: 1.1rem;
}
.card .micro-label { margin: 0; }

.badge {
  align-self: flex-start;
  margin-top: 0.4rem;
  font-family: var(--labs-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  color: var(--labs-muted);
}
.badge-open { border-color: var(--labs-signal); color: var(--labs-signal); }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--labs-surface);
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  padding: 1.75rem;
}
.panel-narrow { max-width: 26rem; margin: 2rem auto; }

/* ---------------------------------------------------------------- forms */
form label {
  display: block;
  font-family: var(--labs-font-body);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--labs-muted);
  margin: 1.1rem 0 0.35rem;
}
form label .micro-label { display: inline; text-transform: none; letter-spacing: 0.04em; margin: 0; }

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--labs-bg);
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  color: var(--labs-text);
  transition: border-color 150ms ease-out;
}
input:focus-visible { outline-offset: 1px; border-color: var(--labs-signal); }

.check {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  text-transform: none !important;
  letter-spacing: 0.02em !important;
}
input[type="checkbox"] { accent-color: var(--labs-signal); width: 1rem; height: 1rem; }

.btn {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.55rem 1.2rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  background: var(--labs-surface);
  color: var(--labs-text);
  cursor: pointer;
  transition: background-color 150ms ease-out;
}
.btn:hover { background: var(--labs-raised); }
.btn-primary {
  background: var(--labs-signal);
  border-color: var(--labs-signal);
  color: var(--labs-signal-ink);
}
.btn-primary:hover { background: color-mix(in srgb, var(--labs-signal) 88%, white); }

/* ---------------------------------------------------------------- alerts */
.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--labs-radius);
  border: 1px solid;
  font-size: 0.95rem;
}
.alert-error { border-color: var(--labs-danger); color: var(--labs-danger); }
.alert-warn  { border-color: var(--labs-warn);  color: var(--labs-warn); }

/* ---------------------------------------------------------------- tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.data th {
  text-align: left;
  font-family: var(--labs-font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--labs-muted);
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--labs-line);
}
table.data td {
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-bottom: 1px solid var(--labs-line);
}

/* ---------------------------------------------------------------- invites */
.invite-created {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--labs-signal);
  border-radius: var(--labs-radius);
  background: var(--labs-bg);
}
.invite-created .micro-label { color: var(--labs-signal); }
.invite-url {
  display: block;
  word-break: break-all;
  margin: 0.4rem 0;
}

/* ---------------------------------------------------------------- provduken shell */
/* App layout: tool pages opt in via {{define "main_class"}}main-app{{end}} —
 * the content column's max-width/padding is for text pages; an editor gets
 * the full viewport. The site footer steps aside on app pages (graceful:
 * browsers without :has() simply keep it, below the fold). */
.main-app { max-width: none; padding: 0; display: flex; flex-direction: column; }
body:has(.main-app) .site-footer { display: none; }

.tool-strip {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--labs-line);
}
.tool-strip-id { display: flex; align-items: baseline; gap: 0.6rem; }
.tool-strip-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
/* Single-accent discipline: the note is quiet chrome; only the privacy
   promise itself (a <strong> in the template) steps up to text. */
.tool-strip-note {
  margin: 0 0 0 auto;
  font-size: 0.75rem;
  color: var(--labs-muted);
}
.tool-strip-note strong { color: var(--labs-text); font-weight: 600; }
.tool-about { position: relative; font-size: 0.8rem; }
.tool-about summary { cursor: pointer; color: var(--labs-muted); list-style: none; }
.tool-about summary::after { content: " ▾"; font-size: 0.7em; }
.tool-about[open] summary { color: var(--labs-text); }
.tool-about-body {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.5rem);
  left: 0;
  width: min(26rem, 80vw);
  padding: 0.9rem 1rem;
  background: var(--labs-raised);
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
  color: var(--labs-muted);
}
.tool-about-body p { margin: 0; }

#tool-root {
  min-height: 24rem;
  background: var(--labs-surface);
}
/* Text-page fallback (non-app pages keep the boxed look). */
main:not(.main-app) #tool-root {
  margin-top: 1rem;
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
}
/* Chrome above the island in app mode: header ~3.6rem + tool strip ~2.4rem.
 * The island's .pd reads this to fill the rest of the viewport exactly. */
/* App-mode sizing: a real flex chain instead of estimating the chrome height
 * with a --pd-chrome constant (the estimate clipped the timeline footer by
 * however much the real header+strip differed). body gets a DEFINITE height,
 * which is what lets flex:1 (basis 0) resolve at every level below — without
 * it .pd collapses to its min-height (the earlier thin-band bug). :has() is
 * already a dependency of app mode (footer hiding above). */
body:has(.main-app) { height: 100dvh; overflow: hidden; }
.main-app { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.main-app #tool-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main-app .pd { flex: 1; min-height: 540px; height: auto; border: 0; border-radius: 0; }

.island-fallback { padding: 1.75rem; max-width: 40rem; }

.spec-list { margin: 0; }
.spec-list div {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--labs-line);
}
.spec-list dt { color: var(--labs-muted); }
.spec-list dd { margin: 0; }

noscript .alert { display: block; margin-top: 1rem; }

/* ---------------------------------------------------------------- admin access */
.badge-warn { border-color: var(--labs-warn); color: var(--labs-warn); }

table.data form { margin: 0; }
table.data td { vertical-align: top; }
.btn-small {
  margin-top: 0.35rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
}
.grant-box { margin-top: 0.35rem; }
.grant-box summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--labs-muted);
}
.grant-box summary:hover { color: var(--labs-text); }
.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.6rem 0 0.2rem;
}
.check-list .check { margin: 0; font-size: 0.85rem; }

/* ---------------------------------------------------------------- news */
.news-group { margin-bottom: 2.25rem; }
.news-entry {
  max-width: 44rem;
  margin-bottom: 0.85rem;
  padding: 1rem 1.25rem;
  background: var(--labs-surface);
  border: 1px solid var(--labs-line);
  border-radius: var(--labs-radius);
}
.news-entry header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}
.news-entry h3 { margin: 0; font-size: 1.05rem; }
.news-entry header .badge { align-self: baseline; margin-top: 0; }
.news-entry p { margin: 0.45rem 0 0; color: var(--labs-muted); }
.news-entry ul {
  margin: 0.45rem 0 0;
  padding-left: 1.2rem;
  color: var(--labs-muted);
}
.news-entry li { margin: 0.2rem 0; }

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
