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

:root {
  --bg:          #080c14;
  --panel:       #0d1220;
  --panel-alt:   #0a0f1c;
  --border:      #1e293b;
  --border-hover:#2e3f5a;
  --cyan:        #00d4ff;
  --cyan-dim:    rgba(0, 212, 255, 0.18);
  --cyan-glow:   rgba(0, 212, 255, 0.06);
  --text-primary:#e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;
  --sidebar-w:   260px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Canvas Background ─────────────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
}

.radial-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(0,212,255,0.04) 0%, transparent 65%);
}

/* ─── Top Bar ───────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(8, 12, 20, 0.94);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  z-index: 100;
}

#topbar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
#topbar .logo svg { width: 18px; height: 18px; }

#topbar .sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

#topbar .breadcrumb {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
}
#topbar .breadcrumb span { color: var(--cyan); }

#topbar .back-link {
  margin-left: auto;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}
#topbar .back-link:hover {
  color: var(--cyan);
  border-color: var(--cyan-dim);
  background: var(--cyan-glow);
}

/* ─── App Layout ────────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  padding-top: 52px;
}

/* ─── Sidebar ───────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  border-right: 1px solid var(--border);
  background: rgba(10, 15, 28, 0.7);
  backdrop-filter: blur(16px);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#sidebar-inner {
  padding: 16px 0 24px;
}

.sidebar-section-label {
  padding: 0 16px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

/* ─── Nav Platform ──────────────────────────────────────────────── */
.nav-platform {
  margin-bottom: 2px;
}

.nav-platform-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  margin: 0 6px;
  transition: background 0.15s;
}
.nav-platform-header:hover { background: rgba(255,255,255,0.04); }
.nav-platform-header.open { }

.nav-platform-icon {
  display: flex;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-platform-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.nav-count {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 10px;
}

.nav-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.22s ease;
  flex-shrink: 0;
}
.nav-platform-header.open .nav-chevron { transform: rotate(180deg); }

/* ─── Year Items ────────────────────────────────────────────────── */
.nav-year-list {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease;
  padding-left: 28px;
}
.nav-year-list.open { max-height: 500px; }

.nav-year-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 6px 8px;
  margin: 1px 6px 1px 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.nav-year-item:hover { background: rgba(255,255,255,0.05); color: var(--text-dim); }
.nav-year-item.active {
  background: rgba(0,212,255,0.08);
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
  padding-left: 6px;
}
.nav-year-item.nav-empty { opacity: 0.5; }

.nav-year-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-year-count {
  margin-left: auto;
  font-size: 10px;
  font-family: monospace;
  color: var(--text-muted);
}

/* ─── Main Content ──────────────────────────────────────────────── */
#main {
  flex: 1;
  height: 100%;
  overflow-y: auto;
}

#main::-webkit-scrollbar { width: 4px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#content-area {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* ─── Landing ───────────────────────────────────────────────────── */
.landing {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.landing-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.landing-icon {
  width: 40px;
  height: 40px;
  color: var(--cyan);
  opacity: 0.5;
}

.landing-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.landing-sub {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 560px;
}

.platform-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.platform-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 18, 32, 0.6);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  backdrop-filter: blur(8px);
}
.platform-card:hover {
  background: rgba(13, 18, 32, 0.9);
  border-color: var(--border-hover);
  transform: translateX(3px);
}

.platform-card-icon {
  display: flex;
  flex-shrink: 0;
}

.platform-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.platform-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.platform-card-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.platform-card-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color 0.2s, transform 0.2s;
}
.platform-card:hover .platform-card-arrow {
  color: var(--cyan);
  transform: translateX(3px);
}

.landing-hint {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hint-prompt { color: var(--cyan); }

/* ─── Year Page ─────────────────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-platform-icon {
  display: flex;
  flex-shrink: 0;
  opacity: 0.9;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 4px;
}

/* ─── Writeup Grid ──────────────────────────────────────────────── */
.writeup-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.writeup-card {
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 18, 32, 0.55);
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
  animation: fadeIn 0.35s ease both;
}
.writeup-card:hover {
  background: rgba(13, 18, 32, 0.85);
  border-color: var(--border-hover);
}

.card-top { display: flex; flex-direction: column; gap: 10px; }

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
  flex-shrink: 0;
}
.card-link:hover {
  color: var(--cyan);
  border-color: var(--cyan-dim);
  background: var(--cyan-glow);
}
.card-link svg { width: 12px; height: 12px; }

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── Badges & Tags ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-family: monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ─── Empty State ───────────────────────────────────────────────── */
.page-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding-top: 20px;
}

.empty-icon {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  opacity: 0.4;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-sub {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.empty-hint {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

/* ─── Responsive ────────────────────────────────────────────────── */
#sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
}
#sidebar-toggle:hover { color: var(--cyan); border-color: var(--cyan-dim); }

@media (max-width: 720px) {
  #sidebar-toggle { display: flex; }
  #sidebar {
    position: fixed;
    left: 0;
    top: 52px;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.open { transform: translateX(0); }
  #content-area { padding: 32px 20px 60px; }
}
