/* MIT License - Copyright (c) fintonlabs.com */
/* Greenagonia mobile — "Trail register". One family (Archivo, width axis),
   one accent, hairlines instead of cards. See DESIGN.md. */

:root {
  --bg: #0b100d;
  --bg-2: #121914;
  --line: rgba(236, 239, 230, 0.13);
  --line-2: rgba(236, 239, 230, 0.28);
  --ink: #ecefe6;
  --ink-2: #aab4a7;
  --ink-3: #7f8a7e;
  --accent: #d6f04f;
  --on-accent: #0b100d;
  --fail: #ff7468;
  --overlay: rgba(4, 7, 5, 0.72);
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --pad: 16px;
  --bar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: 150ms ease-out;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  max-width: 480px;
  min-height: 100dvh;
  border-right: 1px solid var(--line);
  padding-bottom: calc(var(--bar-h) + var(--safe-b) + 40px);
  touch-action: manipulation;
}

h1, h2, h3 { font-weight: 700; }
a { color: var(--ink); text-underline-offset: 3px; }
code { font-family: inherit; color: var(--ink); white-space: nowrap; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* small condensed capitals: every label, caption and figure heading */
.label, .rule span, .rule h2, .rule h3, .top__note, .field, .route__time,
.cascade__t, .cascade__sev, .log time, .log__kind, .lead__badge, .gear__cat {
  font-size: 13px;
  line-height: 16px;
  font-stretch: 78%;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: auto 1fr 48px; align-items: center;
  height: 48px; padding-left: var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px; height: 48px;
  font-weight: 800; font-stretch: 112%; letter-spacing: -0.01em;
}
.brand svg { width: 20px; height: 20px; color: var(--accent); }
.top__note { text-align: right; padding: 0 8px 0 16px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { display: grid; place-items: center; width: 48px; height: 48px; color: var(--ink-2); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:active { color: var(--ink); }

/* ---------- lead product ---------- */
.lead__art { display: block; aspect-ratio: 5 / 3; overflow: hidden; background: var(--bg-2); }
.lead__art svg { display: block; width: 100%; height: 100%; }
.lead__body { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px var(--pad) 24px; }
.lead__badge { grid-column: 1 / -1; color: var(--accent); }
.lead__name { font-size: 28px; line-height: 32px; font-stretch: 108%; letter-spacing: -0.02em; }
.lead__price { font-size: 28px; line-height: 32px; font-weight: 300; font-variant-numeric: tabular-nums; }
.lead__desc { grid-column: 1 / -1; color: var(--ink-2); max-width: 34ch; }

/* ---------- section rule ---------- */
.rule {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 8px var(--pad); border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line);
}
.rule h2, .rule h3 { color: var(--ink); font-weight: 700; }
.rule span { color: var(--ink-3); text-align: right; }

/* ---------- gear list ---------- */
.gear__list { list-style: none; }
.gear__row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 0 16px; align-items: center;
  padding: 8px 0 8px var(--pad); border-bottom: 1px solid var(--line);
}
.gear__art { width: 56px; height: 48px; overflow: hidden; border-radius: 2px; }
.gear__art svg { display: block; width: 100%; height: 100%; }
.gear__name { display: block; font-weight: 600; line-height: 24px; }
.gear__cat { color: var(--ink-3); }
.gear__buy { display: flex; align-items: center; }
.gear__qty { min-width: 24px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.step { display: grid; place-items: center; width: 48px; height: 48px; color: var(--ink-2); }
.step svg { width: 16px; height: 16px; }
.step:active { color: var(--accent); }

/* ---------- footer ---------- */
.foot { padding: 32px var(--pad) 24px; color: var(--ink-3); }
.foot__brand { display: block; height: 48px; font-weight: 700; color: var(--ink-2); }
.foot p { max-width: 30ch; }
.link { height: 48px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.rule .link { height: 32px; font-size: 13px; }

/* ---------- status line + bottom bar ---------- */
.status {
  position: fixed; left: 0; bottom: calc(var(--bar-h) + var(--safe-b)); z-index: 30;
  width: 100%; max-width: 480px; padding: 8px var(--pad);
  background: var(--bg-2); border-top: 1px solid var(--line-2);
  font-size: 13px; line-height: 16px; color: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity var(--ease);
}
.status.is-on { opacity: 1; }
.status.is-fail { color: var(--fail); }

.bar {
  position: fixed; left: 0; bottom: 0; z-index: 20;
  width: 100%; max-width: 480px; height: calc(var(--bar-h) + var(--safe-b));
  padding: 8px var(--pad) calc(8px + var(--safe-b));
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  background: var(--bg); border-top: 1px solid var(--line-2);
}
.bar__sum { display: grid; }
.bar__sum strong { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px;
  border: 1px solid var(--line-2); border-radius: 2px;
  font-weight: 700; font-stretch: 90%; letter-spacing: 0.02em;
  color: var(--ink);
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
.btn:active { background: var(--bg-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:active { background: var(--ink); border-color: var(--ink); }
.btn:disabled { background: none; border-color: var(--line); color: var(--ink-3); cursor: default; }
.btn--block { width: 100%; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-pair .btn { padding: 0 8px; }

/* ---------- sheets (full-height dialogs) ---------- */
.sheet {
  position: fixed; inset: 0 auto 0 0; margin: 0;
  width: 100%; max-width: 480px; height: 100dvh; max-height: none;
  border: 0; border-right: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
  flex-direction: column;
}
.sheet[open] { display: flex; }
.sheet::backdrop { background: var(--overlay); }
.sheet--short { inset: auto auto 0 0; height: auto; border-top: 1px solid var(--line-2); }
.sheet__head {
  display: grid; grid-template-columns: 1fr 48px; align-items: center;
  padding: 8px 0 8px var(--pad); border-bottom: 1px solid var(--line-2);
}
.sheet__head h2 { font-size: 16px; line-height: 24px; font-stretch: 108%; }
.sheet__body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px var(--pad) 24px; }
.sheet__body > p, .sheet__body form > p { color: var(--ink-2); margin-bottom: 16px; max-width: 38ch; }
.sheet__foot { padding: 8px var(--pad) calc(8px + var(--safe-b)); border-top: 1px solid var(--line-2); }
.sheet--short .sheet__body { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field input {
  display: block; width: 100%; height: 48px; margin-top: 4px; padding: 0 12px;
  font: 400 16px/24px var(--font); font-stretch: 100%; letter-spacing: 0; text-transform: none;
  color: var(--ink); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 2px;
  font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.field-row { display: grid; grid-template-columns: 1fr 80px 64px; gap: 8px; }

.summary { border-top: 1px solid var(--line-2); margin-top: 8px; }
.summary div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.summary div:last-child { color: var(--ink); font-weight: 700; }

/* ---------- the route: checkout drawn as five waypoints ---------- */
.route { list-style: none; margin: 16px 0 24px; }
.route li {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center;
  min-height: 56px; padding-left: 40px; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  transition: color var(--ease);
}
.route li::before {            /* the leg leading down to the next waypoint */
  content: ""; position: absolute; left: 11px; top: 50%; width: 2px; height: 100%;
  background: var(--line-2); transition: background-color var(--ease);
}
.route li:last-child::before { display: none; }
.route li::after {             /* the waypoint marker */
  content: ""; position: absolute; left: 6px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: var(--bg); border: 2px solid var(--line-2); border-radius: 1px;
  transition: background-color var(--ease), border-color var(--ease);
}
.route__name { font-weight: 600; }
.route__time { color: inherit; }
.route li.is-active { color: var(--ink); }
.route li.is-active::after { border-color: var(--accent); }
.route li.is-done { color: var(--ink-2); }
.route li.is-done::before { background: var(--accent); }
.route li.is-done::after { background: var(--accent); border-color: var(--accent); }
.route li.is-failed { color: var(--fail); }
.route li.is-failed::after { background: var(--fail); border-color: var(--fail); transform: rotate(45deg); }
.route li.is-failed::before {  /* the route breaks here */
  background: repeating-linear-gradient(to bottom, var(--line-2) 0 4px, transparent 4px 8px);
}

.result h3 { font-size: 28px; line-height: 32px; font-stretch: 108%; letter-spacing: -0.02em; margin-bottom: 8px; }
.result p { color: var(--ink-2); max-width: 36ch; }
.result--fail h3 { color: var(--fail); }
.meta {
  margin: 16px 0; padding: 8px 12px; background: var(--bg-2); border-left: 2px solid var(--fail);
  font: 500 13px/20px var(--font); font-stretch: 85%; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.pdnote { color: var(--ink) !important; font-weight: 600; }
.pdnote.is-fail { color: var(--fail) !important; }

/* ---------- ops console ---------- */
.ops__sec { margin: 0 calc(var(--pad) * -1) 32px; }
.ops__sec > :not(.rule) { margin-left: var(--pad); margin-right: var(--pad); }
.ops__sec > .rule { margin-bottom: 16px; }
.ops__sec:first-child > .rule { margin-top: -16px; border-top: 0; }
.ops__impact { color: var(--ink-2); margin-bottom: 16px; max-width: 38ch; }
#incident-count { font-variant-numeric: tabular-nums; color: var(--ink-3); }
#incident-count.is-hot { color: var(--fail); }

.cascade { list-style: none; margin-top: 16px; border-top: 1px solid var(--line); }
.cascade li {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 0 8px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink-3);
  transition: color var(--ease);
}
.cascade__t, .cascade__sev { color: inherit; }
.cascade__sum { font-size: 13px; line-height: 16px; }
.cascade__svc { display: block; font-weight: 600; }
.cascade li.is-sent { color: var(--ink); }
.cascade li.is-sent .cascade__t { color: var(--accent); }
.cascade li.is-fail { color: var(--fail); }

.log { list-style: none; }
.log li { display: grid; grid-template-columns: 64px 64px 1fr; gap: 0 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 16px; overflow-wrap: anywhere; }
.log time { color: var(--ink-3); }
.log__kind { color: var(--ink); }
.log__kind--error { color: var(--fail); }
.log__kind--trigger { color: var(--accent); }
.log__empty { display: block !important; color: var(--ink-3); }

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