/* Shannon Test — frontend styling.
   One file, no build step, no framework. Readable top to bottom. */

:root {
  --bg:        #0f1117;
  --panel:     #171a23;
  --panel-2:   #1d212c;
  --line:      #2a2f3d;
  --ink:       #e8eaf0;
  --ink-dim:   #9aa2b4;
  --front:     #4fc3f7;   /* browser side  — blue  */
  --back:      #a5d6a7;   /* server side   — green */
  --accent:    #ffb74d;
  --danger:    #ef5350;
  --radius:    14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb; --panel: #ffffff; --panel-2: #f0f2f7; --line: #dfe3ec;
    --ink: #1a1d26; --ink-dim: #5b6376;
    --front: #0277bd; --back: #2e7d32; --accent: #b26a00;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

code { font-family: var(--mono); font-size: .88em; }

/* ── Masthead ───────────────────────────────────────────────── */

.masthead {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3.5rem 0 2.5rem;
  text-align: center;
}
.eyebrow {
  margin: 0 0 .75rem;
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.masthead h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.15;
  letter-spacing: -.02em;
}
.lede { margin: 0; color: var(--ink-dim); font-size: 1.05rem; }
.lede strong { color: var(--ink); }

/* ── The two halves + the wire between them ─────────────────── */

.model {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
  max-width: 62rem;
  margin: 0 auto 3.5rem;
}
.half {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.half--front { border-top: 3px solid var(--front); }
.half--back  { border-top: 3px solid var(--back);  }
.half h2 { margin: .35rem 0 .6rem; font-size: 1.35rem; }
.half p  { margin: 0; color: var(--ink-dim); font-size: .95rem; }
.half em { color: var(--ink); font-style: normal; font-weight: 600; }
.half__badge {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* The animated connection. Fires a pulse each time a request goes out. */
.wire {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
}
.wire::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--front), var(--back));
  opacity: .5;
}
.wire__label {
  position: relative;
  margin-bottom: 1.6rem;
  padding: .15rem .5rem;
  background: var(--bg);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--ink-dim);
}
.wire__pulse {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px; height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}
/* Out to the server... */
.wire.is-sending .wire__pulse {
  animation: travel-out .45s ease-in forwards;
}
/* ...and back with the answer. */
.wire.is-receiving .wire__pulse {
  animation: travel-back .45s ease-out forwards;
}
@keyframes travel-out {
  from { opacity: 1; left: 0;    background: var(--front); }
  to   { opacity: 1; left: 100%; background: var(--back);  }
}
@keyframes travel-back {
  from { opacity: 1; left: 100%; background: var(--back);  }
  to   { opacity: 0; left: 0;    background: var(--front); }
}

@media (prefers-reduced-motion: reduce) {
  .wire__pulse { animation: none !important; }
}

/* ── Demo cards ─────────────────────────────────────────────── */

.demos {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 62rem;
  margin: 0 auto;
}
.demo {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.demo__head {
  display: flex;
  gap: 1rem;
  padding: 1.4rem 1.5rem 0;
}
.demo__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--accent);
}
.demo__head h3 { margin: .1rem 0 .35rem; font-size: 1.2rem; }
.demo__head p  { margin: 0; color: var(--ink-dim); font-size: .95rem; }
.demo__head strong { color: var(--ink); }

.demo__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 1.25rem;
  padding: 1.25rem 1.5rem 1.5rem;
}
.demo__action { display: flex; flex-direction: column; gap: .6rem; }
.demo__action form { display: flex; flex-direction: column; gap: .45rem; }

label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-dim);
}
input[type=text], textarea {
  width: 100%;
  padding: .6rem .7rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  resize: vertical;
}
input[type=text]:focus, textarea:focus {
  outline: 2px solid var(--front);
  outline-offset: 1px;
  border-color: transparent;
}

.btn {
  align-self: flex-start;
  margin-top: .25rem;
  padding: .6rem 1.1rem;
  background: var(--front);
  border: 0;
  border-radius: 9px;
  color: #06202b;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }

.hint { margin: 0; font-size: .82rem; color: var(--ink-dim); }
.hint code {
  padding: .1rem .3rem;
  background: var(--panel-2);
  border-radius: 5px;
}

/* Where the server's answer lands. */
.demo__out {
  min-height: 8rem;
  padding: 1rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--back);
  border-radius: 10px;
  font-size: .93rem;
}
.placeholder { margin: 0; color: var(--ink-dim); font-style: italic; }

.answer { margin: 0; }
.answer__lead {
  margin: 0 0 .75rem;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--back);
}
.answer__grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .35rem .9rem;
  margin: 0;
  font-size: .88rem;
}
.answer__grid dt { color: var(--ink-dim); }
.answer__grid dd {
  margin: 0;
  font-family: var(--mono);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.answer__err { margin: 0; color: var(--danger); font-weight: 600; }

/* The guestbook list. */
.notes { margin: 0; padding: 0; list-style: none; display: grid; gap: .6rem; }
.notes li {
  padding: .6rem .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.notes .note__meta {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .2rem;
  font-size: .76rem;
  color: var(--ink-dim);
}
.notes .note__who  { font-weight: 700; color: var(--back); }
.notes .note__text { overflow-wrap: anywhere; }
.notes__count {
  margin: 0 0 .6rem;
  font-size: .8rem;
  color: var(--ink-dim);
}
.notes--scroll { max-height: 20rem; overflow-y: auto; }

/* ── Code comparison ────────────────────────────────────────── */

.code { border-top: 1px solid var(--line); }
.code summary {
  padding: .85rem 1.5rem;
  color: var(--ink-dim);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.code summary:hover { color: var(--ink); }
.code__pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 1.5rem;
}
.code__side h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
  margin: 0 0 .5rem;
  font-size: .9rem;
}
.code__side h4 span {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 400;
  color: var(--ink-dim);
}
.code__side:first-child h4 { color: var(--front); }
.code__side:last-child  h4 { color: var(--back);  }
.code pre {
  margin: 0;
  padding: .9rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  font-size: .8rem;
  line-height: 1.6;
}
.code pre code { font-family: var(--mono); }

/* ── Wire log ───────────────────────────────────────────────── */

.log {
  max-width: 62rem;
  margin: 3.5rem auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.log__head h2 { margin: 0 0 .35rem; font-size: 1.25rem; }
.log__head p  { margin: 0 0 1.25rem; color: var(--ink-dim); font-size: .92rem; }

.entry {
  margin-bottom: .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: .8rem;
}
.entry__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .55rem .8rem;
  background: var(--panel-2);
}
.entry__method {
  padding: .1rem .45rem;
  border-radius: 5px;
  background: var(--front);
  color: #06202b;
  font-weight: 700;
  font-size: .72rem;
}
.entry__method[data-m="POST"] { background: var(--accent); }
.entry__url { color: var(--ink); overflow-wrap: anywhere; }
.entry__status { margin-left: auto; font-weight: 700; color: var(--back); }
.entry__status[data-bad="1"] { color: var(--danger); }
.entry__ms { color: var(--ink-dim); }

.entry__cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.entry__col { padding: .7rem .8rem; background: var(--panel); }
.entry__col h5 {
  margin: 0 0 .4rem;
  font-family: var(--sans);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.entry__col pre {
  margin: 0;
  max-height: 13rem;
  overflow: auto;
  font-size: .76rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Footer ─────────────────────────────────────────────────── */

.foot {
  max-width: 62rem;
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: .88rem;
  text-align: center;
}
.foot p { margin: 0 0 .5rem; }
.foot__note { font-size: .82rem; opacity: .85; }

/* ── Narrow screens ─────────────────────────────────────────── */

@media (max-width: 800px) {
  .model { grid-template-columns: 1fr; }
  .wire { min-height: 4.5rem; }
  .wire::before { inset-inline: 25%; }
  .wire__label { margin-bottom: 0; }
  .demo__body,
  .code__pair,
  .entry__cols { grid-template-columns: minmax(0, 1fr); }
}
