/* ============================================================
   PlayHive layout.css — app shell, sidebar, dashboard, screens
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--panel);
  border-right: 3px solid var(--edge-panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 14px;
  z-index: 30;
}
.sidebar__brand {
  display: block;
  line-height: 0;
  border-radius: 12px;
  transition: transform 0.12s ease;
}
.sidebar__brand img { width: 52px; height: 52px; display: block; }
.sidebar__brand:hover { transform: translateY(-2px); }
.sidebar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex: 1;
}
.side-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  width: 72px;
}
.side-link .hex { background: var(--line); transition: background 0.15s ease, transform 0.1s ease; }
.side-link .hex__inner { font-size: 20px; }
.side-link:hover .hex { background: var(--blue); transform: translateY(-2px); }
.side-link.is-active { color: var(--text); }
.side-link.is-active .hex { background: var(--blue); }
.side-link.is-active .hex__inner { color: var(--text); }
.side-link__label { font-size: 11px; font-weight: 800; }
.sidebar__foot { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ---------- Main column ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 3px solid var(--edge-panel);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title { font-family: var(--font-head); font-size: 22px; margin-right: auto; }
.topbar__logo { display: none; }
.topbar__logo .wordmark { display: block; height: 40px; width: auto; }
.topbar__right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.player-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
}

.screen {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  flex: 1;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--edge-blue);
  color: #fff;
  padding: 26px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.hero h1 { font-size: clamp(26px, 4.5vw, 40px); line-height: 1.05; }
.hero__sub { opacity: 0.9; font-size: 14px; margin-top: 4px; }
.hero__actions { margin-left: auto; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.continue-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.continue-chip:hover { background: rgba(255, 255, 255, 0.26); }
.continue-chip__thumb {
  width: 28px;
  height: 21px;
  object-fit: contain;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
}

/* first-load splash: gentle bounce then fade, never blocks the page */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
  background: transparent;
  animation: splash-fade 0.3s ease 0.6s forwards;
}
.splash img {
  width: 104px;
  height: 104px;
  animation: splash-bounce 0.6s cubic-bezier(0.3, 1.2, 0.4, 1);
}
@keyframes splash-bounce {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes splash-fade {
  to { opacity: 0; visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .splash { display: none; }
}

/* ---------- Toolbar (chips + search) ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar__chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Home layout ---------- */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.rightcol { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--topbar-h) + 16px); }

/* best-scores list */
.best-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
  font-weight: 800;
  border-bottom: 1px dashed var(--line);
}
.best-row:last-child { border-bottom: 0; }
.best-row__emoji { font-size: 18px; }
.best-row__score { margin-left: auto; color: var(--blue); }

/* ---------- Settings ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.setting-row:last-child { border-bottom: 0; }
.setting-row__label { font-weight: 800; font-size: 15px; }
.setting-row__hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.seg { display: flex; gap: 8px; }

/* ---------- Game screen ---------- */
.game-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}
.game-screen__body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
}

/* ---------- Responsive ---------- */
@media (min-width: 900px) {
  .topbar__logo { display: block; flex: none; margin-right: 4px; }
}

@media (max-width: 1080px) {
  .home-grid { grid-template-columns: 1fr; }
  .rightcol { position: static; flex-direction: row; flex-wrap: wrap; }
  .rightcol > * { flex: 1 1 260px; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    height: auto;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 3px solid var(--edge-panel);
    gap: 0;
  }
  .sidebar__brand, .sidebar__foot { display: none; }
  .sidebar__nav { flex-direction: row; gap: 2px; margin-top: 0; width: 100%; justify-content: space-around; }
  .side-link { width: auto; padding: 2px 6px; }
  .side-link .hex { --hex-size-w: 34px; --hex-size-h: 38px; }
  .side-link .hex__inner { font-size: 15px; }
  .side-link__label { font-size: 10px; }
  .main { padding-bottom: 76px; }
  .screen { padding: 14px; gap: 14px; }
  .hero { padding: 20px; }
  .hero__actions { margin-left: 0; align-items: stretch; width: 100%; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__title { font-size: 18px; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .game-card__art { height: 88px; font-size: 38px; }
}

@media (max-width: 420px) {
  .player-tag .player-name { display: none; }
  .games-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- View Transitions: circular theme reveal ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }
html.theme-reveal::view-transition-new(root) {
  animation: theme-reveal 0.45s ease forwards;
  clip-path: circle(0% at var(--tx, 50%) var(--ty, 50%));
}
@keyframes theme-reveal {
  to { clip-path: circle(150% at var(--tx, 50%) var(--ty, 50%)); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  html.theme-reveal::view-transition-new(root) { animation: none; clip-path: none; }
}
