/* LIGATE — one stylesheet, no framework.
 *
 * A field notebook on a dark bench. Serif for anything written by a person,
 * monospace for anything measured by an instrument. That split is the whole
 * design system: if it is a number, an identifier or a reading, it is mono.
 */

:root {
  --field:  #0c1220;
  --panel:  #141c2e;
  --panel2: #101728;
  --line:   #24304a;
  --line2:  #33415e;
  --cream:  #ece3cf;
  --dim:    #8494b3;
  --dimmer: #5b6a88;
  --amber:  #f0b429;
  --good:   #4ade80;
  --bad:    #f87171;

  --ori: #22d3ee;  --marker: #fb923c; --promoter: #34d399; --rbs: #fbbf24;
  --cds: #38bdf8;  --tag: #a78bfa;    --term: #f472b6;     --reg: #e879f9;

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;

  --pad: 18px;
  --r: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--field);
  color: var(--cream);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad)
           calc(var(--pad) + env(safe-area-inset-bottom));
}

/* Nothing in this game benefits from a horizontal scrollbar. */
body { overflow-x: hidden; }

/* ------------------------------------------------------------------- type */

h1 { font-size: 44px; margin: 4px 0 2px; letter-spacing: -1.5px; font-weight: 600; }
h2 { font-size: 25px; margin: 8px 0 4px; font-weight: 600; line-height: 1.15; }
p  { margin: 0 0 10px; line-height: 1.5; }

.eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 3.5px;
  color: var(--amber); text-transform: uppercase;
}
.label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  color: var(--dimmer); text-transform: uppercase;
}
.dim   { color: var(--dim); }
.small { font-size: 13px; }
.mono  { font-family: var(--mono); }
.num   { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- layout */

.row  { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.spacer { height: 20px; }

.card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px;
}

/* --------------------------------------------------------------- controls */

button {
  font: inherit; cursor: pointer; border: none; background: none; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--amber); outline-offset: 2px;
}

/* Every tappable thing clears 44px, either directly or with padding. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 12px 16px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); color: var(--cream);
  font-family: var(--mono); font-size: 12px; letter-spacing: 1.2px;
  text-transform: uppercase;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber); color: #1a1200; border-color: var(--amber); font-weight: 700; }
.btn.danger  { color: var(--bad); }
.btn.wide    { width: 100%; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: none; border-color: transparent; color: var(--dim); min-height: 32px; padding: 4px 0; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  flex: 1; min-height: 38px; padding: 6px 10px; background: var(--panel2);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.2px; color: var(--dim);
}
.seg button[aria-pressed="true"] { background: var(--line); color: var(--cream); }

/* ------------------------------------------------------------ brief cards */

.brieflist { display: flex; flex-direction: column; gap: 8px; }

.brief-card {
  display: block; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; color: var(--cream);
  font-family: var(--serif);
}
.brief-card[disabled] { opacity: .38; }
.brief-card .t { font-size: 17px; }
.brief-card .g { color: var(--dim); font-size: 13px; margin-top: 4px; line-height: 1.45; }
.brief-card .n {
  font-family: var(--mono); font-size: 11px; color: var(--dimmer);
  min-width: 22px; display: inline-block;
}
.act-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 22px 0 9px;
}
.act-head .rule { flex: 1; height: 1px; background: var(--line); }

.tick { color: var(--good); font-family: var(--mono); font-size: 13px; }
.locked { font-family: var(--mono); font-size: 10px; color: var(--dimmer); letter-spacing: 1.5px; }

/* ------------------------------------------------------------------- ring */

.ringwrap { display: flex; justify-content: center; margin: 4px 0 2px; position: relative; }
.ring { touch-action: manipulation; max-width: 100%; height: auto; }
.ring .seg-arc { cursor: pointer; }
.ring .seg-arc.sel { filter: brightness(1.5); }
.ring text { pointer-events: none; user-select: none; }

.ringempty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--dimmer); font-size: 13px; text-align: center; pointer-events: none;
  padding: 0 60px;
}

/* -------------------------------------------------------------- part rail */

.rail { margin-top: 6px; }
.rail-group + .rail-group { margin-top: 10px; }
.rail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }

.chip {
  display: inline-flex; align-items: stretch;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--line2));
  border-radius: 9px; overflow: hidden;
  font-family: var(--mono); font-size: 11.5px; color: var(--cream);
}
.chip .chip-add { padding: 10px 9px; min-height: 42px; text-align: left; color: inherit; }
.chip .bp { color: var(--dimmer); font-size: 10px; }
.chip.new { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.chip .q {
  color: var(--dimmer); width: 30px; font-size: 12px;
  border-left: 1px solid var(--line);
}
.chip .q:active, .chip .chip-add:active { background: var(--line); }

.blurb {
  margin-top: 7px; font-size: 13px; line-height: 1.55; color: var(--dim);
  border-left: 2px solid var(--c, var(--line2)); padding-left: 10px;
}

/* --------------------------------------------------------------- selected */

.selbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 6px; padding: 8px 0;
  background: linear-gradient(to top, var(--field) 70%, transparent);
}
.selbar .btn { flex: 1; padding: 10px 6px; font-size: 11px; min-height: 44px; }

/* ------------------------------------------------------------------ plate */

.plates { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 6px; }
.plate { flex: 1; text-align: center; min-width: 0; }
.plate svg { width: 100%; max-width: 160px; }
.plate .cap {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  letter-spacing: 1.2px; margin-top: 3px;
}
.plate .sub { font-family: var(--mono); font-size: 9.5px; color: var(--dimmer); }

/* The reveal. One beat of silence after the plate slides up, then colonies
   bloom on a jittered schedule. Failure gets no shake and no red flash — the
   plate just sits there. */
@keyframes bloom { from { transform: scale(0); opacity: 0; }
                   60% { transform: scale(1.15); opacity: 1; }
                   to   { transform: scale(1); opacity: 1; } }
@keyframes slideup { from { transform: translateY(14px); opacity: 0; }
                     to   { transform: none; opacity: 1; } }
@keyframes flash { 0%,100% { background: var(--field); }
                   12% { background: #16324a; } 45% { background: #16324a; }
                   62% { background: #2a1c06; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.revealing .plate svg { animation: slideup .25s ease-out both; animation-delay: .35s; }
.revealing .colony { transform-box: fill-box; transform-origin: center;
                     animation: bloom .34s cubic-bezier(.2,1.4,.5,1) both; }
.revealing .after { animation: fadein .4s ease-out both; animation-delay: 1.3s; }
.heatshock { animation: flash .36s linear both; }

@media (prefers-reduced-motion: reduce) {
  .revealing .plate svg, .revealing .colony, .revealing .after, .heatshock {
    animation-duration: .01ms !important; animation-delay: 0ms !important;
  }
}

/* --------------------------------------------------------------- readings */

.readout { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.reading { display: flex; align-items: baseline; gap: 6px; font-family: var(--mono); font-size: 12px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; border: 1px solid #0006; flex: none; }

/* Criteria. The mark is a glyph as well as a colour, and the row is readable
   with no colour at all — 8% of men cannot use a green tick against a red cross. */
.crit { display: flex; gap: 9px; align-items: flex-start; padding: 3px 0; }
.crit .m { font-family: var(--mono); font-size: 13px; line-height: 1.5; flex: none; width: 14px; }
.crit.ok  .m { color: var(--good); }
.crit.no  .m { color: var(--bad); }
.crit .txt { font-size: 13.5px; line-height: 1.5; }
.crit.no .txt { color: #d6c9b4; }

.warnlist { margin-top: 10px; }
.warn {
  display: flex; gap: 8px; font-size: 12.5px; line-height: 1.5;
  color: var(--dim); padding: 4px 0;
}
.warn .m { color: var(--amber); font-family: var(--mono); flex: none; }

/* --------------------------------------------------------------- scoring */

.score { margin-top: 12px; }
.bar { margin-top: 9px; }
.bar .top { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; }
.bar .track {
  height: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 5px; margin-top: 4px; position: relative; overflow: hidden;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--line2); }
.bar .you {
  position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--amber);
}

/* ----------------------------------------------------------------- trace */

.trace { font-family: var(--mono); font-size: 11px; line-height: 1.7; }
.trace .u { margin-bottom: 10px; }
.trace .hdr { color: var(--promoter); }
.trace .step { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; }
.trace .flux { color: var(--dimmer); text-align: right; }
.trace .nm { color: var(--cream); }
.trace .note { color: var(--dim); }
.trace .off { color: var(--dimmer); }

/* ------------------------------------------------------------- lab note */

.labnote {
  margin-top: 12px; padding: 12px 13px;
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: 0 var(--r) var(--r) 0; background: var(--panel2);
  font-size: 13.5px; line-height: 1.6; color: var(--cream);
}
.labnote .h { font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px;
              color: var(--amber); display: block; margin-bottom: 5px; }

.discover {
  margin-top: 12px; padding: 13px;
  border: 1px solid var(--amber); border-radius: var(--r);
  background: #1c1608;
}
.discover .h { font-family: var(--mono); font-size: 9.5px; letter-spacing: 2px; color: var(--amber); }
.discover .l { font-size: 14.5px; line-height: 1.5; margin: 6px 0 8px; }

/* ------------------------------------------------------------------ gate */

.gate { text-align: center; padding: 8px 0 0; }
.price { font-family: var(--mono); font-size: 34px; color: var(--amber); }

/* --------------------------------------------------------------- toast */

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 50;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 10px;
  padding: 11px 16px; font-family: var(--mono); font-size: 11.5px;
  max-width: 92vw; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
#toast.on { opacity: 1; }

/* ------------------------------------------------------------------ misc */

/* Read aloud, never drawn. The tick and cross are also colour-independent
   glyphs, but a screen reader should not have to infer meaning from "✓". */
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
a { color: var(--amber); }
details summary { cursor: pointer; font-family: var(--mono); font-size: 11px;
                  letter-spacing: 1.2px; color: var(--dim); padding: 8px 0; }
.prose { font-size: 14px; line-height: 1.65; color: var(--cream); }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose li { margin-bottom: 7px; line-height: 1.6; }

/* Expanded bench: usable forms, keyboard part selection and experiment tabs. */
#app { max-width: 760px; }
h3 { font-size: 18px; margin: 0 0 8px; }
.free-label { color: var(--amber); margin: 14px 0; }
.progress { height: 5px; border-radius: 4px; overflow: hidden; background: var(--line); margin: 18px 0 8px; }
.progress span { height: 100%; display: block; background: var(--good); }
.home-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.home-tools > .btn { flex: 1; min-width: 130px; }
.footer-tools, .workshop-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.page-kicker { margin-top: 14px; }
.section-label { margin-top: 22px; margin-bottom: 8px; }
.secondary-action { margin-top: 12px; }
.help { margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; font: 12px/1.5 var(--mono); color: var(--dim); min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
input, select, textarea { font: 14px/1.5 var(--mono); color: var(--cream); background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; padding: 10px; max-width: 100%; }
input:not([type=checkbox]), select, textarea { width: 100%; min-width: 0; min-height: 44px; }
textarea { resize: vertical; overflow-wrap: anywhere; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--amber); flex: none; }
.check { display: flex; gap: 9px; align-items: center; min-height: 44px; font: 12px/1.5 var(--mono); color: var(--dim); }
.part-order { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.part-index { padding: 9px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; font: 11px var(--mono); color: var(--dim); }
.part-index.selected { border-color: var(--amber); background: var(--panel); color: var(--cream); }
.selected-part { margin-top: 12px; }
.selected-part .selbar { position: static; flex-wrap: wrap; background: none; }
.edit-tools { margin: 12px 0; }
.assembly { margin-bottom: 18px; }
.junctions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.junction { font: 11px/1.5 var(--mono); padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.junction.ok { color: var(--good); }.junction.bad { color: var(--bad); }
.condition-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.condition-tabs .btn { text-transform: none; font-size: 11px; flex: 1; min-width: 90px; }
.condition-tabs [aria-pressed=true] { border-color: var(--amber); color: var(--amber); }
.result-headline { font-size: 23px; line-height: 1.4; margin-top: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding: 14px 0; }
.metric-grid > div { background: var(--panel); padding: 10px; border-radius: 10px; }
.metric-grid .label { font-size: 8px; letter-spacing: 1px; }
.metric-grid strong { display: block; font: 20px/1.7 var(--mono); }
.metric-grid small { font-size: 10px; color: var(--dim); }
.palette-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 8px; }
.author-trial { margin-top: 14px; }
.plates .plate svg { max-width: 220px; }
.card p:last-child { margin-bottom: 0; }
#workshop-message, #author-message, #codemsg { color: var(--amber); overflow-wrap: anywhere; }
.btn.ghost { min-height: 44px; }
.chip .q { width: 40px; }
.chip .chip-add { min-height: 44px; }
.brieflist .g.mono { font-size: 10px; }
@media (min-width: 650px) { .brieflist { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); } .brief-card { height: 100%; } }
@media (max-width: 360px) { :root { --pad: 12px; } .btn { padding: 10px; font-size: 10px; } .metric-grid strong { font-size: 17px; } }
@media (max-width: 420px) { .field-grid { grid-template-columns: minmax(0, 1fr); } }
