/* ===========================================================================
   RELAY — styles
   Aesthetic: operations center at night.  Warm off-black, cream text,
   ember accent for alerts.  Fraunces for display serifs; IBM Plex Mono
   for everything technical.
   =========================================================================== */

:root {
  --bg: #0d0f12;
  --bg-raised: #141720;
  --bg-card: #171a23;
  --line: #262b38;
  --line-soft: #1d2130;

  --ink: #efe9df;        /* warm cream */
  --ink-dim: #a8a294;
  --ink-fade: #6c6659;

  --ember: #ff6b3d;      /* accent */
  --ember-dim: #b8492a;
  --ok: #7ec99a;
  --warn: #e6c65a;
  --off: #c75a4a;

  --display: "Fraunces", ui-serif, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 6px;
  --radius-lg: 10px;

  --pad-page: clamp(20px, 4vw, 48px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  /* Subtle vignette so the dark background has depth */
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(255, 107, 61, 0.08), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(126, 201, 154, 0.04), transparent 55%),
    var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Film grain overlay for texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 100;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: screen;
}

/* ----------------------------- Masthead ---------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--pad-page);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  color: var(--ember);
  font-size: 14px;
  animation: pulse 2.6s ease-in-out infinite;
}
.brand-name {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.35em;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.masthead-meta { display: inline-flex; gap: 8px; }
.meta-label { color: var(--ink-fade); }
.meta-value { color: var(--ink); }

/* ------------------------------- Layout ---------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 0;
  min-height: calc(100svh - 180px);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.control {
  padding: clamp(28px, 5vw, 56px) var(--pad-page);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

@media (max-width: 900px) {
  .control { border-right: 0; border-bottom: 1px solid var(--line-soft); }
}

/* ---------------------------- Display text ------------------------------- */

.h-display {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(42px, 5.5vw, 68px);
  line-height: 0.96;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

.h-display .italic {
  font-style: italic;
  color: var(--ember);
}

.h-display em {
  font-style: italic;
  color: var(--ink-dim);
  font-weight: 400;
}

.lede {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-dim);
  max-width: 42ch;
  margin: 0;
}

/* ------------------------------- Card ------------------------------------ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset,
              0 20px 40px -30px rgba(0,0,0,0.7);
}
.card.warn {
  border-color: #3a2d18;
  background: linear-gradient(180deg, #1b160e 0%, var(--bg-card) 100%);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-fade);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

.card-body {
  margin: 0;
  color: var(--ink-dim);
  font-size: 13px;
}
.card-body kbd {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink);
}

/* ---------------------------- Status -------------------------------------- */

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent);
}
.dot[data-state="ok"]   { background: var(--ok);    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot[data-state="warn"] { background: var(--warn);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.dot[data-state="off"]  { background: var(--off);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--off) 25%, transparent); }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 0 0 18px;
  font-size: 12px;
}
.kv dt { color: var(--ink-fade); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; align-self: center; }
.kv dd { color: var(--ink); margin: 0; text-align: right; word-break: break-all; }
.trunc { overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------- Button ------------------------------------- */

.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 18px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, color 160ms ease;
  width: 100%;
  min-height: 44px;
}
.btn:hover { border-color: var(--ink-dim); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--ember);
  color: #1a0f0a;
  border-color: var(--ember);
  font-weight: 600;
}
.btn.primary:hover { background: #ff815a; border-color: #ff815a; }
.btn.primary:disabled { background: var(--ember-dim); border-color: var(--ember-dim); }

.btn.ghost {
  width: auto;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
}

/* --------------------------- Feed column --------------------------------- */

.feed-col {
  padding: clamp(28px, 5vw, 56px) var(--pad-page);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.feed-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  margin: 0;
  color: var(--ink);
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-fade);
  font-size: 13px;
}
.empty-mark {
  font-family: var(--display);
  font-size: 48px;
  line-height: 1;
  color: var(--ember-dim);
  margin-bottom: 16px;
}
.empty code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 3px;
}
.hint { margin-top: 8px; font-size: 12px; }

/* ------------------------------ Note item -------------------------------- */

.note {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ember);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  animation: slide-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.note-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--ink-fade);
  margin-bottom: 8px;
  letter-spacing: 0.06em;
}
.note-app {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ember);
  font-weight: 600;
}
.note-head time { font-variant-numeric: tabular-nums; }

.note-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 6px;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.005em;
}
.note-body {
  margin: 0;
  color: var(--ink-dim);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------- Footer ---------------------------------- */

.foot {
  padding: 22px var(--pad-page);
  border-top: 1px solid var(--line-soft);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-fade);
  text-align: center;
}
