/* app.css — the shell around the player.
 *
 * The player ships its own visual language (player.css); this file styles only
 * what surrounds it — head, directory, forms — and deliberately borrows the
 * same warm-dark palette so the seam between shell and player is invisible.
 *
 * Phone-first: this site is read on a phone far more often than on a desktop,
 * so the base layout is the small one and the wide layout is the exception.
 */

:root {
  --ink: #f4efe8;
  --ink-dim: #a89e93;
  --ink-faint: #6f665d;
  --bg: #12100e;
  --bg-raised: #1b1815;
  --line: rgba(244, 239, 232, 0.10);
  --accent: #d8a657;
  --err: #e0796b;
  --ok: #8fbf7f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

/* --- head --- */

.site-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(0.9rem, 4vw, 2rem);
  padding-top: max(0.85rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(18, 16, 14, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* A spine, not a logo: two rules suggesting a book edge. */
.brand-mark {
  width: 12px;
  height: 18px;
  border-left: 3px solid var(--accent);
  border-right: 1px solid var(--ink-faint);
  border-radius: 1px;
}

.brand-dim { color: var(--ink-faint); font-weight: 400; }

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.9rem;
}
.nav-link:hover { color: var(--ink); }

.nav-who {
  color: var(--ink-faint);
  font-size: 0.82rem;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn, .btn {
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.34rem 0.9rem;
  cursor: pointer;
}
.nav-btn:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-quiet { background: none; color: var(--ink-faint); }

.signin-pending { color: var(--ink-faint); font-size: 0.85rem; }

/* --- layout --- */

.view {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.2rem, 5vw, 2.5rem) clamp(0.9rem, 4vw, 2rem) 3rem;
}

.page-title {
  font-size: clamp(1.6rem, 6vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
}

.page-sub { color: var(--ink-dim); margin: 0 0 1.8rem; }

.empty, .hint { color: var(--ink-faint); }
.hint { font-size: 0.85rem; margin: 0.35rem 0 1rem; }

.banner {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  color: var(--ink-dim);
  margin: 0 0 1.5rem;
}

/* --- directory --- */

.space-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.space-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}
.space-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #2a2521;
}

.avatar-blank {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
}

.space-meta { display: flex; flex-direction: column; min-width: 0; }
.space-name { font-weight: 600; }
.space-count { color: var(--ink-faint); font-size: 0.84rem; }

/* --- forms --- */

.form-page { max-width: 480px; }

.label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 1.1rem 0 0.35rem;
}

.field {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}
.field:focus { outline: none; border-color: var(--accent); }

.section {
  font-size: 1rem;
  margin: 2.2rem 0 0.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.form-msg { min-height: 1.2em; font-size: 0.85rem; color: var(--ink-faint); margin: 0.6rem 0 0; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--err); }

.allowlist { margin: 0.8rem 0; }
.allow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-faint); font-size: 0.8rem; }

.notfound .btn { margin-top: 1rem; display: inline-block; text-decoration: none; }

/* --- foot --- */

.site-foot {
  border-top: 1px solid var(--line);
  padding: 1rem clamp(0.9rem, 4vw, 2rem);
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  color: var(--ink-faint);
  font-size: 0.8rem;
}

/* The player mounts inside the shell's content column and brings its own
   chrome, so it gets breathing room rather than styling. */
#player-mount { margin-top: 0.5rem; }

/* --- phone layout for the embedded player ---
 *
 * Scoped to this site on purpose. player.css is shared with karagame and
 * brandonlandry.com, and its side-by-side chapter/transcript split is their
 * default too — changing it there would restyle two live sites nobody asked
 * me to touch. These overrides live in the one stylesheet only this site
 * loads, so the blast radius is exactly books.landry.bot.
 *
 * !important is required because the player sets `flex: 0 0 50%` inline on
 * both panels (it is drag-resizable, so the split is state, not style).
 */
@media (max-width: 620px) {
  /* Stack rather than split: 50% of a 390px screen is ~10 words per line in
     the transcript, which is the thing you are actually here to read. */
  #player-mount .content-area { flex-direction: column; }
  #player-mount .chapter-panel {
    flex: 0 0 auto !important;
    max-height: 34vh;
    border-bottom: 1px solid var(--line);
  }
  #player-mount .transcript-panel { flex: 1 1 auto !important; }
  /* The divider drags a horizontal split; with panels stacked it would resize
     the wrong axis, so it goes away rather than misleading. */
  #player-mount .panel-divider { display: none; }
  /* Reading mode still wins — it hides the chapter pane entirely. */
  #player-mount .player-view.reading-mode .chapter-panel { display: none; }
}

/* The shell already names the space above the player; the player's own
   library heading and back link would repeat it. */
#player-mount .player-view { padding-top: 0; }
#player-mount .back-btn { text-align: left; }
