/* ============================================================================
   GHOSTSIG theme
   ----------------------------------------------------------------------------
   Every visual decision lives in this file. app.js sets classes and text only,
   never inline styles and never a colour, so swapping the design means editing
   this file and nothing else.

   Deliberately single-theme. A neon page commits to one visual world, so there
   is no prefers-color-scheme block, but every colour, including the body
   ground, is painted explicitly so the page holds anywhere.

   References, one signature move each:
     Radicle:  border-radius 0, dashed borders, mono everything
     Aztec:    fragmented letter-spacing on the wordmark, dot-matrix labels
     Neon:     saturated triad, glow reserved for live values
   ========================================================================= */

:root {
  /* ground, violet-biased rather than neutral charcoal */
  --ink:      #0A0710;
  --panel:    #120B1E;
  --well:     #1A1030;
  --line:     #3A2A5C;
  --dot:      rgba(168, 85, 247, 0.13);

  /* accent */
  --magenta:  #FF2E88;
  --violet:   #A855F7;

  /* semantic, kept separate from the accent hue */
  --lime:     #C8FF00;
  --amber:    #FFB627;
  --red:      #FF4D5E;

  --text:     #EDE6FF;
  --dim:      #8B7BA8;

  --data:  'Anonymous Pro', ui-monospace, SFMono-Regular, Menlo, monospace;
  --micro: 'Silkscreen', 'Anonymous Pro', ui-monospace, monospace;

  --gutter: clamp(1rem, 4vw, 1.75rem);
  --measure: 46rem;
  --dock-bar: 2.5rem;

  --glow-magenta: 0 0 18px rgba(255, 46, 136, 0.40);
  --glow-lime:    0 0 26px rgba(200, 255, 0, 0.28);
  --speed: 0.22s;
}

/* ── reset ────────────────────────────────────────────────────────────── */

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

/* every surface below sets `display`, which would otherwise beat [hidden] */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  padding: clamp(2rem, 7vw, 4rem) var(--gutter) calc(var(--dock-bar) + 3rem);
  background-color: var(--ink);
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0);
  background-size: 22px 22px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--data);
  font-size: 15px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

main {
  max-width: var(--measure);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* fine grain over everything, static */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
}

/* ── type primitives ──────────────────────────────────────────────────── */

.micro {
  font-family: var(--micro);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  line-height: 1;
}

em { font-style: italic; color: var(--violet); }
strong { font-weight: 700; color: var(--text); }

/* ── masthead ─────────────────────────────────────────────────────────── */

.masthead { display: flex; flex-direction: column; gap: 0.5rem; }

/* mark and wordmark as one lockup, the mark at roughly cap height */
.lockup { display: flex; align-items: center; gap: 0.7rem; }
.mark { width: auto; height: 0.86em; font-size: clamp(1.9rem, 7vw, 2.9rem); }

/* Aztec's signature: irregular tracking that fragments the wordmark.
   Used exactly once on the page. */
.wordmark {
  margin: 0;
  font-size: clamp(1.9rem, 7vw, 2.9rem);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  text-wrap: balance;
}
/* GHOST tight, SIG open and magenta: the two halves read as one word while
   the tracking shift still fragments it the way the reference does. */
.wordmark .w-a { letter-spacing: -0.03em; color: var(--text); }
.wordmark .w-b { letter-spacing: 0.14em; color: var(--magenta); padding-left: 0.12em; }

.tagline { margin: 0; color: var(--dim); font-size: 0.9rem; }

/* ── surfaces ─────────────────────────────────────────────────────────── */

.panel,
.card {
  border: 1px dashed var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card { gap: 0.85rem; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--line);
}
.head-id { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; }
.card-head #acct-name { color: var(--text); }
.card-head #acct-name:empty { display: none; }

/* the address is the account's real identity, so it sits in the title row */
.addr-short { font-size: 0.72rem; color: var(--violet); }

.addr {
  margin: 0;
  color: var(--violet);
  font-size: 0.82rem;
  word-break: break-all;
}

.balance {
  display: block;
  margin: 0.6rem 0 0;
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  color: var(--lime);
  text-shadow: var(--glow-lime);
  word-break: break-all;
}
.balance.is-live { animation: pulse 0.6s ease-out; }

/* no balance yet, so stay quiet rather than glowing an empty placeholder */
.balance.is-empty {
  font-size: 1.4rem;
  color: var(--dim);
  text-shadow: none;
}

.meta {
  margin: 0 0 0.4rem;
  color: var(--dim);
  font-size: 0.8rem;
}
.meta .sep { color: var(--line); padding-inline: 0.4rem; }
.meta .btn.ghost { font-size: 0.8rem; padding: 0; }

/* ── fields ───────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 0.4rem; }
/* a ghost button inside a field is an aside, not a full-width control */
.field > .btn.ghost { align-self: flex-start; }

input {
  font: inherit;
  font-size: 0.85rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 0;
  background: var(--well);
  color: var(--text);
}
input::placeholder { color: var(--dim); opacity: 0.7; }

/* solid border marks focus, so no colour change is needed */
input:focus-visible {
  outline: none;
  border-style: solid;
  border-color: var(--magenta);
}

.well-row { display: flex; align-items: stretch; }
.well-row input { border-right: none; }
.well-row .unit {
  display: flex;
  align-items: center;
  padding-inline: 0.75rem;
  border: 1px dashed var(--line);
  background: var(--well);
  color: var(--violet);
}

/* ── buttons ──────────────────────────────────────────────────────────── */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.head-actions { display: flex; align-items: center; gap: 0.9rem; }

.btn {
  font-family: var(--data);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: transform var(--speed), box-shadow var(--speed),
              border-color var(--speed), color var(--speed);
}
.btn:hover:not(:disabled) {
  border-color: var(--violet);
  color: var(--violet);
  transform: translateY(-1px);
}
.btn:focus-visible {
  outline: 2px solid var(--magenta);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--magenta);
  border-color: var(--magenta);
  color: var(--ink);
}
.btn.primary:hover:not(:disabled) {
  color: var(--ink);
  box-shadow: var(--glow-magenta);
  transform: translateY(-1px);
}

.btn.ghost {
  border-color: transparent;
  border-bottom: 1px dashed var(--line);
  padding: 0.3rem 0.2rem;
  font-weight: 400;
  color: var(--dim);
}
.btn.ghost:hover:not(:disabled) {
  color: var(--violet);
  border-bottom-color: var(--violet);
  transform: none;
}

.note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--amber);
  border-left: 2px solid var(--amber);
  padding-left: 0.7rem;
}

/* ── derivation chain ─────────────────────────────────────────────────── */

.chain { display: flex; flex-direction: column; gap: 0.9rem; }

.nodes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* the rail the nodes sit on */
.nodes::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 10%;
  right: 10%;
  border-top: 1px dashed var(--line);
}

.node { min-width: 0; }

.node-btn {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  padding: 0 0.25rem;
  background: none;
  border: none;
  border-radius: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: center;
}
.node-btn:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

.dot {
  width: 11px;
  height: 11px;
  border: 1px solid var(--line);
  background: var(--ink);
  transform: rotate(45deg);
  transition: background var(--speed), border-color var(--speed), box-shadow var(--speed);
}

.node-label { font-size: 0.5rem; }

.node-val {
  font-size: 0.68rem;
  color: var(--dim);
  width: 100%;
  overflow-wrap: anywhere;
}

/* lit by app.js as each stage is derived */
.node.is-live .dot {
  background: var(--violet);
  border-color: var(--violet);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.7);
}
.node.is-live .node-label { color: var(--violet); }
.node.is-live .node-val { color: var(--text); }
.node.is-open .node-val { color: var(--lime); }

/* ── network switch ──────────────────────────────────────────────────── */

.netswitch { display: flex; }

.net {
  font-family: var(--micro);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 0.5rem;
  border: 1px dashed var(--line);
  border-right-width: 0;
  border-radius: 0;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color var(--speed), background var(--speed);
}
.net:last-child { border-right-width: 1px; }
.net:hover { color: var(--violet); }
.net[aria-pressed='true'] {
  background: var(--magenta);
  border-style: solid;
  border-color: var(--magenta);
  color: var(--ink);
}
.net:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

/* ── tabs ─────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 1.1rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.6rem;
}

.tab {
  font-family: var(--micro);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.2rem 0;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
  transition: color var(--speed), border-color var(--speed);
}
.tab:hover { color: var(--violet); }
.tab[aria-selected='true'] { color: var(--magenta); border-bottom-color: var(--magenta); }
.tab:focus-visible { outline: 2px solid var(--magenta); outline-offset: 3px; }

.tabpanel { display: flex; flex-direction: column; gap: 0.85rem; }

/* ── receive ──────────────────────────────────────────────────────────── */

.receive {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1.1rem;
  align-items: start;
}

/* uqr renders with currentColor, so the palette lives here and nowhere else */
.qr {
  color: var(--lime);
  border: 1px dashed var(--line);
  padding: 0.5rem;
  line-height: 0;
}
.qr svg { width: 100%; height: auto; display: block; }
.qr:empty { display: none; }

.receive-side { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }
.receive-side .actions { flex-direction: column; align-items: flex-start; }

/* ── raw ──────────────────────────────────────────────────────────────── */

textarea {
  font-family: var(--data);
  font-size: 0.76rem;
  line-height: 1.5;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: 0;
  background: var(--well);
  color: var(--text);
  resize: vertical;
}
textarea::placeholder { color: var(--dim); opacity: 0.7; }
textarea:focus-visible { outline: none; border-style: solid; border-color: var(--magenta); }

.raw-preview {
  margin: 0;
  font-size: 0.72rem;
  color: var(--dim);
  border-left: 2px solid var(--line);
  padding-left: 0.7rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.raw-preview[data-mode='json'] { border-left-color: var(--violet); }
.raw-preview[data-mode='hex']  { border-left-color: var(--lime); }
.raw-preview[data-mode='error'] { border-left-color: var(--red); color: var(--red); }

/* ── about ────────────────────────────────────────────────────────────── */

.about {
  border-top: 1px dashed var(--line);
  padding-top: 1rem;
}
.about > summary {
  cursor: pointer;
  color: var(--dim);
  list-style: none;
  transition: color var(--speed);
}
.about > summary::-webkit-details-marker { display: none; }
.about > summary::before { content: '+ '; color: var(--magenta); }
.about[open] > summary::before { content: '- '; }
.about > summary:hover { color: var(--violet); }
.about > summary:focus-visible { outline: 2px solid var(--magenta); outline-offset: 3px; }

.about-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1rem;
  max-width: 60ch;
}
.about-body p { margin: 0; font-size: 0.78rem; line-height: 1.75; color: var(--dim); }
.about-body .formula {
  color: var(--violet);
  font-size: 0.72rem;
  border-left: 2px solid var(--line);
  padding-left: 0.9rem;
  overflow-wrap: anywhere;
}

/* ── console dock ─────────────────────────────────────────────────────── */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--panel);
  border-top: 1px dashed var(--line);
}

.dock-bar {
  width: 100%;
  height: var(--dock-bar);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-inline: var(--gutter);
  background: none;
  border: none;
  border-radius: 0;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  text-align: left;
}
.dock-bar:hover .dock-title { color: var(--violet); }
.dock-bar:focus-visible { outline: 2px solid var(--magenta); outline-offset: -2px; }

.dock-title { color: var(--magenta); }
.dock-count { color: var(--dim); }

.dock-latest {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cursor {
  flex: none;
  width: 7px;
  height: 1rem;
  background: var(--lime);
  animation: blink 1.1s steps(1) infinite;
}

.dock-body {
  height: 0;
  overflow: hidden;
  transition: height var(--speed) ease-out;
}
.dock[data-open="true"] .dock-body { height: min(45vh, 24rem); }
.dock[data-open="true"] .dock-title::before { content: none; }

.dock-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem var(--gutter);
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}

.lines {
  height: calc(min(45vh, 24rem) - 2.5rem);
  overflow-y: auto;
  padding: 0.75rem var(--gutter) 1rem;
  font-size: 0.76rem;
  line-height: 1.75;
}

.line {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.6rem;
  animation: rise var(--speed) ease-out;
}
.line .ts { color: var(--dim); }
.line .caret { color: var(--magenta); }
.line .msg { min-width: 0; overflow-wrap: anywhere; color: var(--text); }

.line[data-level="ok"]   .msg { color: var(--lime); }
.line[data-level="warn"] .msg { color: var(--amber); }
.line[data-level="warn"] .caret { color: var(--amber); }
.line[data-level="err"]  .msg { color: var(--red); }
.line[data-level="err"]  .caret { color: var(--red); }
.line[data-level="dim"]  .msg { color: var(--dim); }

/* click-to-expand hex */
.hex {
  font: inherit;
  padding: 0;
  border: none;
  border-bottom: 1px dashed var(--line);
  background: none;
  color: var(--violet);
  cursor: pointer;
  overflow-wrap: anywhere;
  text-align: left;
}
.hex:hover { border-bottom-color: var(--violet); color: var(--lime); }
.hex:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

.line a { color: var(--violet); text-decoration: none; border-bottom: 1px dashed var(--line); }
.line a:hover { color: var(--lime); border-bottom-color: var(--lime); }

/* ── motion ───────────────────────────────────────────────────────────── */

@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@keyframes pulse {
  0%   { text-shadow: var(--glow-lime); }
  40%  { text-shadow: 0 0 40px rgba(200, 255, 0, 0.75); }
  100% { text-shadow: var(--glow-lime); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

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

/* ── narrow ───────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .nodes { grid-template-columns: 1fr; gap: 0.9rem; }
  .nodes::before {
    top: 5px;
    bottom: 5px;
    left: 5px;
    right: auto;
    border-top: none;
    border-left: 1px dashed var(--line);
  }
  .node-btn {
    grid-template-columns: 11px auto 1fr;
    justify-items: start;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
  }
  .node-val { text-align: left; }
  .dock-latest { font-size: 0.72rem; }
  .receive { grid-template-columns: 1fr; }
  .qr { max-width: 11rem; }
  .tabs { gap: 0.9rem; }
}
