/* ============================================================
   CRAYON ARCADE — homepage hub
   Layout modeled on a games-platform browse page: icon sidebar,
   top search bar, thumbnail card grid, green "Play" buttons.
   ============================================================ */

:root {
  --bg-page: #f2f4f8;
  --bg-panel: #ffffff;
  --bg-panel-2: #eef0f6;
  --ink: #1e2130;
  --ink-dim: #767c94;
  --accent-purple: #7c3aed;
  --accent-play: #17b866;   /* green "Play" action, standard game-platform convention */
  --border-soft: #e3e6ee;
  --sidebar-w: 84px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 1px 2px rgba(20,20,40,0.04), 0 4px 14px rgba(20,20,40,0.06);
  --shadow-card-hover: 0 6px 20px rgba(20,20,40,0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; min-height: 100%; background: var(--bg-page); color: var(--ink);
  font-family: "Nunito", sans-serif;
}
h1, h2, .topbar-brand, .play-btn { font-family: "Baloo 2", "Nunito", sans-serif; }

.hidden { display: none !important; }

/* ============================================================
   APP SHELL — sidebar + main area
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- icon sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-panel); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 10px; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
  font-size: 26px; width: 48px; height: 48px; border-radius: 14px;
  background: var(--accent-purple); color: #fff; overflow: hidden;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; }
.sidebar-bottom { margin-top: auto; width: 100%; display: flex; justify-content: center; }

.sidebar-icon {
  width: 64px; padding: 8px 4px; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: var(--radius-md); color: var(--ink-dim);
}
.sidebar-icon .icon-glyph { font-size: 21px; }
.sidebar-icon .icon-label { font-size: 10px; font-weight: 800; }
.sidebar-icon:hover { background: var(--bg-panel-2); color: var(--ink); }
.sidebar-icon.active { background: #f1e9fe; color: var(--accent-purple); }

/* ---------- main area ---------- */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--bg-panel); border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--ink);
  opacity: 0.75; flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { opacity: 1; background: var(--bg-panel-2); }
.header-logo {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: var(--accent-purple);
}
.topbar-brand { font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand-my { color: var(--accent-purple); }
.brand-games { color: var(--ink); }

.search-wrap {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-panel-2); border: 1px solid var(--border-soft);
  border-radius: 999px; padding: 5px; flex-shrink: 0;
  width: 40px; overflow: hidden; transition: width 0.22s ease, padding 0.22s ease;
}
.search-wrap.expanded { width: min(320px, 60vw); padding: 5px 8px 5px 12px; }
.search-wrap input {
  border: none; outline: none; background: transparent; flex: 1; min-width: 0;
  font-family: "Nunito", sans-serif; font-weight: 700; font-size: 14px; color: var(--ink);
  opacity: 0; transition: opacity 0.15s ease;
}
.search-wrap.expanded input { opacity: 1; }
.search-wrap input::placeholder { color: var(--ink-dim); }

.hub-hero { padding: 28px 24px 6px; }
.hub-hero h1 { font-size: 26px; font-weight: 800; margin: 0; color: var(--ink); }
.hub-hero .tagline { color: var(--ink-dim); font-weight: 700; margin: 4px 0 0; font-size: 14px; }

/* ---------- game thumbnail grid ---------- */
.game-grid {
  padding: 18px 24px 10px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px;
}

.game-card {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); overflow: hidden; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-card); transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }

.card-thumb {
  aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: var(--bg-panel-2);
}
.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-emoji { font-size: 52px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.2)); }

.card-info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.card-info h2 { font-size: 16px; margin: 0; }
.card-info p { color: var(--ink-dim); font-weight: 600; font-size: 12.5px; margin: 0 0 6px; min-height: 32px; }

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.players-tag { font-size: 11px; font-weight: 800; color: var(--ink-dim); }
.play-btn {
  background: var(--accent-play); color: #fff; font-weight: 800; font-size: 12.5px;
  padding: 7px 14px; border-radius: 999px;
}

.no-results { text-align: center; color: var(--ink-dim); font-weight: 700; padding: 30px; }

/* ---------- profile page ---------- */
.profile-page { max-width: 420px; margin: 0 auto; padding: 28px 24px 10px; }
.profile-page h1 { font-size: 24px; font-weight: 800; margin: 0; color: var(--ink); }
.profile-page .tagline { color: var(--ink-dim); font-weight: 700; font-size: 13px; margin: 4px 0 22px; }

.profile-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.profile-avatar-preview {
  width: 92px; height: 92px; border-radius: 50%;
  background: var(--bg-panel-2); border: 2px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; background-size: cover; background-position: center;
}
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-label { cursor: pointer; display: inline-block; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-weight: 800; font-size: 12px; color: var(--ink-dim);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;
}
.avatar-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-preset-btn {
  width: 40px; height: 40px; border-radius: 50%; font-size: 19px;
  background: var(--bg-panel-2); border: 2px solid var(--border-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.avatar-preset-btn:hover { background: #f1e9fe; }
.avatar-preset-btn.selected { border-color: var(--accent-purple); background: #f1e9fe; }

input[type="text"] {
  width: 100%; padding: 11px 14px; font-size: 15px; font-weight: 700;
  background: var(--bg-panel-2); color: var(--ink);
  border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  font-family: "Nunito", sans-serif; outline: none;
}
input[type="text"]:focus { border-color: var(--accent-purple); }
input[type="text"]::placeholder { color: var(--ink-dim); }

.btn {
  display: inline-block; text-align: center; cursor: pointer;
  font-weight: 800; font-size: 14px; padding: 11px 18px; border-radius: 999px; border: none;
}
.btn-block { display: block; width: 100%; margin-top: 4px; }
.btn-small { padding: 8px 16px; font-size: 13px; }
.btn-primary { background: var(--accent-purple); color: #fff; }
.btn-secondary { background: var(--bg-panel-2); color: var(--ink); border: 1px solid var(--border-soft); }

.profile-saved-msg { color: var(--accent-play); font-weight: 800; font-size: 13px; text-align: center; margin-top: 10px; }

.hub-footer {
  margin-top: auto; text-align: center; color: var(--ink-dim);
  font-weight: 700; font-size: 12px; padding: 24px 20px 30px;
}

/* ---------- mobile bottom tab bar (shown < 720px instead of sidebar) ---------- */
.mobile-tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--bg-panel); border-top: 1px solid var(--border-soft);
  justify-content: space-around; padding: 6px 0 8px;
}
.tab-icon {
  border: none; background: transparent; color: var(--ink-dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 20px;
}
.tab-icon span { font-size: 10px; font-weight: 800; }
.tab-icon.active { color: var(--accent-purple); }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .mobile-tabbar { display: flex; }
  .main-area { padding-bottom: 60px; }
}

/* ============================================================
   DRAWER (Privacy / Terms / Contact) + MODAL
   ============================================================ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,20,40,0.45); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.drawer-overlay.visible { opacity: 1; pointer-events: auto; }

.side-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 82vw;
  background: var(--bg-panel); border-right: 1px solid var(--border-soft);
  z-index: 50; transform: translateX(-100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column; padding: 18px; box-shadow: 8px 0 30px rgba(0,0,0,0.15);
}
.side-drawer.open { transform: translateX(0); }

.drawer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.drawer-brand { font-family: "Baloo 2", sans-serif; font-weight: 800; color: var(--accent-purple); font-size: 16px; }
.drawer-close {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-soft);
  background: var(--bg-panel-2); color: var(--ink); cursor: pointer; font-weight: 800;
}

.drawer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.drawer-link {
  display: block; padding: 12px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-soft); background: var(--bg-panel-2);
  color: var(--ink); text-decoration: none; font-weight: 800; font-size: 15px;
}
.drawer-link:hover { background: #f1e9fe; }
.drawer-links.small .drawer-link { font-size: 13px; padding: 10px 14px; background: transparent; border-color: transparent; color: var(--ink-dim); }
.drawer-links.small .drawer-link:hover { color: var(--ink); background: var(--bg-panel-2); border-color: var(--border-soft); }

.drawer-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.drawer-copyright { color: var(--ink-dim); font-size: 11px; font-weight: 700; text-align: center; margin: 10px 0 0; line-height: 1.5; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,40,0.5); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  position: relative; width: 100%; max-width: 460px; max-height: 80vh; overflow-y: auto;
  background: var(--bg-panel); border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); padding: 26px;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-soft);
  background: var(--bg-panel-2); color: var(--ink); cursor: pointer; font-weight: 800;
}
.modal-title { font-family: "Baloo 2", sans-serif; font-size: 22px; color: var(--accent-purple); margin: 0 0 14px; }
.modal-box p { color: var(--ink); line-height: 1.6; font-size: 14px; font-weight: 600; }
.modal-lead { font-size: 15px; }
.modal-divider { border: none; border-top: 1px solid var(--border-soft); margin: 16px 0; }
.credits-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.credits-list li {
  background: #f1e9fe; border: 1px solid var(--border-soft); border-radius: 20px;
  padding: 6px 14px; font-weight: 800; font-size: 13px; color: var(--accent-purple);
}
