/* style.css -- bytesize design system */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ---------------------------------------------------------------------------
   Tokens
--------------------------------------------------------------------------- */
:root {
  --bg:             #0c0c0f;
  --surface:        #111116;
  --surface-2:      #17171e;
  --surface-3:      #1c1c24;
  --border:         rgba(255,255,255,0.06);
  --border-bright:  rgba(255,255,255,0.12);
  --text:           #ededf2;
  --text-2:         #a0a0b8;
  --muted:          #52526a;
  --accent:         #c8f135;
  --accent-dim:     rgba(200,241,53,0.08);
  --accent-glow:    rgba(200,241,53,0.18);
  --love:           #ff6b8a;
  --danger:         #ff5f57;

  --topbar-h:       48px;
  --left-w:         340px;
  --radius:         10px;
  --radius-sm:      6px;

  --mono:  'JetBrains Mono', monospace;
  --sans:  'Bricolage Grotesque', sans-serif;
}

/* ---------------------------------------------------------------------------
   Reset
--------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--sans); cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: var(--sans); color: var(--text); }

/* ---------------------------------------------------------------------------
   Topbar
--------------------------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 100;
}

.logo {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; text-decoration: none;
}
.logo img {
  width: 24px; height: 24px;
  border-radius: 5px;
  object-fit: contain;
}
.logo-text {
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.03em; color: var(--text);
}

.topbar-div {
  width: 1px; height: 18px;
  background: var(--border-bright); flex-shrink: 0;
}
.topbar-spacer { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 30px;
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: -0.01em;
  transition: all 0.14s ease;
  white-space: nowrap; flex-shrink: 0; cursor: pointer;
}
.btn svg { flex-shrink: 0; }

.btn-ghost {
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-3); color: var(--text);
  border-color: var(--border-bright);
}

.btn-accent { background: var(--accent); color: #0c0c0f; border: none; }
.btn-accent:hover { background: #d4f54a; box-shadow: 0 0 16px var(--accent-glow); }

.btn-danger {
  background: rgba(255,95,87,0.1); color: var(--danger);
  border: 1px solid rgba(255,95,87,0.18);
}
.btn-danger:hover { background: rgba(255,95,87,0.18); }

/* ---------------------------------------------------------------------------
   Stat group (like / share / fork)
--------------------------------------------------------------------------- */
.stat-group {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; flex-shrink: 0;
}
.stat-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 0 10px; height: 30px;
  font-family: var(--mono); font-size: 11px;
  color: var(--text-2); background: var(--surface-2);
  border: none; cursor: pointer;
  transition: all 0.14s ease;
}
.stat-btn + .stat-btn { border-left: 1px solid var(--border); }
.stat-btn:hover { background: var(--surface-3); color: var(--text); }
.stat-btn.liked { color: var(--love); background: rgba(255,107,138,0.06); }
.stat-btn.liked svg path { fill: var(--love); stroke: var(--love); }

/* ---------------------------------------------------------------------------
   Framework / doc type tags
--------------------------------------------------------------------------- */
.fw-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.fw-tag.html     { background: rgba(91,143,255,0.08);   color: #5b8fff;  border: 1px solid rgba(91,143,255,0.18); }
.fw-tag.react    { background: rgba(97,218,251,0.08);   color: #61dafb;  border: 1px solid rgba(97,218,251,0.18); }
.fw-tag.vue      { background: rgba(66,211,146,0.08);   color: #42d392;  border: 1px solid rgba(66,211,146,0.18); }
.fw-tag.d3       { background: rgba(247,183,49,0.08);   color: #f7b731;  border: 1px solid rgba(247,183,49,0.18); }
.fw-tag.chartjs  { background: rgba(247,183,49,0.08);   color: #f7b731;  border: 1px solid rgba(247,183,49,0.18); }
.fw-tag.recharts { background: rgba(247,183,49,0.08);   color: #f7b731;  border: 1px solid rgba(247,183,49,0.18); }
.fw-tag.canvas   { background: rgba(253,150,68,0.08);   color: #fd9644;  border: 1px solid rgba(253,150,68,0.18); }
.fw-tag.phaser   { background: rgba(253,150,68,0.08);   color: #fd9644;  border: 1px solid rgba(253,150,68,0.18); }
.fw-tag.markdown { background: rgba(162,155,254,0.08);  color: #a29bfe;  border: 1px solid rgba(162,155,254,0.18); }
.fw-tag.revealjs { background: rgba(255,107,138,0.08);  color: #ff6b8a;  border: 1px solid rgba(255,107,138,0.18); }

/* ---------------------------------------------------------------------------
   Left panel
--------------------------------------------------------------------------- */
.left-panel {
  width: var(--left-w); flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-header {
  height: 36px; display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-label {
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}
.panel-body {
  flex: 1; overflow-y: auto; padding: 12px;
  scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent;
}

/* ---------------------------------------------------------------------------
   Meta table
--------------------------------------------------------------------------- */
.meta-table {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.meta-row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.meta-key {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  flex-shrink: 0;
}
.meta-val {
  font-family: var(--mono); font-size: 10px;
  color: var(--text-2); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.meta-val.accent { color: var(--accent); }
.meta-val a { color: var(--text-2); transition: color 0.14s; }
.meta-val a:hover { color: var(--text); }

.meta-avatar {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; color: #0c0c0f;
  background: linear-gradient(135deg, #5b8fff, #c8f135);
  vertical-align: middle; margin-right: 3px; flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Prompt display
--------------------------------------------------------------------------- */
.prompt-quote {
  font-size: 24px; color: var(--accent);
  font-weight: 800; line-height: 1;
  margin-bottom: 6px; display: block;
}
.prompt-text {
  font-size: 13px; line-height: 1.65;
  color: var(--text); font-style: italic; opacity: 0.8;
}

/* ---------------------------------------------------------------------------
   Device frame
--------------------------------------------------------------------------- */
.device-frame {
  width: 100%; max-width: 760px;
  height: 100%; max-height: 520px;
  border-radius: 12px;
  border: 1px solid var(--border-bright);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  animation: frameIn 0.35s cubic-bezier(0.16,1,0.3,1) forwards;
}
@keyframes frameIn {
  from { opacity: 0; transform: translateY(8px) scale(0.988); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.device-chrome {
  height: 30px; background: #16161e;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 10px; gap: 5px; flex-shrink: 0;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-r { background: #ff5f57; }
.dot-y { background: #febc2e; }
.dot-g { background: #28c840; }
.url-bar { flex: 1; margin: 0 10px; display: flex; justify-content: center; }
.url-pill {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 10px;
  font-family: var(--mono); font-size: 9px; color: var(--muted);
  width: 180px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.device-content { flex: 1; overflow: hidden; position: relative; }
.device-content iframe { width: 100%; height: 100%; border: none; display: block; }

/* ---------------------------------------------------------------------------
   Form controls (dropdowns, inputs)
--------------------------------------------------------------------------- */
.form-group {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px;
}
.form-label {
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.form-select, .form-input {
  width: 100%; height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 0 10px;
  transition: border-color 0.14s;
  outline: none; appearance: none; cursor: pointer;
}
.form-select { background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2352526a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.form-select:focus, .form-input:focus { border-color: var(--border-bright); }
.form-select:hover, .form-input:hover { border-color: var(--border-bright); }

/* ---------------------------------------------------------------------------
   Toast
--------------------------------------------------------------------------- */
#toast {
  position: fixed; bottom: 52px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-3); border: 1px solid var(--border-bright);
  color: var(--text); font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16,1,0.3,1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 9999;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------------------
   Bottom bar
--------------------------------------------------------------------------- */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 38px; border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 16px; gap: 10px; z-index: 100;
}

/* ---------------------------------------------------------------------------
   Gallery card
--------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.14s, transform 0.14s;
  cursor: pointer; display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
}
.card:hover { border-color: var(--border-bright); transform: translateY(-2px); }

.card-thumb {
  height: 160px;
  flex-shrink: 0;
  background: var(--surface-2);
  overflow: hidden; position: relative;
  width: 100%;
}
.card-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.card-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.card-thumb-placeholder span {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}

.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.01em; margin-bottom: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  flex-wrap: wrap;
}
.card-stats {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.card-stat { display: flex; align-items: center; gap: 3px; }


/* ---------------------------------------------------------------------------
   User nav (topbar right, all pages)
--------------------------------------------------------------------------- */
.user-nav {
  display: flex; align-items: center; gap: 6px;
  position: relative;
}
.user-nav-btn {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  color: var(--text-2); background: none; border: none;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all 0.14s; letter-spacing: -0.01em;
}
.user-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border-bright);
  border-radius: 10px; padding: 6px;
  min-width: 150px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none; z-index: 200;
}
.user-dropdown.open { display: block; }
.dd-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  cursor: pointer; transition: all 0.12s; width: 100%;
  border: none; background: none; font-family: var(--sans); text-align: left;
}
.dd-item:hover { background: var(--surface-3); color: var(--text); }
.dd-sep { height: 1px; background: var(--border); margin: 4px 0; }
.dd-item.danger:hover { color: var(--danger); }
.prompt-text { white-space: pre-wrap; }
/* ---------------------------------------------------------------------------
   Auth page
--------------------------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  width: 360px; padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 6px; }
.auth-sub { font-size: 13px; color: var(--text-2); margin-bottom: 28px; line-height: 1.55; }

.oauth-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px; margin-bottom: 10px;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-bright);
  cursor: pointer; transition: all 0.14s;
  font-family: var(--sans); text-decoration: none;
}
.oauth-btn:hover { background: var(--surface-3); border-color: rgba(255,255,255,0.2); }
.oauth-btn svg { flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   Dialog / modal
--------------------------------------------------------------------------- */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.dialog-overlay.open { opacity: 1; pointer-events: all; }
.dialog {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 12px; padding: 24px;
  width: 360px; box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: translateY(8px);
  transition: transform 0.18s ease;
}
.dialog-overlay.open .dialog { transform: translateY(0); }
.dialog-title { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------------------------
   Scrollbar
--------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */
@media (max-width: 680px) {
  .left-panel { display: none; }
  :root { --left-w: 0px; }
  .stat-group { display: none; }
}
