/* ============================================================
   Age of Heroes — main stylesheet
   Palette: brownstone amber, forest green, torchlight gold,
            harbour grey, night black, parchment cream
   ============================================================ */

:root {
  --night:       #0d0b08;
  --deep:        #1a1610;
  --stone:       #2c2418;
  --brownstone:  #5c4a2a;
  --amber:       #8b6914;
  --gold:        #c9943a;
  --torch:       #e8b84b;
  --parchment:   #f2e8cc;
  --cream:       #fdf6e3;
  --forest:      #2d4a1e;
  --moss:        #4a7c2f;
  --harbour:     #3a4a5c;
  --grey:        #8a9aaa;
  --muted:       #6b7a6a;

  --font-display: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-body:    Georgia, 'Times New Roman', serif;
  --font-mono:    'Courier New', Courier, monospace;

  --radius: 3px;
  --transition: 0.2s ease;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background-color: var(--night);
  color: var(--parchment);
  font-family: var(--font-body);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--torch); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: normal;
  letter-spacing: 0.03em;
  color: var(--torch);
  line-height: 1.25;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; margin-bottom: 0.6em; }
h3 { font-size: 1.3rem; margin-bottom: 0.4em; color: var(--gold); }

p { margin-bottom: 1em; }

hr {
  border: none;
  border-top: 1px solid var(--brownstone);
  margin: 2rem 0;
}

/* ---- Layout ---- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-content {
  padding: 3rem 0;
}

/* ---- Navigation ---- */
.site-nav {
  background: linear-gradient(180deg, var(--deep) 0%, var(--stone) 100%);
  border-bottom: 2px solid var(--brownstone);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--torch);
  letter-spacing: 0.06em;
}
.nav-brand:hover { color: var(--gold); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.2rem;
}

.nav-links a {
  display: block;
  padding: 0.3rem 0.8rem;
  color: var(--parchment);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--brownstone);
  color: var(--torch);
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.85rem;
}

.nav-auth .btn-login {
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  color: var(--torch);
  transition: background var(--transition);
}
.nav-auth .btn-login:hover { background: var(--brownstone); }

/* ---- Hero section ---- */
.hero {
  background: linear-gradient(170deg, var(--deep) 0%, #1c1a10 50%, var(--forest) 100%);
  border-bottom: 2px solid var(--brownstone);
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(201,148,58,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-size: 3.4rem;
  color: var(--torch);
  text-shadow: 0 0 40px rgba(232,184,75,0.3);
  margin-bottom: 0.3em;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--grey);
  font-style: italic;
  margin-bottom: 2rem;
}

.hero-connect {
  display: inline-block;
  background: var(--brownstone);
  border: 1px solid var(--amber);
  color: var(--torch);
  padding: 0.7rem 2rem;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.08em;
  border-radius: var(--radius);
  transition: background var(--transition), box-shadow var(--transition);
}
.hero-connect:hover {
  background: var(--amber);
  color: var(--night);
  box-shadow: 0 0 18px rgba(201,148,58,0.4);
}

.hero-connect code {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

/* ---- Section dividers ---- */
.section-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--brownstone);
}

/* ---- Cards ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 1.4rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
  border-color: var(--amber);
  box-shadow: 0 2px 16px rgba(139,105,20,0.15);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--torch);
  margin-bottom: 0.5rem;
}

.card-body {
  font-size: 0.9rem;
  color: var(--parchment);
  opacity: 0.85;
}

/* ---- Race cards ---- */
.race-stats {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.stat-tag {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  border: 1px solid var(--brownstone);
  color: var(--grey);
}
.stat-tag.pos { border-color: var(--moss); color: #8dc46a; }
.stat-tag.neg { border-color: #5c2a2a; color: #c47a6a; }

/* ---- Lore / world page ---- */
.lore-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}
@media (max-width: 720px) { .lore-section { grid-template-columns: 1fr; } }

.lore-block {
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.lore-block h3 {
  border-bottom: 1px solid var(--brownstone);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* ---- Docs ---- */
.docs-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 760px) { .docs-layout { grid-template-columns: 1fr; } }

.docs-sidebar {
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.docs-sidebar h4 {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 1rem 0 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--brownstone);
}
.docs-sidebar h4:first-child { margin-top: 0; }

.docs-sidebar ul { list-style: none; }
.docs-sidebar ul li a {
  display: block;
  padding: 0.2rem 0.4rem;
  font-size: 0.82rem;
  color: var(--parchment);
  opacity: 0.8;
  border-radius: 2px;
  transition: background var(--transition), opacity var(--transition);
}
.docs-sidebar ul li a:hover,
.docs-sidebar ul li a.active {
  background: var(--brownstone);
  opacity: 1;
  color: var(--torch);
}

.docs-content {
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 1.6rem 2rem;
}

.docs-content pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--parchment);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.docs-content pre a {
  color: var(--amber);
  text-decoration: none;
  border-bottom: 1px dotted var(--amber);
}
.docs-content pre a:hover {
  color: var(--parchment);
  border-bottom-style: solid;
}

.docs-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.docs-search input {
  flex: 1;
  background: var(--stone);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  color: var(--parchment);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.docs-search input:focus { outline: none; border-color: var(--amber); }
.docs-search button {
  background: var(--brownstone);
  border: 1px solid var(--amber);
  color: var(--torch);
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition);
}
.docs-search button:hover { background: var(--amber); color: var(--night); }

.search-results a {
  display: block;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--stone);
  font-size: 0.9rem;
}
.search-results a:last-child { border-bottom: none; }
.search-result-path { font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); }

/* ---- Online players ---- */
.online-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.online-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--moss);
  background: var(--deep);
  border: 1px solid var(--forest);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
}

.online-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.online-table th {
  font-family: var(--font-display);
  font-weight: normal;
  color: var(--gold);
  text-align: left;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--brownstone);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}
.online-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--stone);
  color: var(--parchment);
}
.online-table tr:last-child td { border-bottom: none; }
.online-table tr:hover td { background: var(--deep); }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss);
  margin-right: 0.4rem;
  box-shadow: 0 0 4px var(--moss);
}

/* ---- Chat ---- */
.chat-layout {
  display: grid;
  grid-template-rows: 1fr auto;
  height: calc(100vh - 130px);
  min-height: 400px;
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
}

.chat-messages {
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chat-msg {
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 0.15rem 0;
}
.chat-msg .msg-who {
  color: var(--torch);
  font-family: var(--font-display);
  margin-right: 0.4rem;
}
.chat-msg .msg-chan {
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  margin-right: 0.4rem;
}
.chat-msg.emote .msg-text { font-style: italic; color: var(--grey); }

.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--brownstone);
  background: var(--stone);
}
.chat-input-bar input {
  flex: 1;
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.chat-input-bar input:focus { outline: none; border-color: var(--amber); }
.chat-input-bar button {
  background: var(--brownstone);
  border: 1px solid var(--amber);
  color: var(--torch);
  padding: 0.45rem 1.2rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9rem;
  transition: background var(--transition);
}
.chat-input-bar button:hover { background: var(--amber); color: var(--night); }

.chat-channel-selector {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--brownstone);
  background: var(--stone);
}
.chat-channel-selector button {
  background: none;
  border: 1px solid var(--brownstone);
  color: var(--parchment);
  padding: 0.2rem 0.7rem;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background var(--transition), color var(--transition);
}
.chat-channel-selector button.active,
.chat-channel-selector button:hover {
  background: var(--brownstone);
  color: var(--torch);
  border-color: var(--amber);
}

/* ---- Login ---- */
.login-box {
  max-width: 400px;
  margin: 4rem auto;
  background: var(--deep);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 2rem 2.4rem;
}
.login-box h2 { text-align: center; margin-bottom: 1.5rem; }

.form-group {
  margin-bottom: 1.1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.form-group input {
  width: 100%;
  background: var(--stone);
  border: 1px solid var(--brownstone);
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: var(--amber); }

.btn-primary {
  width: 100%;
  background: var(--brownstone);
  border: 1px solid var(--amber);
  color: var(--torch);
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  transition: background var(--transition);
  margin-top: 0.5rem;
}
.btn-primary:hover { background: var(--amber); color: var(--night); }

.flash-error {
  background: rgba(92,42,42,0.5);
  border: 1px solid #7a3333;
  color: #e08a8a;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.flash-success {
  background: rgba(45,74,30,0.5);
  border: 1px solid var(--forest);
  color: #8dc46a;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--deep);
  border-top: 1px solid var(--brownstone);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--torch); }

/* ---- WS connection indicator ---- */
.ws-status {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
}
.ws-status.connected { color: #8dc46a; border: 1px solid var(--forest); }
.ws-status.disconnected { color: #c47a6a; border: 1px solid #5c2a2a; }
.ws-status.connecting { color: var(--gold); border: 1px solid var(--amber); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .hero-title { font-size: 2.2rem; }
  .nav-links { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}
