/* Launch Hub Student Gallery — parent-facing, phone-first.
   Sections: tokens · base · header · buttons/forms · login · class grid ·
   project cards · project viewer (Scratch / Python / image) · class photos. */

:root {
  --blue:      #2E6BE6;
  --blue-deep: #214FB0;
  --orange:    #F7931E;
  --green:     #16a34a;
  --coral:     #d9463e;
  --ink:       #1B2333;
  --body:      #4a5263;
  --muted:     #7c8598;
  --line:      #E4EAF1;
  --bg:        #F4F8FC;
  --surface:   #FFFFFF;
  --r-sm: 10px;
  --r-md: 16px;
  --shadow: 0 6px 20px -12px rgba(27, 35, 51, .35);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ── base ── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--body); font-family: var(--font); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
a { color: var(--blue-deep); }
.muted { color: var(--muted); }
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }
[hidden] { display: none !important; }

/* ── header ── */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; font-size: 15px; }
.brand img { flex: 0 0 auto; border-radius: 8px; }
.brand strong { color: var(--blue-deep); }

/* ── buttons / forms ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--blue); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-link { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; padding: 8px 4px; }
.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; text-decoration: none; }
.msg-error { color: var(--coral); font-weight: 600; margin: 12px 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; box-shadow: var(--shadow); }

/* ── login ── */
.login { max-width: 400px; margin: 8vh auto 0; text-align: center; }
.login h1 { margin-bottom: 6px; }
.login form { margin-top: 18px; display: grid; gap: 12px; }
.login input { width: 100%; min-height: 50px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; text-align: center; }
.login input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ── class grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.class-card { display: block; text-decoration: none; color: inherit; }
.class-card:hover, .class-card:focus-visible { border-color: var(--blue); }
.class-card h2 { margin-bottom: 4px; color: var(--blue-deep); }

/* ── project cards (inside a class) ── */
.student { margin-top: 18px; }
.student h3 { font-size: 16px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.item-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; text-decoration: none; color: var(--ink); min-width: 0; }
.item-card:hover, .item-card:focus-visible { border-color: var(--blue); }
.item-thumb { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; background: var(--bg); font-size: 40px; }
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-body { padding: 8px 10px 10px; min-width: 0; }
.item-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-tag { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; }
.tool-scratch { background: var(--orange); }
.tool-python  { background: var(--blue-deep); }
.tool-create  { background: var(--green); }

/* ── project viewer ── */
.viewer-head { margin-bottom: 14px; }
.viewer-head .by { color: var(--muted); font-size: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }

/* Scratch: the player has a fixed natural size; .scratch-stage reserves
   the scaled height and the iframe is scaled to the available width by
   app.js (transform), so a 375px phone sees the whole stage. */
.scratch-stage { position: relative; width: 100%; max-width: 512px; margin: 0 auto; overflow: hidden; border-radius: var(--r-sm); background: #fff; border: 1px solid var(--line); }
.scratch-stage iframe { display: block; border: 0; transform-origin: 0 0; }

/* Python: output (turtle drawing + printed text), optional source. */
.py-output { display: grid; gap: 12px; }
.py-canvas { min-height: 80px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: auto; }
.py-canvas:empty { display: none; }
.py-console, .py-code { margin: 0; padding: 12px; border-radius: var(--r-sm); font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; overflow: auto; }
.py-console { min-height: 64px; max-height: 320px; background: #0f172a; color: #e2e8f0; }
.py-console .err { color: #fca5a5; }
.py-code { background: var(--surface); border: 1px solid var(--line); color: var(--ink); max-height: 480px; }
details.code-toggle { margin-top: 16px; }
details.code-toggle summary { cursor: pointer; font-weight: 700; color: var(--blue-deep); padding: 6px 0; }

.art { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; }

/* ── class photos ── */
.section-title { margin-top: 30px; padding-bottom: 8px; border-bottom: 2px solid var(--line); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.photo-tile { aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; cursor: pointer; }
.photo-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-tile--missing { cursor: default; opacity: .4; }
.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .92); }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.lightbox__status { color: #fff; }
.lightbox__close { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
