/* ── App shell: persistent left sidebar + content column ──────
   Reuses the design tokens from main.css (loaded first). Public pages keep
   the top header; the authenticated app area uses this shell. */

:root {
  --sidebar: 248px;
}

/* ── Themed date / time inputs ────────────────────────────────
   Dark native popup (color-scheme), a burnt-orange calendar icon, and the
   whole field is clickable to open the picker (see scripts.js showPicker). */
input[type="datetime-local"],
input[type="date"],
input[type="time"] {
  color-scheme: dark;
  cursor: pointer;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23c97a2c' stroke-width='1.7'%3E%3Crect x='3' y='4.5' width='14' height='12' rx='2'/%3E%3Cpath d='M3 8.5h14M7 3v3M13 3v3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

body.app-body {
  flex-direction: row;
  align-items: stretch;
}

/* Pages that aren't the explicit app-body layout (the public/legacy pages that
   include fragments/nav) still get the fixed sidebar — their content column is
   offset by the sidebar width. App-body pages use .app-content margin instead. */
body:not(.app-body) {
  padding-left: var(--sidebar);
}
@media (max-width: 900px) {
  body:not(.app-body) { padding-left: 0; }
}

/* ── Sidebar ──────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  background: rgba(16, 14, 11, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  z-index: 1000;
}

.app-sidebar-brand {
  height: var(--hdr);
  display: flex;
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
}

.app-sidebar-brand img {
  height: 34px;
  object-fit: contain;
}

.app-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 14px;
  overflow-y: auto;
}

.app-nav-group {
  font-family: 'Philosopher', serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 14px 12px 6px;
}

.app-nav-group:first-child { padding-top: 4px; }

.app-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: 'Philosopher', serif;
  font-size: 14.5px;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.app-nav a svg { flex: none; opacity: 0.8; }

.app-nav a:hover {
  color: var(--text);
  background: var(--surface);
}

.app-nav a.active {
  color: var(--text);
  background: var(--accent-glow);
  border-color: var(--border-a);
}

.app-nav a.active svg { opacity: 1; color: var(--accent); }

/* ── Sidebar footer (user / sign-in) ─────────────────────── */
.app-sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 14px;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-user-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--border-a);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  text-transform: uppercase;
  overflow: hidden;
}

.app-user-name {
  flex: 1;
  min-width: 0;
  font-family: 'Philosopher', serif;
  font-size: 13.5px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-logout-form { display: flex; }

.app-logout {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text3);
  padding: 6px;
  cursor: pointer;
  display: flex;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.app-logout:hover { color: var(--text); background: var(--surface); border-color: var(--border); }

.app-signin {
  display: block;
  text-align: center;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-a);
  color: var(--text);
  font-family: 'Philosopher', serif;
  font-size: 14px;
}

.app-signin:hover { background: var(--accent-glow); }

/* ── Content column ───────────────────────────────────────── */
.app-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar);
  display: flex;
  flex-direction: column;
}

.app-topbar {
  display: none; /* mobile only */
  align-items: center;
  gap: 14px;
  height: var(--hdr);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(16, 14, 11, 0.9);
  backdrop-filter: blur(16px);
  z-index: 900;
}

.app-menu-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.app-topbar-title {
  font-family: 'Philosopher', serif;
  font-size: 17px;
  font-weight: 500;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 38px 40px 56px;
}
/* Bracket pages use the full content width so wide brackets don't get
   squeezed into the centered column (less horizontal scrolling). */
.app-main.app-main-wide { max-width: none; }

/* ── Page header within main ──────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.page-title {
  font-family: 'Philosopher', serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-subtitle {
  color: var(--text2);
  font-family: 'Philosopher', serif;
  font-size: 14.5px;
  margin-top: 6px;
}

/* ── Shared building blocks ───────────────────────────────── */
.app-section { margin-bottom: 40px; }

.app-section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.app-section-head .t {
  font-family: 'Philosopher', serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  white-space: nowrap;
}

.app-section-head .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-a);
  background: var(--accent-glow);
  color: var(--text);
  font-family: 'Philosopher', serif;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: rgba(201, 122, 44, 0.28); }

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

.btn-ghost:hover { background: var(--surface-h); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

a.tile:hover { border-color: var(--border-a); background: var(--surface-h); transform: translateY(-2px); }

.tile-name {
  font-family: 'Philosopher', serif;
  font-size: 17px;
  color: var(--text);
}

.tile-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--text2);
  font-family: 'Philosopher', serif;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: 'Philosopher', serif;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  white-space: nowrap;
}

.badge-pro { color: var(--accent); border-color: var(--border-a); background: var(--accent-glow); }
.badge-official { color: var(--gold); border-color: rgba(184,146,58,0.4); background: rgba(184,146,58,0.12); }
.badge-live { color: #6fbf73; border-color: rgba(111,191,115,0.4); background: rgba(111,191,115,0.12); }
.badge-draft { color: var(--text3); }
.badge-done { color: var(--silver); }

/* ── Secondary (inner) nav + tab panels ───────────────────── */
.with-subnav {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.subnav {
  position: sticky;
  top: 24px;
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.subnav a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: 'Philosopher', serif;
  font-size: 14.5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.subnav a:hover { color: var(--text); background: var(--surface); }
.subnav a.active {
  color: var(--text);
  background: var(--accent-glow);
  border-color: var(--border-a);
}
.subnav-content { flex: 1; min-width: 0; }
.tab-panel[hidden] { display: none; }

@media (max-width: 760px) {
  .with-subnav { flex-direction: column; gap: 16px; }
  .subnav {
    position: static;
    flex: none;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .subnav a { white-space: nowrap; }
}

/* Reusable inline search bar (Games page, etc.) */
.page-search {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  max-width: 480px;
}
.page-search input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Philosopher', serif;
  font-size: 14px;
  padding: 9px 13px;
}
.page-search input:focus { outline: none; border-color: var(--border-a); }

.empty {
  padding: 30px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  font-family: 'Philosopher', serif;
  text-align: center;
}

/* ── Shell footer (lives inside .app-content) ─────────────── */
.app-foot {
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--text3);
  font-family: 'Philosopher', serif;
  font-size: 12.5px;
}

.app-foot-links { display: flex; gap: 16px; }
.app-foot-links a:hover { color: var(--text2); }

/* ── Mobile ───────────────────────────────────────────────── */
.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
}

@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.app-sidebar-open .app-sidebar { transform: translateX(0); }
  body.app-sidebar-open .app-sidebar-overlay { display: block; }
  .app-content { margin-left: 0; }
  .app-topbar { display: flex; }
  .app-main { padding: 24px 18px 44px; }
  .page-title { font-size: 25px; }
}
