/* LMS student portal (portal.php). Mobile-first; no inline styles are used by the templates (CSP).
 * Visual identity follows the institutional site (4tchannel.com.br): greens #064E3B / #0F9E75 / #10B981, amber accent,
 * Space Grotesk for headings and Inter for text. Fonts are self-hosted (assets/fonts/, SIL Open Font License) because
 * the portal CSP only allows 'self'. Button/background greens are slightly darker than the site's #0F9E75 to keep
 * white text above 4.5:1 contrast. */
@font-face { font-family: 'Space Grotesk'; src: url(fonts/space-grotesk-latin.woff2) format('woff2'); font-weight: 500 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(fonts/inter-latin.woff2) format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #dde5e0;
  --nav-bg: #064e3b;
  --nav-bg-2: #0a6b4f;
  --nav-link: #a7f3d0;
  --primary: #0b8460;        /* 4.68:1 with white text */
  --primary-hover: #087f5b;
  --primary-text: #ffffff;
  --link: #047857;           /* 5.48:1 on white */
  --accent: #10b981;
  --focus: rgba(16, 185, 129, .45);
  --done-bg: #d1fae5;
  --done-fg: #065f46;
  --current-bg: #fef3c7;
  --current-fg: #92400e;
  --locked-bg: #e2e8f0;
  --locked-fg: #475569;
  --alert-bg: #fee2e2;
  --alert-fg: #991b1b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --auth-top: #064e3b;
  --auth-top-2: #0a6b4f;
  --radius: 14px;
  --gutter: 16px;
  --font-head: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07130f;
    --surface: #0e2019;
    --text: #e6f4ee;
    --muted: #9db8ae;       /* 7.99:1 on --surface */
    --border: #1f3b32;
    --nav-bg: #031a13;
    --nav-bg-2: #06291f;
    --nav-link: #6ee7b7;
    --primary: #34d399;     /* 9.85:1 on --bg */
    --primary-hover: #6ee7b7;
    --primary-text: #052e22; /* 7.69:1 on the dark --primary */
    --link: #6ee7b7;
    --accent: #34d399;
    --focus: rgba(52, 211, 153, .5);
    --done-bg: #0f3d2c;
    --done-fg: #a7f3d0;
    --current-bg: #4a3410;
    --current-fg: #fcd34d;
    --locked-bg: #1b2d27;
    --locked-fg: #a7bdb4;
    --alert-bg: #451a1a;
    --alert-fg: #fca5a5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --auth-top: #031a13;
    --auth-top-2: #06291f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
a:focus-visible, .btn:focus-visible, .input:focus-visible, .choice input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 1.55rem; font-weight: 700; margin: 0 0 14px; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 10px; }
img, video, iframe, table { max-width: 100%; }

.wrap { max-width: 920px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.muted { color: var(--muted); font-size: .9rem; }

/* nav */
.nav {
  position: static; z-index: 10;
  background: linear-gradient(135deg, var(--nav-bg), var(--nav-bg-2)); color: #fff;
  padding: 8px var(--gutter); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  box-shadow: 0 2px 12px rgba(6, 78, 59, .25);
}
.nav-brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; letter-spacing: -.01em; }
.nav-logo { height: 30px; width: auto; display: block; }
.nav-brand-sub { font-size: .8rem; font-weight: 500; color: var(--nav-link); padding: 2px 8px; border: 1px solid rgba(167, 243, 208, .35); border-radius: 999px; }
.nav-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 2px; flex: 1 1 100%; }
.nav-links a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; margin: 0; border-radius: 10px; font-size: .94rem;
  color: var(--nav-link); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-links a.active { color: #fff; font-weight: 600; background: rgba(255, 255, 255, .16); }
.nav-links li:last-child { margin-left: auto; }
.nav-links a.nav-out { color: #fecaca; }
.nav-links a.nav-out:hover { background: rgba(254, 202, 202, .14); color: #fff; }
.nav a:focus-visible { outline-color: #a7f3d0; }

/* pages without navigation (login, code verification, status): brand header over a green band */
body.page-auth { background: linear-gradient(180deg, var(--auth-top) 0, var(--auth-top-2) 240px, var(--bg) 240px); min-height: 100vh; }
.auth-brand { text-align: center; padding: 40px var(--gutter) 52px; }
.auth-logo { height: 46px; width: auto; display: inline-block; }
.auth-tag { margin: 10px 0 0; color: var(--nav-link); font-family: var(--font-head); font-weight: 500; letter-spacing: .02em; }
body.page-auth .wrap { padding-top: 0; }

/* cards & forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card-narrow { max-width: 440px; margin: -26px auto 24px; padding: 24px; }
.card-narrow h1 { font-size: 1.35rem; }
fieldset.card { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; }
.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}
.input:focus { border-color: var(--accent); }
label { font-size: .9rem; color: var(--muted); }
.choice {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; margin: 0 0 8px;
  color: var(--text); font-size: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--done-bg); }
.choice input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 10px; font: inherit; font-family: var(--font-head); font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--link); border-color: var(--primary); }
.btn-secondary:hover { background: var(--done-bg); }
.btn-block { display: flex; width: 100%; margin: 0 0 10px; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[hidden] { display: none; }

.alert { background: var(--alert-bg); color: var(--alert-fg); padding: 10px 14px; border-radius: 10px; margin: 0 0 12px; border: 1px solid transparent; }
.msg { min-height: 1.5em; margin: 8px 0; }
.exam-result { margin-top: 16px; font-weight: 600; }
.exam-result[hidden] { display: none; }
.exam-result-ok { background: var(--done-bg); color: var(--done-fg); }
.exam-result-warn { background: var(--current-bg); color: var(--current-fg); }
.status-text { font-size: 1.05rem; }

/* badges & progress */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-done { background: var(--done-bg); color: var(--done-fg); }
.badge-current { background: var(--current-bg); color: var(--current-fg); }
.badge-locked { background: var(--locked-bg); color: var(--locked-fg); }
progress.bar { width: 100%; height: 10px; border: 0; border-radius: 999px; overflow: hidden; background: var(--locked-bg); accent-color: var(--accent); appearance: none; -webkit-appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--locked-bg); border-radius: 999px; }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; }
.step {
  display: flex; align-items: flex-start; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin: 0 0 10px; min-height: 44px; box-shadow: var(--shadow);
}
.step-done { border-left-color: var(--accent); }
.step-current { border-left-color: #f59e0b; }
.step-locked { opacity: .78; border-left-color: #cbd5e1; }
.step-icon { flex: none; width: 34px; height: 34px; line-height: 34px; text-align: center; font-size: 1.1rem; border-radius: 50%; background: var(--locked-bg); }
.step-done .step-icon { background: var(--done-bg); }
.step-current .step-icon { background: var(--current-bg); }
.step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-title { font-family: var(--font-head); font-weight: 600; }
a.step-title { text-decoration: none; }
a.step-title:hover { text-decoration: underline; }
.step-reason { color: var(--muted); font-size: .9rem; }

/* lesson player (script: assets/lms_player.js) */
.intro { margin: 0 0 16px; }
.intro img { height: auto; }
.player { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; box-shadow: var(--shadow); }
.player:empty { display: none; }
.player-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.notice { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.timebar { display: inline-block; font-family: var(--font-head); font-weight: 600; margin: 8px 0; padding: 6px 12px; border-radius: 999px; background: var(--done-bg); color: var(--done-fg); }
.files { list-style: none; margin: 0; padding: 0; }
.files li { padding: 8px 0; min-height: 44px; }

@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .nav { position: sticky; top: 0; }
  .nav-links { flex: 1 1 auto; }
  .nav-links a { padding: 0 12px; font-size: 1rem; }
  h1 { font-size: 1.75rem; }
  .btn-block { display: inline-flex; width: auto; min-width: 220px; margin-right: 8px; }
  .card-narrow .btn-block { display: flex; width: 100%; }
  .card { padding: 22px; }
}

/* player glue (assets/lms_player.js): overlay over the video, own controls, idle prompt */
.player-overlay { position: absolute; inset: 0; z-index: 2; background: transparent; cursor: pointer; }
.player-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0 0; }
.player-controls .btn { min-width: 110px; }
.player-controls input[type=range] { flex: 1 1 120px; min-width: 0; max-width: 220px; accent-color: var(--primary); }
.player-progress { flex: 1 1 100%; height: 8px; background: var(--locked-bg); border-radius: 4px; overflow: hidden; }
.player-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.idle-prompt { margin: 10px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--current-bg); color: var(--current-fg); text-align: center; font-weight: 600; }
.idle-prompt[hidden], .player-controls[hidden] { display: none; }
