/* theme: nocturne — The mecha palette. Dark-first, violet accent, amber for anything called out. */
:root {
  color-scheme: light dark;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 8px;
  --ground: #ffffff;
  --surface: #f7f7fa;
  --text: #1a1a22;
  --muted: #5a5a68;
  --line: #dcdce4;
  --accent: #5d5294;
  --on-accent: #ffffff;
  --ring: #9184d9;
  --signal: #96601f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #12141f;
    --surface: #161826;
    --text: #e9e9ed;
    --muted: #9a9aa8;
    --line: #2b2741;
    --accent: #b5abfc;
    --on-accent: #12141f;
    --ring: #9184d9;
    --signal: #e8a24a;
  }
}
:root[data-theme="light"] {
  --ground: #ffffff;
  --surface: #f7f7fa;
  --text: #1a1a22;
  --muted: #5a5a68;
  --line: #dcdce4;
  --accent: #5d5294;
  --on-accent: #ffffff;
  --ring: #9184d9;
  --signal: #96601f;
}
:root[data-theme="dark"] {
  --ground: #12141f;
  --surface: #161826;
  --text: #e9e9ed;
  --muted: #9a9aa8;
  --line: #2b2741;
  --accent: #b5abfc;
  --on-accent: #12141f;
  --ring: #9184d9;
  --signal: #e8a24a;
}

/* mecha-manifest — the structural sheet. One column, one layout, every colour
   a token. Nothing here is a hue: a theme supplies the values and adds no
   rules, which is what makes changing the look a swap rather than a rewrite.

   No @import and no hosted font. An imported stylesheet is an external
   reference — the gate blocks it under `style-src 'self'`, and the publish
   gate fails a bundle for one. Vendoring a woff2 and serving it from our own
   origin is the supported route. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  /* A readable measure, not a mobile one. Forms narrow themselves below;
     pages that carry tables widen themselves further down. */
  max-width: 46rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* A form is read one line at a time, and a long measure makes a column of
   inputs feel like a table — so the form element keeps the old narrow
   measure inside whatever page it is on. */
main > form { max-width: 34rem; }

/* The account page's ledgers are tables, and tables want room. `:has` is
   the page classifying itself: no markup change, no second stylesheet. */
main:has(table) { max-width: 72rem; }

/* Commands a person copies — the pairing instruction — wrap instead of
   walking off the edge of the screen. */
pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

.intro {
  color: var(--muted);
  margin: 0 0 2.5rem;
  font-size: 1.0625rem;
}

/* --- fields ------------------------------------------------------------- */

.field { margin: 0 0 1.75rem; }
.field[hidden] { display: none; }

label {
  display: block;
  /* Mono, deliberately. A field label names a value rather than describing
     one, which is nearer to code than to prose — and it is the single choice
     that stops a generated form looking generic. */
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0 0 0.5rem;
}

.req {
  color: var(--muted);
  font-weight: 400;
}

.help {
  color: var(--muted);
  font-size: 0.875rem;
  margin: -0.25rem 0 0.5rem;
}

input[type=text], input[type=email], input[type=url], input[type=date],
input[type=number], input[type=tel], select, textarea {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .12s ease, box-shadow .12s ease;
}

textarea { min-height: 7rem; resize: vertical; line-height: 1.6; }

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }

input[type=file] {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

input[type=file]::file-selector-button {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  margin-right: 0.75rem;
  cursor: pointer;
}

.file-limits {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0.375rem 0 0;
}

/* The submission form's stand-in for a file input: the upload comes after
   verification, and this is where the form says so. */
.file-note {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin: 0;
}

/* The chevron is drawn here rather than left to the platform, because a
   native select arrow is the one control that makes a styled form look
   half-styled. `img-src data:` covers it; nothing is fetched. */
select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239a9aa8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

input:hover, select:hover, textarea:hover { border-color: var(--muted); }

/* One focus treatment everywhere: a ring outside the border rather than an
   outline on it, so nothing shifts by a pixel when a field takes focus. */
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent);
}

/* --- checkboxes --------------------------------------------------------- */

.choices { display: grid; gap: 0.625rem; margin-top: 0.25rem; }

.ack label, .choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.625rem;
  align-items: start;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0;
  cursor: pointer;
}

input[type=checkbox], input[type=radio] {
  appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.19rem 0 0;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
input[type=radio] { border-radius: 50%; }

input[type=checkbox]:checked, input[type=radio]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type=checkbox]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
  background-size: 0.875rem;
  background-position: center;
  background-repeat: no-repeat;
}

/* --- steps -------------------------------------------------------------- */

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 0 0 2rem;
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}

legend {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 0.5rem;
}

/* --- what went wrong ---------------------------------------------------- */

/* The signal colour marks and never fills. A field that failed gets a rule
   and a word, not a coloured panel — the palette has one accent and treats
   amber as a called-out line rather than a background. */
[aria-invalid=true] { border-color: var(--signal); }

.error {
  color: var(--signal);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin: 0.5rem 0 0;
}

.errors {
  border-left: 2px solid var(--signal);
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 0 0 2rem;
}
.errors p { margin: 0 0 0.25rem; font-weight: 500; }
.errors ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9375rem; }

/* --- submit ------------------------------------------------------------- */

button {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.6875rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: opacity .12s ease;
}
button:hover { opacity: .88; }
button:active { opacity: .96; }

a { color: var(--accent); text-underline-offset: 2px; }

/* The confirmation and error pages share the shell, so they get the same
   measure and rhythm without a second stylesheet. */
main > h1:only-of-type + p { color: var(--muted); }

/* The hangar and its switchboards: a person's own pages.
   These classes were emitted with no rules behind them at all, so the page
   fell back to browser defaults -- bulleted lists and underlined blue links
   -- while every test passed, because a test asserts what a page *says* and
   none can assert that it looks designed. The person who opened it is what
   caught it, which is the same shape as a renderer needing a real terminal
   rather than a passing suite. */

/* A person's links, under their name. Spaced rather than run together: the
   default inline flow produced "Github Computational Social Affective
   Neuroscience Lab cosanlab.com" as one unreadable run. */
nav.links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.375rem 1.25rem;
  margin: 0 0 2.5rem;
}
nav.links a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
nav.links a:hover { border-bottom-color: var(--accent); }
/* The host beside a link whose kind cannot vouch for it. Quiet, but never
   invisible -- it is the one thing standing between a labelled link and a
   phishing link. */
nav.links .muted { font-size: 0.875rem; }

/* The lines of a hangar or a switchboard. No bullets: these are destinations,
   not prose, and a marker in front of each adds nothing a reader uses. */
ul.lines {
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
ul.lines li { margin: 0; }
ul.lines a {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  padding: 0.4375rem 0;
  font-weight: 450;
}
ul.lines a:hover { color: var(--accent); }

/* A switchboard's lines are the point of the page rather than an index of
   it, so they are buttons: bigger targets, a surface, and a blurb under the
   label when its author wrote one. */
ul.lines a.line {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  background: var(--surface);
}
ul.lines a.line:hover {
  border-color: var(--accent);
  color: var(--text);
}
ul.lines .label { display: block; }
ul.lines .blurb {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 400;
  margin-top: 0.1875rem;
}

/* The site header: mark on the left, account on the right. Present on the
   gate's own pages and on rendered forms; never on artifact origins, whose
   bytes are content-addressed and not ours to decorate. A full-width band
   with its own rule underneath, so the chrome reads as chrome and the page
   starts where the border ends. */
header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
/* The mark wears the brand's accent — it sits on the page ground, where the
   theme's own light/dark accent pair is exactly the contrast rule. */
header.site a.mark { color: var(--accent); display: inline-flex; }
header.site a.mark:hover { opacity: .8; }
header.site > nav { display: flex; gap: 1rem; align-items: center; }
.site-right { display: flex; gap: 1rem; align-items: center; }
.site-right nav a { font-size: 0.875rem; color: var(--muted); text-decoration: none; }
.site-right nav a:hover { color: var(--accent); text-decoration: underline; }
.account-menu .menu label { font-size: 0.8125rem; }
.account-menu .menu input { margin: 0.25rem 0 0.625rem; }
header.site > nav a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}
header.site > nav a:hover { color: var(--accent); text-decoration: underline; }

/* The account dropdown is a <details>: open/close is the browser's, no
   script anywhere. */
.account-menu { position: relative; }
.account-menu > summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu[open] > summary { border-color: var(--accent); }
.account-menu > .menu {
  position: absolute;
  right: 0;
  margin-top: 0.375rem;
  min-width: 14rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  z-index: 1;
}
.account-menu .menu p {
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}
.account-menu .menu nav a { display: block; padding: 0.25rem 0; font-size: 0.875rem; }
.account-menu .menu form { margin: 0.5rem 0 0; }
.account-menu .menu button {
  width: 100%;
  padding: 0.4375rem 0.75rem;
  font-size: 0.875rem;
  background: var(--ground);
  color: var(--text);
  border-color: var(--line);
}

/* The framed artifact viewer: the site header above, the bundle below,
   nothing scrolling but the frame itself. */
body.viewer { display: flex; flex-direction: column; height: 100vh; margin: 0; }
body.viewer iframe.artifact { border: 0; flex: 1; width: 100%; background: var(--ground); }
.account-menu .menu nav strong { display: block; padding: 0.25rem 0; font-size: 0.875rem; }

/* Tables — the account page's artifacts and machines. */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0.75rem 0 1.5rem;
}
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 0.375rem 0.75rem 0.375rem 0;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
td form { margin: 0; display: inline; }
td button { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

@media (max-width: 30rem) {
  main { padding: 2.5rem 1.25rem 4rem; }
  h1 { font-size: 1.5rem; }
  header.site { padding: 1rem 1.25rem 0; }
}
