/* COBBER — cassette-future skin, aligned to Cassette Future Magazine's design
   language: Inter body, Zen Kaku Gothic New display, cassette-blue / NASA-orange
   / yellow accents, tri-color divider, subtle CRT scanlines + film grain.
   Dark by default — it's a CRT; there is no light mode. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Zen+Kaku+Gothic+New:wght@400;700;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232d;
  --text: #e6e6e6;
  --text-light: #8b98a5;
  --border: #2a2f38;

  --cassette-blue: #4a7ab5;
  --cassette-navy: #0d2137;
  --nasa-orange: #e85d04;
  --nasa-gold: #f48c06;
  --nasa-yellow: #faa307;
  --cassette-yellow: #ffd000;

  --font-en: 'Inter', system-ui, sans-serif;
  --font-jp: 'Zen Kaku Gothic New', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 15px;
  line-height: 1.5;
}

/* CRT scanlines + film grain — analog tech meets space age (from the magazine). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  opacity: 0.35;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

.hidden { display: none !important; }

/* ── Masthead ─────────────────────────────────────────────────────── */
.masthead {
  padding: var(--space-lg) var(--space-lg) 0;
  text-align: center;
}
.masthead h1 {
  font-family: var(--font-jp);
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 0.14em;
  margin: 0;
  color: var(--text);
  text-shadow: 0 0 18px rgba(232, 93, 4, 0.25);
}
.masthead .sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--nasa-orange);
  margin-top: 0.4rem;
}

/* Tri-color divider — the magazine's blue / orange / yellow signature. */
.tricolor {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: var(--space-md) 0 0;
}
.tricolor span { height: 2px; width: 100%; display: block; }
.tricolor .b { background: var(--cassette-blue); box-shadow: 0 0 8px rgba(74, 122, 181, 0.5); }
.tricolor .o { background: var(--nasa-orange); box-shadow: 0 0 8px rgba(232, 93, 4, 0.5); }
.tricolor .y { background: var(--cassette-yellow); box-shadow: 0 0 8px rgba(255, 208, 0, 0.5); }

/* ── Shared shell ─────────────────────────────────────────────────── */
main {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* ── Airlock ──────────────────────────────────────────────────────── */
#airlock {
  max-width: 26rem;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-lg);
  box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.08), 0 24px 60px rgba(0, 0, 0, 0.5);
}
#airlock pre {
  font-family: var(--font-mono);
  color: var(--nasa-gold);
  font-size: 0.72rem;
  line-height: 1.6;
  margin: 0 0 var(--space-md);
  text-shadow: 0 0 8px rgba(244, 140, 6, 0.4);
}
#loginForm { display: flex; flex-direction: column; gap: var(--space-sm); }

input[type='text'], input:not([type]), input[type='password'] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
input:focus { outline: none; border-color: var(--nasa-orange); box-shadow: 0 0 0 2px rgba(232, 93, 4, 0.2); }

/* ── Buttons: chunky physical keys ────────────────────────────────── */
button {
  font-family: var(--font-jp);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a1206;
  background: linear-gradient(180deg, var(--nasa-yellow), var(--nasa-orange));
  border: none;
  border-radius: 4px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #a5410a, 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #a5410a, 0 2px 4px rgba(0, 0, 0, 0.4); }

.err { color: var(--nasa-orange); font-family: var(--font-mono); font-size: 0.8rem; min-height: 1.2em; margin-top: var(--space-sm); }

/* ── The House ────────────────────────────────────────────────────── */
#status {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cassette-yellow);
  margin-bottom: var(--space-sm);
}
#badgeSetup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--nasa-orange);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-light);
}
#badgeSetup input { width: auto; display: inline-block; padding: 0.3rem; }
#badgeSetup input[type='color'] { padding: 0; height: 1.8rem; width: 2.4rem; vertical-align: middle; }

#log {
  height: 58vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.86rem;
}
#log > div { padding: 0.15rem 0; }
#log .msg .who { color: var(--nasa-gold); font-weight: 500; }
#log .msg .t { color: var(--text-light); font-size: 0.72rem; }
#log .sys { color: var(--cassette-blue); font-style: italic; }
#log .sys small { color: var(--text-light); }
#log .unknown { color: var(--nasa-orange); }

/* ── Composer: tape-recorder console ──────────────────────────────── */
#composer {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-sm);
}
#composer input { flex: 1; }
#composer button {
  /* the big red REC key */
  background: linear-gradient(180deg, #ff5a3c, #c0392b);
  color: #fff;
  box-shadow: 0 3px 0 #7d1c12, 0 4px 8px rgba(0, 0, 0, 0.4);
  min-width: 5.5rem;
}
#composer button:active { box-shadow: 0 1px 0 #7d1c12, 0 2px 4px rgba(0, 0, 0, 0.4); }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }

/* ── Three-panel House ────────────────────────────────────────────── */
#house { max-width: 72rem; margin: 0 auto; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.panel-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* TOP — Crew Manifest roster of badge tiles */
#manifest { margin-bottom: var(--space-md); }
#roster { display: flex; flex-wrap: wrap; gap: var(--space-sm); padding: 0.75rem; min-height: 3.4rem; }
#roster .empty { color: var(--text-light); font-family: var(--font-mono); font-size: 0.8rem; }
.tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.6rem 0.35rem 0.5rem;
}
.tile .lamp {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; border: 1px solid var(--text-light);
}
.tile .lamp.on { background: var(--cassette-yellow); border-color: var(--cassette-yellow); box-shadow: 0 0 6px var(--cassette-yellow); }
.tile .badge {
  display: inline-grid; place-items: center;
  width: 1.9rem; height: 1.9rem; border-radius: 3px;
  font-family: var(--font-jp); font-weight: 700; font-size: 0.72rem;
  color: #12100c; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.tile .name { font-weight: 500; font-size: 0.85rem; }
.tile .rank {
  font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-light);
}

/* The deck row: channels | viewport | directory */
.decks { display: grid; grid-template-columns: 12rem 1fr 12rem; gap: var(--space-md); }
.center { display: flex; flex-direction: column; min-width: 0; }

#channels, #servers { list-style: none; margin: 0; padding: 0.4rem; }
#channels li, #servers li {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-light);
}
#channels li:hover { background: var(--surface-2); color: var(--text); }
#channels li.active {
  background: var(--cassette-navy);
  color: var(--cassette-yellow);
  border-left: 3px solid var(--nasa-orange);
}
#servers li { cursor: default; }
#servers li.active { color: var(--text); border-left: 3px solid var(--cassette-blue); }

#log { flex: 1; height: auto; min-height: 40vh; }

/* Unread indicator on a deck */
#channels li { display: flex; align-items: center; justify-content: space-between; }
.unread {
  background: var(--nasa-orange);
  color: #12100c;
  font-family: var(--font-jp);
  font-weight: 700;
  font-size: 0.62rem;
  min-width: 1.1rem; height: 1.1rem;
  border-radius: 999px;
  display: inline-grid; place-items: center;
  padding: 0 0.25rem;
}

/* Center bar: status + logout/manage */
.center-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.bar-actions { display: flex; gap: 0.4rem; }

/* Ghost buttons — flat, secondary (not the chunky orange keys) */
button.ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  box-shadow: none;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: none;
  padding: 0.3rem 0.6rem;
}
button.ghost:hover { color: var(--text); border-color: var(--text-light); filter: none; }
button.ghost:active { transform: none; }
button.ghost.danger { color: var(--nasa-orange); border-color: rgba(232, 93, 4, 0.4); }
button.ghost.danger:hover { border-color: var(--nasa-orange); }
button.ghost:disabled { opacity: 0.35; cursor: not-allowed; }

/* Admin panel */
#admin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cassette-yellow);
  border-radius: 6px;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-md);
}
.admin-sec h4 {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cassette-yellow);
  margin: 0 0 0.5rem;
}
.admin-sec form { display: flex; gap: 0.4rem; margin-top: 0.4rem; flex-wrap: wrap; }
.admin-sec input, .admin-sec select {
  flex: 1; min-width: 6rem;
  padding: 0.4rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: var(--font-mono); font-size: 0.8rem;
}
.admin-sec form button { padding: 0.4rem 0.7rem; font-size: 0.72rem; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.8rem;
  padding: 0.3rem 0; border-bottom: 1px solid var(--border);
}
.admin-row em { color: var(--text-light); font-style: normal; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; }
.mint-out { font-family: var(--font-mono); font-size: 0.76rem; margin-top: 0.5rem; color: var(--text-light); word-break: break-all; }
.mint-out code { color: var(--cassette-yellow); }

/* Voice room */
.voice-box { border-top: 1px solid var(--border); margin-top: 0.4rem; }
.voice-box .panel-label { border-bottom: none; color: var(--cassette-blue); }
.voice-roster { padding: 0 0.6rem 0.4rem; }
.voice-roster .vrow {
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0.2rem 0; display: flex; align-items: center; gap: 0.35rem;
}
.voice-roster .vrow em { color: var(--text-light); font-style: normal; }
.voice-roster .vmic { font-size: 0.7rem; }
.voice-roster .empty { color: var(--text-light); font-family: var(--font-mono); font-size: 0.72rem; }
.voice-controls { display: flex; gap: 0.35rem; padding: 0 0.6rem 0.6rem; flex-wrap: wrap; }
.voice-controls button { flex: 1; min-width: 5rem; }

@media (max-width: 720px) {
  .decks { grid-template-columns: 1fr; }
  #comms, #directory { order: 2; }
  .center { order: 1; }
}
