*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #080d14;
  --surface:      #0e1520;
  --surface-2:    #131d2a;
  --border:       #1a2d42;
  --blue:         #3a9bd5;
  --blue-dark:    #1a5a8a;
  --blue-dim:     #1e4060;
  --gold:         #f0b040;
  --gold-dim:     #a07828;
  --magenta:      #b040b8;
  --magenta-bright: #d060d8;
  --white:        #e8eef5;
  --muted:        #6a8aaa;
  --text:         #c8daea;
  --radius:       8px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 13, 20, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.wordmark-main {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--blue);
}

.wordmark-sub {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ── Auth widget ──────────────────────────────────────── */
.auth-widget {
  display: flex;
  align-items: center;
}

.auth-loading {
  display: flex;
  align-items: center;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-loggedin,
.auth-loggedout {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.widget-avatar,
.widget-avatar-fallback {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--blue-dim);
  flex-shrink: 0;
}

.widget-avatar { object-fit: cover; }

.widget-avatar-fallback {
  background: var(--surface-2);
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-username {
  font-size: 0.85rem;
  color: var(--white);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.widget-logout:hover:not(:disabled) {
  border-color: #8a3030;
  color: #e07070;
}

.widget-signin {
  font-size: 0.85rem;
  color: var(--blue);
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--blue-dim);
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.widget-signin:hover {
  background: rgba(58, 155, 213, 0.1);
  border-color: var(--blue);
}

.widget-register {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.widget-register:hover { color: var(--white); }

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  max-width: 1100px;
  margin: 3rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero-image-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Broken image placeholder */
.hero-image.broken {
  display: none;
}

.hero-image-wrap::after {
  content: 'Image coming soon';
  display: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.hero-image.broken ~ .hero-image-wrap::after,
.hero-image-wrap:has(.broken)::after {
  display: block;
}

.hero-text h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 1.25rem;
  line-height: 1.1;
}

.hero-text h1::after {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--magenta);
  margin-top: 0.75rem;
  border-radius: 2px;
}

.hero-text p {
  color: var(--text);
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* ── Canon section ────────────────────────────────────── */
.canon-section {
  max-width: 1100px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
}

.section-title {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

.canon-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.canon-card:hover {
  border-color: var(--blue-dim);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.canon-card--featured {
  border-color: var(--gold-dim);
}

.canon-card--featured:hover {
  border-color: var(--gold);
}

.canon-pov {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

.canon-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 0.4rem;
}

.canon-card--featured .canon-name {
  color: var(--gold);
}

.canon-domain {
  font-size: 0.75rem;
  color: var(--blue);
  font-family: monospace;
}

.canon-card--featured .canon-domain {
  color: var(--gold-dim);
}

/* ── Footer ───────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer a {
  color: var(--blue);
  text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 700px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 1.5rem auto;
  }

  .hero-image-wrap {
    aspect-ratio: 4/3;
  }

  .hero-text h1 { font-size: 1.75rem; }

  .canon-grid {
    grid-template-columns: 1fr;
  }

  .widget-username { display: none; }
}
