/* ============================================================
   LewDB — Design System
   nhentai-inspired: bold header, dark body, compact grid
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Core palette */
  --bg:            #111111;
  --bg-deep:       #181818;
  --surface:       #1f1f1f;
  --surface-raise: #282828;
  --surface-hover: #333333;

  /* Header */
  --header-bg:     #1f1f1f;
  --header-text:   #ffffff;

  /* Text */
  --text:          #ffffff;
  --text-dim:      #cccccc;
  --text-muted:    #888888;

  /* Borders */
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);

  /* Accent (nhentai signature pink) */
  --accent:        #ec2854;
  --accent-hover:  #d41b44;
  --accent-soft:   rgba(236,40,84,0.12);

  /* Tags */
  --tag-bg:        #2d2d2d;
  --tag-text:      #cccccc;
  --tag-count:     #777777;

  /* Utility */
  --radius:        4px;
  --radius-lg:     8px;
  --speed:         0.15s;
  --font:          "Inter", ui-sans-serif, system-ui, -apple-system,
                   BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Site Header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.5px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity var(--speed);
}

.brand::before {
  content: "♥";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.brand:hover {
  opacity: 0.85;
}

/* Search */
.search {
  flex: 1;
  max-width: 600px;
  display: flex;
  align-items: center;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--speed);
}

.search:focus-within {
  border-color: var(--accent);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: none;
  background: transparent;
  color: #fff;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.search input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: background var(--speed);
}

.search-btn:hover {
  background: var(--accent-hover);
}

/* Nav links in header */
nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  margin-left: auto;
}

nav a {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--speed);
}

nav a:hover {
  color: var(--accent);
}

/* User nav (login/register or avatar) */
.user-nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.user-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--speed);
}

.user-nav a:hover {
  color: var(--accent);
}

.user-nav .btn-primary {
  height: auto;
  margin: 0 8px;
  padding: 6px 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.user-nav .btn-primary:hover {
  background: var(--accent-hover);
}

.user-nav .favorites-link {
  color: var(--accent);
  font-weight: 700;
}

/* ── Page Layout ─────────────────────────────────────────── */
.page {
  width: min(1200px, calc(100% - 32px));
  margin: 24px auto 60px;
}

.page section + section {
  margin-top: 20px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--speed), border-color var(--speed), color var(--speed);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-raise);
  flex-shrink: 0;
}

.avatar-sm  { width: 28px;  height: 28px; }
.avatar-md  { width: 48px;  height: 48px; }
.avatar-lg  { width: 80px;  height: 80px; }
.avatar-xl  { width: 128px; height: 128px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-raise);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.3em;
  flex-shrink: 0;
}

/* ── Intro Band (homepage hero) ──────────────────────────── */
.intro-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 4px;
}

.intro-band h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
}

.intro-band p {
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 8px;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.stat-row span {
  background: var(--accent-soft);
  border: 1px solid rgba(236, 40, 84, 0.2);
  border-radius: var(--radius);
  color: var(--accent);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Tag Rail (homepage) ─────────────────────────────────── */
.tag-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}

.tag-rail h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Tag Chips ───────────────────────────────────────────── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0 10px;
}

.game-card .tag-list {
  margin: 4px 0 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--tag-bg);
  border: none;
  border-radius: var(--radius);
  color: var(--tag-text);
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--speed), color var(--speed);
}

.tag-chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tag-chip small {
  color: var(--tag-count);
  font-size: 10px;
}

.text-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  transition: color var(--speed);
}

.text-link:hover {
  color: var(--accent-hover);
}

/* ── Card Grid ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 12px;
}

/* ── Sections ────────────────────────────────────────────── */
.grid-section {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.grid-section h2,
.section-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-accent {
  color: var(--accent);
}

/* ── Game Card ───────────────────────────────────────────── */
.game-card {
  min-width: 0;
  border-radius: var(--radius);
  background: var(--bg-deep);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed);
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  border-color: var(--accent);
}

.game-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Cover */
.cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--surface-raise);
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.game-card:hover .cover-img {
  transform: scale(1.06);
}

/* Cover overlay */
.cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}

.game-card:hover .cover-overlay {
  opacity: 1;
}

.cover-overlay-title {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Cover placeholder */
.cover-placeholder {
  aspect-ratio: 2 / 3;
  background: linear-gradient(145deg, var(--surface-raise), var(--accent-soft));
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-placeholder::after {
  content: "🎮";
  font-size: 32px;
  opacity: 0.3;
}

/* Card meta */
.game-card-meta {
  padding: 8px 10px 10px;
}

.game-card h3,
.game-card-title {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-card p,
.game-card-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

/* ── Tag Index ───────────────────────────────────────────── */
.tag-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}

.tag-index-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  transition: background var(--speed), border-color var(--speed);
}

.tag-index-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.tag-index-item small {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 20px;
  text-align: center;
}

/* ── Notice ──────────────────────────────────────────────── */
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
}

.notice h1 { margin: 0 0 6px; font-size: 18px; }
.notice p  { margin: 0; color: var(--text-dim); line-height: 1.5; }

/* ── Game Page ───────────────────────────────────────────── */
.game-page {
  display: grid;
  gap: 16px;
}

.game-page dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}

.game-page dt { color: var(--text-muted); font-size: 13px; }
.game-page dd { margin: 0; font-size: 13px; }

.game-page section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.game-page section h2 { margin: 0 0 8px; font-size: 16px; }
.game-page section p  { margin: 0; color: var(--text-dim); line-height: 1.5; }

/* ── Resource List ───────────────────────────────────────── */
.resource-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: background var(--speed), border-color var(--speed);
}

.resource-list li:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.resource-list a {
  color: var(--text);
  font-weight: 700;
  transition: color var(--speed);
}

.resource-list a:hover { color: var(--accent); }

.resource-list span {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Forms ───────────────────────────────────────────────── */
.tool-form {
  display: grid;
  gap: 14px;
  max-width: 720px;
  margin-top: 16px;
}

.tool-form label,
.field {
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.tool-form label > span,
.field-label {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tool-form input,
.tool-form select,
.tool-form textarea,
.field-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-deep);
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  transition: border-color var(--speed), box-shadow var(--speed);
  outline: none;
}

.tool-form input:focus,
.tool-form select:focus,
.tool-form textarea:focus,
.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tool-form textarea { resize: vertical; }

.tool-form button,
.form-btn {
  width: fit-content;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--speed);
}

.tool-form button:hover,
.form-btn:hover {
  background: var(--accent-hover);
}

.form-status {
  min-height: 18px;
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.form-status.success { color: #4caf85; }
.form-status.error   { color: var(--accent); }

/* ── Search Page ─────────────────────────────────────────── */
.search-results {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.result-row {
  display: grid;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  transition: background var(--speed), border-color var(--speed);
}

.result-row:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.result-row a        { font-weight: 700; transition: color var(--speed); }
.result-row a:hover  { color: var(--accent); }
.result-row span,
.result-row small    { color: var(--text-muted); font-size: 12px; }

/* ── Profile Page ────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-username {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
}

.profile-meta {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.profile-bio {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.profile-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
}

.profile-section-body {
  padding: 16px;
}

/* ── Settings Page ───────────────────────────────────────── */
.settings-layout {
  display: grid;
  gap: 12px;
  max-width: 680px;
}

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--speed);
}

.settings-panel-header:hover {
  background: var(--surface-hover);
}

.settings-panel-header .panel-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}

.settings-panel-chevron {
  color: var(--text-muted);
  transition: transform var(--speed);
}

.settings-panel[open] .settings-panel-chevron {
  transform: rotate(180deg);
}

.settings-panel-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.avatar-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.avatar-option {
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color var(--speed), transform var(--speed);
  padding: 0;
  background: none;
}

.avatar-option:hover      { transform: scale(1.08); }
.avatar-option.selected   { border-color: var(--accent); }

.avatar-upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 48px;
  height: 48px;
  border: 2px dashed var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  transition: border-color var(--speed), color var(--speed);
  background: none;
}

.avatar-upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-danger .settings-panel-header {
  color: var(--accent);
}

/* ── Auth Pages (login / register) ───────────────────────── */
.auth-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 30px 28px;
}

.auth-box h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
}

.auth-box .auth-sub {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form .form-btn {
  width: 100%;
  text-align: center;
  padding: 11px;
  font-size: 14px;
}

.auth-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-footer a {
  color: var(--accent);
  font-weight: 600;
  transition: color var(--speed);
}

.auth-footer a:hover { color: var(--accent-hover); }

/* ── Site Footer ─────────────────────────────────────────── */
.site-footer {
  display: flex;
  gap: 16px;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto 28px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  padding-top: 16px;
  font-size: 12px;
}

.site-footer a {
  color: var(--text-muted);
  transition: color var(--speed);
}

.site-footer a:hover { color: var(--text); }

/* ── Inline Alerts ───────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}

.alert-error {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #f8a0b0;
}

.alert-success {
  background: rgba(76, 175, 133, 0.1);
  border-color: #4caf85;
  color: #8fd8bc;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 800px) {
  .site-header {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 14px;
    gap: 8px;
  }

  .search {
    order: 10;
    flex: 0 0 100%;
    max-width: none;
  }

  nav {
    margin-left: 0;
  }

  nav a {
    height: auto;
    padding: 6px 8px;
    font-size: 12px;
  }

  .user-nav a {
    height: auto;
    padding: 6px 8px;
    font-size: 12px;
  }

  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
  }

  .profile-actions {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .auth-box {
    padding: 20px 18px;
  }
}

/* ── Content pages (h1 styling) ──────────────────────────── */
.page > section > h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
}

.page > section > p {
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 6px;
}
