/* Hilltoppers Study Topping.
 * Matches the Hilltoppers popup: light surface, SJA green accent, the same
 * card, button and input shapes, and the same system font stack.
 * Sized for the Topping iframe: about 318px wide, ~360px tall. No fixed pixel
 * widths; text wraps and stays inside the card. The wrapper [data-topping-content]
 * carries the natural height that resize.js reports for Fit content. */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-muted: #f0f2f5;
  --border: rgba(17, 17, 17, 0.18);
  --border-soft: rgba(17, 17, 17, 0.08);
  --text: #111111;
  --heading: #161b22;
  /* Hilltoppers uses #7d8591 for tertiary text, but it only reaches 3.5:1 on
     this surface. #647067 is the same source family (.footer-action) and clears
     AA at 4.9:1, so notes, labels and status text stay readable. */
  --muted: #647067;
  --label: #555f6a;
  --accent: #1a7f37;
  --accent-muted: rgba(26, 127, 55, 0.12);
  /* The popup's primary CTA (.grade-prompt-continue): a soft mint pill with
     dark-green text hovering to a brighter mint — not a saturated green fill. */
  --accent-strong: #14532d;
  --accent-soft: #abe0bc;
  --accent-soft-hover: #8fd4a6;
  /* Neutral pill (.grade-prompt-row) behind chips and quiet buttons. */
  --pill: #ebeef2;
  --pill-hover: #dfe3e8;
  --danger: #bc4c2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

/* The reported-height element. Natural height by design: do not give it a
   viewport-relative or fixed height, or the Topping cannot shrink. */
[data-topping-content] {
  display: flow-root;
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 9px;
}

.app { display: flex; flex-direction: column; gap: 9px; }

.view { display: flex; flex-direction: column; gap: 9px; }
.view[hidden] { display: none; }

/* Top bar: no mark, title or credit line. The Topping is already inside
   Hilltoppers, so repeating the branding there is noise; the only chrome left
   is the connection dot and the settings gear. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #a0a7b0; flex: 0 0 auto; }
.dot.online { background: var(--accent); }
.dot.waiting { background: #f39c3d; }
.dot.offline { background: var(--danger); }

/* The gear is an icon at rest and grows the word "Settings" on hover or
   keyboard focus, so the toolbar stays quiet but the control still says what
   it is. */
.gear {
  display: inline-flex;
  align-items: center;
  padding: 4px 6px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.gear:not(:disabled):hover { background: rgba(17, 17, 17, 0.06); color: var(--label); }
/* .gear sets display, so the hidden attribute has to be repeated here. */
.gear[hidden] { display: none; }
.gear-icon { width: 18px; height: 18px; display: block; }
.gear-label {
  max-width: 0;
  margin-right: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.15s ease, margin-right 0.15s ease, opacity 0.15s ease;
}
.gear:hover .gear-label,
.gear:focus-visible .gear-label { max-width: 72px; margin-right: 6px; opacity: 1; }


/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--heading); }
.code-card { align-items: center; text-align: center; }
.field-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--label);
}
.code {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}
.note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.error { margin: 0; font-size: 12px; line-height: 1.5; color: var(--danger); font-weight: 500; }
.error[hidden] { display: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Buttons: the popup draws two shapes and these are exactly those two. A
   prominent action is the mint pill — .grade-prompt-continue, #abe0bc on
   #14532d, 999px, hovering to #8fd4a6. Everything else is the bordered
   rectangle of .schedule-toggle: 6px, a 0.12 hairline, hovering to #f3f5f7 on a
   0.18 border. A bordered *pill* is a shape the popup never draws, which is
   what made the secondary and ghost buttons look invented. */
button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: var(--surface);
  /* #4a5560, the text colour of both .schedule-toggle and .grade-prompt-row. */
  color: #4a5560;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
button:disabled { opacity: 0.55; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* The one pill in the system. */
.primary {
  border-radius: 999px;
  padding: 9px 15px;
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.primary:not(:disabled):hover { background: var(--accent-soft-hover); border-color: var(--accent-soft-hover); }

/* .schedule-toggle, to the pixel. */
.secondary { border-color: rgba(17, 17, 17, 0.12); }
.secondary:not(:disabled):hover { background: #f3f5f7; border-color: rgba(17, 17, 17, 0.18); }

/* .footer-action, to the pixel: bare text, 4px 0, and hovering changes the
   colour only — it never paints a box behind the word. width:fit-content keeps
   the word-sized button word-sized in the column views, so the focus ring
   outlines the word instead of the whole row. */
.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 400;
  padding: 4px 0;
  width: fit-content;
}
.ghost:not(:disabled):hover { color: var(--accent); }
.ghost.danger { color: var(--danger); align-self: flex-start; }
.ghost.danger:not(:disabled):hover { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  button, .gear-label { transition: none; }
}

/* Inputs */
.join { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.code-input, .composer input {
  min-width: 0;
  min-height: 38px;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  background: #ffffff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.code-input { flex: 1 1 96px; text-transform: uppercase; letter-spacing: 1px; }
.code-input::placeholder, .composer input::placeholder { color: var(--muted); letter-spacing: normal; }
.code-input:focus, .composer input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.controls { align-items: center; }

/* Screen preview */
.video-wrap {
  position: relative;
  background: #000000;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  height: 150px;
  flex: 0 0 auto;
}
.video-wrap[hidden] { display: none; }
.video-wrap video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-label {
  position: absolute;
  left: 7px;
  top: 6px;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.72);
  color: #ffffff;
}
.video-full {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font: inherit;
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.72);
  color: #ffffff;
  cursor: pointer;
}
.video-full:hover { background: rgba(17, 17, 17, 0.9); }
/* What the person sharing sees instead of their own picture. */
.video-message {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.video-message[hidden] { display: none; }

/* Fill tab: an in-page mode, not the Fullscreen API. The picture takes the whole
   viewport height and scrolls with the page, which also sidesteps the iframe
   fullscreen restriction. */
.app.filling .topbar,
.app.filling #view-session > .controls,
.app.filling #view-session > .messages,
.app.filling #view-session > .composer,
.app.filling #end { display: none; }
.app.filling .video-wrap {
  height: calc(100vh - 18px);
  max-height: none;
  border: 0;
  border-radius: 0;
}
.app.filling .video-full { right: 12px; bottom: 12px; }

#view-session { position: relative; }

/* Floating chat over the filled picture. */
.chat-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  width: min(248px, 82%);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(17, 17, 17, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(17, 17, 17, 0.28);
}
.chat-float[hidden] { display: none; }
.chat-float-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: 0;
  background: var(--surface-muted);
  color: var(--heading);
  font-size: 12px;
  font-weight: 600;
}
.chat-float-bar .chev { color: var(--muted); font-size: 11px; }
.chat-float-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}
.chat-float-body[hidden] { display: none; }
/* Inside the float the list is capped and the composer stays visible. */
.chat-float .messages { min-height: 72px; max-height: 168px; }
.chat-float .composer { gap: 6px; }
.chat-float .composer input { min-width: 0; }

/* Chat: the popup's schedule list — one bordered surface, rows divided by a
   hairline. */
.messages {
  display: flex;
  flex-direction: column;
  min-height: 84px;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.msg {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 11px;
}
.msg + .msg { border-top: 1px solid var(--border-soft); }
.msg .who { font-size: 11px; font-weight: 600; color: var(--muted); }
.msg .text { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.msg.mine .who { color: var(--accent); }
.msg.system { background: var(--surface-muted); }
.msg.system .text { color: var(--muted); font-style: italic; }

.composer { display: flex; gap: 8px; align-items: stretch; }
.composer input { flex: 1 1 auto; }

/* Overlays (consent, first-run notice) */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(17, 17, 17, 0.55);
}
.overlay[hidden] { display: none; }
.dialog { width: 100%; max-width: 300px; box-shadow: 0 5px 16px rgba(17, 17, 17, 0.12); }
.consent-check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--label); }
.consent-check input { margin: 2px 0 0; }

/* Narrower than the Topping width, if it ever happens. */
@media (max-width: 340px) {
  .composer, .join { gap: 6px; }
  .code { font-size: 20px; }
}

/* Sign-in form */
.stack { display: flex; flex-direction: column; gap: 5px; }
.stack .field-label { margin-top: 4px; }
.stack input {
  min-width: 0;
  min-height: 38px;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  background: #ffffff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.stack input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.stack .primary { margin-top: 8px; }

/* The signed-in student's own name */
.student-name { font-size: 15px; font-weight: 600; color: var(--heading); }
/* The account email, shown in Settings. A long address wraps instead of
   widening the dialog past the Topping. */
.student-email { font-size: 13px; font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }

/* Study-hall block picker */
.blocks { display: flex; flex-wrap: wrap; gap: 6px; }
/* Neutral pill (.grade-prompt-row); ticked = mint pill (.grade-prompt-row.selected). */
.block {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--pill);
  color: #4a5560;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.block:hover { background: var(--pill-hover); color: #161b22; }
.block:has(input:checked) {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
/* .grade-prompt-row says which one is picked by its own fill, not with a
   checkbox drawn inside the pill. The input stays for the form and the
   keyboard, out of sight; the pill is the answer to it. The fill is what shows
   the tick, so this relies on :has — Chrome 105+, which the popup is. */
.block input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.block:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Who is free to study: the popup's schedule list — one bordered surface with
   rows divided by a hairline. */
.students {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.students:empty { display: none; }
.student {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  padding: 7px 11px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.student + .student { border-top: 1px solid var(--border-soft); }
.student:hover { background: var(--surface-muted); }
.student .student-name { font-size: 13px; font-weight: 600; color: var(--heading); }
.student .student-where { font-size: 11px; color: var(--muted); }

.email-input { text-transform: none; letter-spacing: normal; }
