/* ============================================================
   VUE ÉLÈVE — student.css
   ============================================================ */
body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ── Join ───────────────────────────────────────────────── */
#join-screen { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 0%, #1a0a2e 0%, var(--bg) 60%); }

.join-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 48px; width: 420px; text-align: center; position: relative; overflow: hidden; }
.join-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.join-logo { font-family: var(--font-disp); font-size: 2rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 4px; width: 100%; }
.join-logo span { color: var(--accent); }
.join-sub { color: var(--muted); font-size: 13px; margin-bottom: 36px; }
.join-input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); font-family: var(--font-mono); font-size: 16px; margin-bottom: 8px; outline: none; transition: border-color .2s; }
.join-input:focus { border-color: var(--accent); }
.waiting-msg { margin-top: 20px; color: var(--muted); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ── Lobby ──────────────────────────────────────────────── */
#lobby-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
#lobby-overlay[hidden] { display: none; }
.lobby-title { font-family: var(--font-disp); font-size: 40px; font-weight: 800; }
.lobby-title span { color: var(--accent); }
.player-grid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 500px; justify-content: center; }
.player-chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 13px; }
.player-chip.me { border-color: var(--accent2); color: var(--accent2); }

/* ── Top bar ────────────────────────────────────────────── */
#top-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 16px; height: 52px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; z-index: 10; }
.exercise-badge { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.exercise-badge strong { color: var(--text); }
.player-badge { background: var(--accent2); border-radius: 6px; padding: 4px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.timer-display { font-size: 20px; font-weight: 700; color: var(--gold); min-width: 60px; text-align: center; }
.timer-display.urgent { color: var(--accent); animation: flash .5s infinite; }

/* ── Game layout ────────────────────────────────────────── */
#game-screen { flex-direction: column; position: relative; }

/* game-body fills available space between top-bar and bottom-bar */
.game-body { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ── Editor panel ───────────────────────────────────────── */
.editor-panel {
  width: 45%;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #0d0d14;
  position: relative;
  flex-shrink: 0;
}

/* Drag handle on right border */
.resize-handle {
  position: absolute;
  top: 0; right: -3px; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 20;
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 48px;
  background: var(--border);
  border-radius: 2px;
  transition: background .15s, height .15s;
}
.resize-handle:hover::after,
.resize-handle.dragging::after { background: var(--accent2); height: 64px; }

.panel-header { padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot--green { background: var(--green); }

.lang-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; }
.lang-tabs::-webkit-scrollbar { display: none; }
.lang-tab { padding: 8px 16px; font-size: 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all .2s; display: none; user-select: none; white-space: nowrap; }
.lang-tab.visible { display: block; }
.lang-tab.active { color: var(--text); border-bottom-color: var(--accent); }

textarea.code-editor { flex: 1; background: #0d0d14; color: #abb2bf; border: none; padding: 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; resize: none; outline: none; tab-size: 2; display: none; overflow-y: auto; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
textarea.code-editor.active { display: block; }

/* ── Right side ─────────────────────────────────────────── */
.right-side { flex: 1; display: flex; flex-direction: row; overflow: hidden; width: 10%; min-width:fit-content;}
.preview-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.preview-frame { flex: 1; border: none; background: white; }

/* ── Score sidebar ──────────────────────────────────────── */
.score-sidebar {
  width: 180px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .2s ease;
  overflow: hidden;
}
.score-sidebar.collapsed { width: 36px; }

.score-header {
  padding: 12px 10px 12px 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.score-header-text { flex: 1; overflow: hidden; }

.score-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, transform .2s;
}
.score-toggle:hover { color: var(--text); }
.score-sidebar.collapsed .score-toggle { transform: scaleX(-1); }
.score-sidebar.collapsed .score-list,
.score-sidebar.collapsed .score-header-text { display: none; }

.score-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.score-item { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 12px; }
.score-item.me { background: rgba(124,58,237,.15); }
.score-rank { font-size: 11px; min-width: 20px; text-align: center; }
.score-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-pts { color: var(--gold); font-weight: 600; }
.solved-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.solved-indicator.pending { background: var(--border); }

/* ── Bottom bar — full width, outside game-body ─────────── */
.bottom-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.exercise-desc { flex: 1; font-size: 12px; color: var(--muted); line-height: 1.5; min-width: 0; }
.exercise-desc strong { color: var(--gold); font-weight: 600; }

/* ── Wrong answer bar (inside .game-body) ───────────────── */
.wrong-answer-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,62,108,1);
  border-top: 2px solid var(--accent);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 40;
  font-size: 13px;
  animation: slideUp .3s ease;
  flex-wrap: wrap;
}
.wrong-icon { font-size: 18px; flex-shrink: 0; background-color: white; border-radius: 28px; padding: 2px; }
.wrong-hint { flex: 1; color: white; min-width: 120px; }

/* ── Overlays (cover game-body + bottom-bar) ────────────── */
.game-overlay { position: absolute; inset: 0; background: rgba(10,10,15,.9); backdrop-filter: blur(4px); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.game-overlay[hidden] { display: none; }
.overlay-title { font-family: var(--font-disp); font-size: 48px; font-weight: 800; text-align: center; }
.overlay-title--green { color: var(--green); }
.overlay-title--muted { color: var(--muted); }

/* ── End screen ─────────────────────────────────────────── */
#end-screen { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, #1a0a2e 0%, var(--bg) 60%); overflow-y: auto; }
.podium { display: flex; align-items: flex-end; gap: 12px; margin: 32px 0; flex-wrap: wrap; justify-content: center; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium-name { font-size: 13px; max-width: 100px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-block { width: 80px; border-radius: 8px 8px 0 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-disp); font-size: 24px; font-weight: 800; }
.podium-pts { font-size: 11px; color: var(--muted); }
.p1 .podium-block { height: 100px; background: linear-gradient(180deg,#fbbf24,#d97706); color: #000; }
.p2 .podium-block { height: 70px;  background: linear-gradient(180deg,#94a3b8,#64748b); color: #000; }
.p3 .podium-block { height: 50px;  background: linear-gradient(180deg,#c2723a,#9a5b2d); color: #fff; }
.score-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.score-row__name { color: var(--muted); }
.score-row__pts { color: var(--gold); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet */
@media (max-width: 900px) {
  .editor-panel { width: 50%; }
  .score-sidebar { width: 160px; }
  .score-sidebar.collapsed { width: 36px; }
}

/* Mobile */
@media (max-width: 680px) {
  /* Stack editor + preview vertically */
  .game-body { flex-direction: column; }

  .editor-panel {
    width: 100% !important;
    min-width: 0;
    height: 60%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .resize-handle { display: none; }

  .right-side { flex: 1; flex-direction: column; overflow: hidden; width:100%; height:40%;}

  /* Score sidebar becomes a thin strip at bottom of right-side */
  .score-sidebar {
    display:none;
    /* width: 100%;
    height: 36px;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-direction: column;
    flex-shrink: 0;
    transition: height .2s ease;
    overflow: hidden; */
  }
  .score-sidebar .score-header { border-bottom: none; flex: 1; padding: 0 12px; height: 36px; }
  .score-sidebar.collapsed { width: 100%; height: 36px; }
  .score-sidebar.collapsed .score-toggle { transform: none; }
  .score-toggle-mobile { transform: rotate(90deg) !important; }

  /* Top bar */
  #top-bar { padding: 0 10px; gap: 8px; height: 46px; }
  .exercise-badge { display: none; }
  #solved-count { display: none; }

  /* Bottom bar */
  .bottom-bar { padding: 8px 12px; gap: 8px; }
  .exercise-desc { font-size: 11px; width: 100%; min-width: 100%; }

  /* Join card */
  .join-card { width: 95%; padding: 28px 18px; }
  .join-logo { font-size: 1.6rem; }

  /* Overlays */
  .overlay-title { font-size: 36px; }
}

@media (max-width: 380px) {
  .join-card { padding: 20px 14px; }
  .timer-display { font-size: 16px; min-width: 48px; }
  .bottom-bar .btn { padding: 8px 12px; font-size: 11px; }
}
