/* HandGlyph Classroom + Live — app-inspired UI */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
  --hg-font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --hg-ink: #0b3554;
  --hg-muted: #64748b;
  --hg-accent: #1a6bb5;
  --hg-canvas: #9e9e9e;
  --hg-canvas-ink: #1a1a1a;
  --hg-bar-h: 52px;
  --hg-dock-h: 72px;
  --hg-radius: 14px;
  --hg-shadow: 0 12px 40px rgba(11, 53, 84, 0.12);
  --hg-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.classroom-page,
.hg-live {
  font-family: var(--hg-font);
}

/* —— Buttons (fix native gray buttons) —— */
.classroom-page .btn,
.hg-live .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  cursor: pointer;
  font-family: var(--hg-font);
  transition: transform 0.15s var(--hg-ease), box-shadow 0.15s var(--hg-ease),
    background 0.15s;
}

.classroom-page .btn:active,
.hg-live .btn:active {
  transform: scale(0.98);
}

.classroom-page .btn-danger,
.hg-live .btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.classroom-page .btn-danger:hover,
.hg-live .btn-danger:hover {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
  text-decoration: none;
}

.classroom-page .btn-ghost,
.hg-live .btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.hg-live .btn-ghost {
  background: rgba(11, 53, 84, 0.06);
  color: var(--hg-ink);
  border: 1px solid #e2e8f0;
}

/* —— Classroom hub —— */
.classroom-page {
  background: linear-gradient(165deg, #e8f2fc 0%, #f4f6f9 45%, #f8fafc 100%);
  min-height: 100vh;
}

.classroom-page .account-dashboard {
  max-width: 920px;
  padding-bottom: 4rem;
}

.classroom-hero {
  margin-bottom: 2rem;
  animation: hg-fade-up 0.5s var(--hg-ease) both;
}

.classroom-hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.25rem 0 0.5rem;
}

.classroom-card {
  background: #fff;
  border: 1px solid rgba(11, 53, 84, 0.08);
  border-radius: var(--hg-radius);
  padding: 1.5rem 1.65rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--hg-shadow);
  animation: hg-fade-up 0.55s var(--hg-ease) both;
}

.classroom-card:nth-child(2) {
  animation-delay: 0.06s;
}

.classroom-card h2 {
  margin: 0 0 1.15rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.classroom-live-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #0b3554 0%, #1a6bb5 55%, #2d8fd4 100%);
  color: #fff;
  border-radius: var(--hg-radius);
  box-shadow: 0 20px 50px rgba(11, 53, 84, 0.28);
  animation: hg-pulse-glow 3s ease-in-out infinite;
}

@keyframes hg-pulse-glow {
  0%,
  100% {
    box-shadow: 0 20px 50px rgba(11, 53, 84, 0.28);
  }
  50% {
    box-shadow: 0 24px 56px rgba(26, 107, 181, 0.4);
  }
}

.classroom-live-banner strong {
  font-size: 1.1rem;
}

.classroom-live-banner p {
  margin: 0.35rem 0 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

.classroom-live-banner .btn-primary {
  background: #fff;
  color: var(--hg-ink);
  padding: 0.7rem 1.35rem;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.classroom-table-wrap,
.hg-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #e8eef4;
}

.hg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.hg-table th,
.hg-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
}

.hg-table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hg-muted);
  background: #f8fafc;
}

.hg-table tbody tr {
  transition: background 0.15s;
}

.hg-table tbody tr:hover {
  background: #f8fbff;
}

.hg-table tbody tr:last-child td {
  border-bottom: none;
}

.hg-table .hg-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--hg-muted);
  word-break: break-all;
}

.hg-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.classroom-link-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 12rem;
}

.classroom-link-chip {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--hg-accent);
  background: #edf6ff;
  border-radius: 6px;
  word-break: break-all;
}

.classroom-copy-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hg-accent);
  background: transparent;
  border: 1px solid #c5dff5;
  border-radius: 6px;
  cursor: pointer;
}

.classroom-copy-btn:hover {
  background: #edf6ff;
}

.classroom-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--hg-muted);
}

.classroom-section-label {
  margin: 1.5rem 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--hg-muted);
}

.classroom-form-card {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed #e2e8f0;
}

@keyframes hg-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* —— Live board (HandGlyph app style) —— */
.hg-live {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  overflow: hidden;
}

.hg-live.hg-live-board-mode {
  height: 100vh;
  height: 100dvh;
}

.hg-live-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  min-height: var(--hg-bar-h);
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 50;
}

.hg-live-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--hg-accent);
  text-decoration: none;
  flex-shrink: 0;
}

.hg-live-brand:hover {
  text-decoration: none;
}

.hg-live-brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.hg-live-class {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hg-live-class h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--hg-ink);
}

.hg-pill {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--hg-accent);
  background: #e8f4fc;
  border-radius: 999px;
}

.hg-live-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.hg-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hg-muted);
  margin-right: 0.25rem;
}

.hg-live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.hg-live-dot[data-state="ok"] {
  color: #15803d;
}

.hg-live-dot[data-state="ok"]::before {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  animation: hg-blink 2s ease infinite;
}

.hg-live-dot[data-state="error"]::before {
  background: #ef4444;
}

@keyframes hg-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.hg-live-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* Flow panels (join / wait) */
.hg-flow {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: linear-gradient(165deg, #e8f2fc 0%, #f4f6f9 100%);
}

.hg-flow-card {
  width: 100%;
  max-width: 440px;
  padding: 2.25rem 2rem;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--hg-shadow);
  animation: hg-fade-up 0.45s var(--hg-ease) both;
}

.hg-flow-card h1,
.hg-flow-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.hg-wait-spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto 1.25rem;
  border: 3px solid #e8eef4;
  border-top-color: var(--hg-accent);
  border-radius: 50%;
  animation: live-spin 0.85s linear infinite;
}

@keyframes live-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Board stage */
.hg-stage-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.hg-stage {
  flex: 1;
  position: relative;
  min-height: 200px;
  background: var(--hg-canvas);
}

#live-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#live-canvas.hg-readonly {
  cursor: default;
}

/* Floating tool dock — like iPad HandGlyph */
.hg-dock {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 20;
  transition: opacity 0.25s, transform 0.25s var(--hg-ease);
}

.hg-dock.hg-dock-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.hg-dock-divider {
  width: 1px;
  height: 28px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 0.15rem;
}

.hg-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.15s, transform 0.15s;
}

.hg-tool-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.hg-tool-btn.hg-active {
  background: rgba(26, 107, 181, 0.15);
  box-shadow: inset 0 0 0 2px var(--hg-accent);
}

.hg-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s;
}

.hg-color-btn.hg-active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--hg-ink);
}

.hg-canvas-toast {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(11, 53, 84, 0.75);
  border-radius: 999px;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s;
}

.hg-canvas-toast.hg-show {
  opacity: 1;
}

/* Teacher roster drawer */
.hg-roster-drawer {
  width: min(380px, 92vw);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #e8eef4;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.06);
  transform: translateX(0);
  transition: transform 0.35s var(--hg-ease), width 0.35s var(--hg-ease);
  z-index: 40;
}

.hg-roster-drawer.hg-collapsed {
  width: 0;
  transform: translateX(100%);
  border: none;
  overflow: hidden;
}

.hg-roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid #edf2f7;
}

.hg-roster-head h2 {
  margin: 0;
  font-size: 1rem;
}

.hg-roster-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1.5rem;
}

.hg-roster-section {
  margin-bottom: 1.25rem;
}

.hg-roster-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hg-muted);
}

.hg-badge-count {
  display: inline-flex;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 999px;
  vertical-align: middle;
}

.hg-badge-count.hg-zero {
  background: #f1f5f9;
  color: var(--hg-muted);
}

.hg-roster-drawer .hg-table {
  font-size: 0.82rem;
}

.hg-roster-drawer .hg-table th,
.hg-roster-drawer .hg-table td {
  padding: 0.55rem 0.5rem;
}

.hg-btn-xs {
  padding: 0.28rem 0.5rem !important;
  font-size: 0.72rem !important;
  border-radius: 6px !important;
}

@media (max-width: 768px) {
  .hg-live-bar {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    min-height: auto;
  }

  .hg-live-class {
    order: 3;
    width: 100%;
  }

  .hg-roster-drawer:not(.hg-collapsed) {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(100%, 360px);
  }

  .hg-dock {
    max-width: calc(100% - 2rem);
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .classroom-live-banner,
  .hg-wait-spinner,
  .hg-live-dot[data-state="ok"]::before {
    animation: none;
  }

  .classroom-card,
  .classroom-hero,
  .hg-flow-card {
    animation: none;
  }
}
