/* Oceans Academy – Science */
:root {
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --ink: #10283a;
  --muted: #587084;
  --line: #d9e4ec;
  --brand: #0a5c8a;
  --brand-ink: #ffffff;
  --brand-2: #10a0a8;
  --deep: #062f4a;
  --phys: #3d5bd9;
  --phys-soft: #e9edfd;
  --life: #22894a;
  --life-soft: #e4f4ea;
  --danger: #c43a3a;
  --danger-soft: #fdecec;
  --ok: #1d7f49;
  --ok-soft: #e3f4ea;
  --shadow: 0 1px 2px rgba(16, 40, 58, .06), 0 6px 18px rgba(16, 40, 58, .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1822;
    --surface: #12232f;
    --surface-2: #172c3a;
    --ink: #e6eef4;
    --muted: #9bb0c0;
    --line: #23394a;
    --brand: #4fb3e6;
    --brand-ink: #062233;
    --brand-2: #3cc8c9;
    --deep: #05141e;
    --phys: #8fa4ff;
    --phys-soft: #1b2650;
    --life: #5cd18b;
    --life-soft: #123524;
    --danger: #ff7b7b;
    --danger-soft: #3a1919;
    --ok: #63d394;
    --ok-soft: #12321f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand); }
img, svg { display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 500; white-space: nowrap; }
.brand img { width: 32px; height: 32px; }
.brand b { color: var(--brand); font-weight: 700; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 8px 12px; border-radius: 10px;
}
.topnav a svg { width: 18px; height: 18px; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--brand); background: var(--surface-2); }
@media (max-width: 520px) {
  .brand span { font-size: 15px; }
  .topnav a span { display: none; }
  .topnav a { padding: 8px 10px; }
  .topnav a:first-child { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(140deg, var(--deep) 0%, #0a5c8a 55%, #10a0a8 100%);
  color: #fff;
  padding: 56px 0 96px;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.14) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 62%, rgba(255,255,255,.08) 0 46px, transparent 47px),
    radial-gradient(circle at 74% 78%, rgba(255,255,255,.10) 0 18px, transparent 19px);
  pointer-events: none;
}
.hero .wrap { position: relative; }
.hero h1 { font-size: clamp(30px, 6vw, 52px); font-weight: 700; }
.hero .eyebrow { color: #9fe6ea; }
.hero .teacher {
  display: inline-block; margin: 16px 0 0; padding: 6px 14px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; font-size: 17px; font-weight: 500;
}
.waves { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 56px; }
.waves path { fill: var(--bg); }

.eyebrow {
  margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-2);
}

/* ---------- page head & crumbs ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 20px 0 0; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs .sep { opacity: .5; }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }

.page-head { padding: 20px 0 8px; }
.page-head h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
.page-head .lead { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.page-head-subject { display: flex; align-items: center; gap: 16px; }

.section { margin: 32px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 21px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-head h2 svg { width: 20px; height: 20px; color: var(--brand-2); }
.link-more { font-weight: 500; font-size: 15px; text-decoration: none; white-space: nowrap; }
.link-more:hover { text-decoration: underline; }

/* ---------- grade cards ---------- */
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.grade-card {
  position: relative; display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 40px 18px 18px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease; gap: 14px;
}
.grade-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.grade-num {
  flex: none; width: 68px; height: 72px; border-radius: 14px;
  background: linear-gradient(150deg, #0a5c8a, #10a0a8); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.grade-num small { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.grade-num strong { font-size: 34px; line-height: 1; font-weight: 700; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chip { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; font-weight: 500; }
.chip svg { width: 20px; height: 20px; flex: none; }
.chip em { font-style: normal; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.chip-physical-science svg { color: var(--phys); }
.chip-physical-science em { background: var(--phys-soft); color: var(--phys); }
.chip-life-science svg { color: var(--life); }
.chip-life-science em { background: var(--life-soft); color: var(--life); }
.chev { position: absolute; right: 14px; top: 50%; width: 22px; height: 22px; margin-top: -11px; color: var(--muted); }

/* ---------- subject cards ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.subject-card {
  position: relative; display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 48px 22px 20px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  border-top: 5px solid var(--accent); transition: transform .15s ease;
}
.subject-card:hover { transform: translateY(-2px); }
.subject-physical-science { --accent: var(--phys); --accent-soft: var(--phys-soft); }
.subject-life-science { --accent: var(--life); --accent-soft: var(--life-soft); }
.subject-icon {
  flex: none; width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.subject-icon svg { width: 38px; height: 38px; }
.subject-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.subject-text strong { font-size: 21px; font-weight: 600; }
.subject-text span { color: var(--muted); font-size: 15px; }
.subject-text small { color: var(--accent); font-weight: 500; font-size: 14px; }

/* ---------- unit + lessons ---------- */
.unit {
  margin-top: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.unit-head { padding: 20px 20px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.unit-label { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.unit-head h2 { font-size: 22px; font-weight: 600; }
.unit-meta { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.lessons { list-style: none; margin: 0; padding: 8px; }
.lesson {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 14px 44px 14px 12px; border-radius: 12px; color: var(--ink); text-decoration: none;
}
.lesson:hover { background: var(--surface-2); }
.lessons li + li .lesson { border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.lessons li + li .lesson:hover { border-radius: 12px; }
.lesson-num {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 17px;
}
@media (prefers-color-scheme: dark) { .lesson-num { color: #0b1822; } }
.lesson-text { display: flex; flex-direction: column; min-width: 0; }
.lesson-text small { color: var(--muted); font-size: 13px; font-weight: 500; }
.lesson-text strong { font-size: 17px; font-weight: 600; }
.back { margin: 24px 0 0; }
.back a { text-decoration: none; font-weight: 500; }

/* ---------- posts ---------- */
.posts { display: grid; gap: 14px; }
.post {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); border-left: 5px solid var(--brand-2);
  min-width: 0;
}
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tag { font-weight: 600; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--brand); }
.tag-new { background: var(--ok-soft); color: var(--ok); }
.post h3 { font-size: 19px; font-weight: 600; margin: 8px 0 0; overflow-wrap: anywhere; }
.post-body { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-body a { overflow-wrap: anywhere; }
.post-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.posts-empty, .posts-msg {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted);
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.filter {
  font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.filter:hover { border-color: var(--brand); }
.filter[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 16px; line-height: 1.2;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger.confirm { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow);
}
.card h2 { font-size: 20px; font-weight: 600; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 16px; color: var(--ink);
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }
.counter { align-self: flex-end; font-size: 12px; color: var(--muted); }

.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-size: 15px; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
[hidden] { display: none !important; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
.login-card { max-width: 420px; margin: 24px auto 0; }
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- footer ---------- */
.footer { margin-top: 56px; border-top: 1px solid var(--line); background: var(--surface); }
.footer p { margin: 0; padding: 20px 0; color: var(--muted); font-size: 14px; }
.footer b { color: var(--ink); font-weight: 600; }

:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
