/* =========================================================================
   Science Lab — v4 theme.
   Loaded after app.css. Re-tokens the palette and typography, then restyles
   the surfaces that carry the brand: header, hero, cards, buttons, dialogs.
   app.css keeps providing the structural rules, so nothing loses behaviour.
   ========================================================================= */

/* ---------- tokens ---------- */
:root {
  /* palette — teal study desk, warm paper, gold highlight */
  --bg:            #f7f8f5;
  --ink:           #16302f;
  --ink-soft:      #5b6f74;
  --line:          #dce5e4;
  --line-soft:     #e9efee;
  --surface:       #ffffff;
  --surface-1:     #f2f6f4;
  --surface-2:     #e9f0ee;
  --surface-3:     #dde7e5;

  --primary:       #1a7f75;
  --on-primary:    #ffffff;
  --hero:          #17827a;
  --hero-deep:     #123f42;
  --highlight:     #e0a52e;
  --accent:        #b4671b;
  --ok:            #1c7a52;
  --danger:        #b3261e;

  /* type */
  --font-sans:    "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* spacing — 8px scale */
  --s1: 4px;  --s2: 8px;  --s3: 16px; --s4: 24px;
  --s5: 32px; --s6: 48px; --s7: 64px; --s8: 80px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --shadow-1: 0 14px 35px rgba(20, 48, 47, .07);
  --shadow-2: 0 22px 60px rgba(20, 48, 47, .14);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1918; --ink: #e7efed; --ink-soft: #9fb3b1;
    --line: #23403d; --line-soft: #1b312f;
    --surface: #132321; --surface-1: #16292700; --surface-1: #162927;
    --surface-2: #1b322f; --surface-3: #214038;
    --shadow-1: 0 14px 35px rgba(0,0,0,.4);
    --shadow-2: 0 22px 60px rgba(0,0,0,.55);
  }
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100% }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto } }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3, .page-title, .section-title { font-family: var(--font-display); letter-spacing: -.01em }
a { color: var(--primary) }
button, a { -webkit-tap-highlight-color: transparent }

/* ---------- layout ---------- */
.wrap { width: min(100% - 2.5rem, 1200px); margin-inline: auto }
.section { padding-block: var(--s7) }
@media (max-width: 639px) { .section { padding-block: var(--s6) } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 44px; padding: .7rem 1.1rem;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font-sans); font-size: .93rem; font-weight: 700;
  text-decoration: none; cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { transform: translateY(-1px) }
.btn-lg { min-height: 52px; padding-inline: 1.35rem; font-size: 1rem }
.btn-sm { min-height: 40px; padding: .45rem .85rem; font-size: .85rem }
.btn-solid { background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 24px rgba(26,127,117,.24) }
.btn-solid:hover { background: #176e66 }
.btn-light { background: var(--surface); color: var(--hero-deep); box-shadow: 0 12px 30px rgba(12,40,44,.18) }
.btn-outline { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.08); color: #fff }
.btn-outline:hover { background: rgba(255,255,255,.16) }
.btn-ghost { border-color: var(--line); background: transparent; color: var(--ink) }
.btn-ghost:hover { background: var(--surface-1) }
.btn-quiet { border-color: var(--line); background: transparent; color: var(--ink-soft) }
.btn-danger { background: var(--danger); color: #fff }
.btn-block { width: 100% }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .wrap { display: flex; align-items: center; gap: var(--s3); min-height: 64px }
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--ink); text-decoration: none }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: var(--s3) }
.topbar nav a { color: var(--ink-soft); font-size: .92rem; font-weight: 600; text-decoration: none }
.topbar nav a:hover { color: var(--ink) }

/* ---------- hero ---------- */
.hero-stage {
  position: relative; isolation: isolate; overflow: hidden;
  color: #fff; background: linear-gradient(145deg, var(--hero) 0%, var(--hero-deep) 100%);
}
.hero-stage::after {
  content: ""; position: absolute; inset: auto -18% -28% 25%; height: 52%;
  border-radius: 50%; background: rgba(120, 214, 198, .22); filter: blur(80px); z-index: 0;
}
.hero-layout {
  position: relative; z-index: 1;
  display: grid; gap: var(--s5); align-items: center;
  min-height: 680px; padding-block: var(--s7) var(--s6);
}
@media (min-width: 1024px) {
  .hero-layout { grid-template-columns: 1.05fr .95fr; gap: var(--s6); min-height: 760px }
}
.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem; margin-bottom: var(--s3);
  color: #f2cf82; font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.hero-copy h1 {
  max-width: 13ch; margin: 0;
  font-size: clamp(2.6rem, 8vw, 5.2rem); font-weight: 800; line-height: .99; text-wrap: balance;
}
.hero-copy > p { max-width: 58ch; margin-top: var(--s4); color: rgba(255,255,255,.84); font-size: clamp(1rem, 2vw, 1.14rem); line-height: 1.7 }
@media (max-width: 639px) { .hero-copy h1 { font-size: clamp(2.4rem, 12vw, 3.6rem) } }
.hero-actions { display: grid; gap: var(--s2); margin-top: var(--s5) }
@media (min-width: 480px) { .hero-actions { display: flex; flex-wrap: wrap } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--s3) var(--s4);
  margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid rgba(255,255,255,.2) }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, minmax(0,1fr)) } }
.stats div { margin: 0 }
.stats dd { margin: 0; font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: #fff }
.stats dt { margin-top: .15rem; color: rgba(255,255,255,.7); font-size: .72rem; letter-spacing: .02em }

/* slideshow */
.show { position: relative; min-height: 330px; align-self: end }
@media (min-width: 640px) { .show { min-height: 420px } }
@media (min-width: 1024px) { .show { min-height: 620px } }
.slide {
  position: absolute; inset: 0; margin: 0; opacity: 0; visibility: hidden;
  transform: translateX(28px);
  transition: opacity .6s var(--ease), transform .7s var(--ease), visibility .7s;
}
.slide.is-on { opacity: 1; visibility: visible; transform: none }
.slide img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom;
  filter: drop-shadow(0 24px 24px rgba(8,32,36,.34)) }
.slide-cap {
  position: absolute; left: 0; bottom: 1.6rem; display: grid; gap: .15rem; max-width: 250px;
  padding: .8rem 1rem; border: 1px solid rgba(255,255,255,.2); border-radius: var(--r-sm);
  background: rgba(18,50,52,.7); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.slide-cap b { color: #f2cf82; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase }
.slide-cap span { font-size: .86rem; font-weight: 600; color: #fff }
.show-dots { position: absolute; right: 0; bottom: 1.9rem; z-index: 5; display: flex; align-items: center; gap: .45rem }
.show-dots button { width: 28px; height: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer }
.show-dots button::after { content: ""; display: block; width: 7px; height: 7px; margin: auto;
  border-radius: var(--r-full); background: rgba(255,255,255,.45); transition: width .2s var(--ease) }
.show-dots button[aria-selected="true"]::after { width: 22px; background: #fff }
@media (max-width: 639px) { .slide-cap { bottom: 1.1rem } .show-dots { bottom: 1.25rem } }

/* ---------- section headings ---------- */
.head-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: var(--s3) }
@media (max-width: 639px) { .head-row { grid-template-columns: 1fr; align-items: start } }
.kicker { color: var(--primary); font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase }
.section-title { margin: .4rem 0 0; font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 800; line-height: 1.1 }
.page-title { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.15; margin: 0 0 var(--s2) }
.lede { max-width: 62ch; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.7 }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); box-shadow: var(--shadow-1) }
.card-flat { background: var(--surface-1); border-color: transparent; box-shadow: none }

.course-grid { list-style: none; margin: var(--s5) 0 0; padding: 0;
  display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)) }
.course-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2) }
.course-card .thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--surface-2) }
.course-card .thumb img, .course-card .thumb svg { width: 100%; height: 100%; object-fit: cover; display: block }
.course-body { padding: var(--s3) var(--s3) var(--s4) }
.course-card h3 { margin: .2rem 0 .3rem; font-size: 1.06rem; font-weight: 800 }
.course-card .summary { margin: 0; color: var(--ink-soft); font-size: .86rem; line-height: 1.55 }
.course-card .meta { margin: var(--s3) 0 0; color: var(--ink-soft); font-size: .78rem; font-weight: 600 }
.card-cta { margin: var(--s2) 0 0; color: var(--primary); font-size: .84rem; font-weight: 700 }
.card-cta.is-done { color: var(--ok) }
.stretch::after { content: ""; position: absolute; inset: 0 }

@media (max-width: 639px) {
  .course-grid { gap: var(--s2) }
  .course-card { flex-direction: row; align-items: center; gap: var(--s3); padding: var(--s2) }
  .course-card .thumb { flex: none; width: 76px; aspect-ratio: 1; border-radius: var(--r-sm) }
  .course-body { flex: 1; padding: var(--s2) var(--s2) var(--s2) 0 }
  .course-card .summary { display: none }
  .course-card .meta { margin-top: .2rem }
}

/* ---------- dialogs ---------- */
.howto-backdrop, .image-lightbox {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; padding: var(--s3);
  background: rgba(14,32,36,.66); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
}
@media (min-width: 640px) { .howto-backdrop, .image-lightbox { place-items: center } }
.howto-panel, .image-lightbox-panel {
  position: relative; width: min(100%, 520px); padding: var(--s5);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.howto-close, .image-lightbox-close, .dialog-close {
  position: absolute; top: var(--s3); right: var(--s3);
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); cursor: pointer;
}
.howto-steps { display: grid; gap: var(--s4); margin-top: var(--s4); padding: 0; list-style: none }
.howto-steps li { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: var(--s3); color: var(--ink-soft); font-size: .93rem }
.howto-steps li::before {
  content: counter(step); counter-increment: step;
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); color: var(--primary); font-weight: 800; font-size: .9rem;
}
.howto-steps { counter-reset: step }

/* ---------- forms ---------- */
.form { display: grid; gap: var(--s3) }
.form label { display: grid; gap: .35rem; font-size: .88rem; font-weight: 650; color: var(--ink) }
.form input, .form textarea, .form select {
  min-height: 48px; padding: .7rem .9rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.form input:focus, .form textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; background: var(--surface) }
.hint { color: var(--ink-soft); font-size: .82rem; font-weight: 500 }
.alt { color: var(--ink-soft); font-size: .9rem; text-align: center }

/* ---------- notices ---------- */
.flash, .alert, .gate-note {
  padding: var(--s3); border-radius: var(--r-sm); font-size: .93rem;
  border: 1px solid var(--line); background: var(--surface-1); color: var(--ink);
}
.alert-ok, .flash-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 9%, var(--surface)) }
.alert-error, .flash-err { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)) }
.gate-note { border-style: dashed; color: var(--ink-soft) }
.empty { color: var(--ink-soft); padding: var(--s5); text-align: center }

/* ---------- misc surfaces ---------- */
.crumb { color: var(--ink-soft); font-size: .84rem; margin-bottom: var(--s3) }
.crumb a { color: var(--ink-soft) }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); margin-bottom: var(--s4); box-shadow: var(--shadow-1) }
.table { width: 100%; border-collapse: collapse; font-size: .92rem }
.table th, .table td { padding: .7rem .6rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top }
.table th { color: var(--ink-soft); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em }
.table-wrap { overflow-x: auto }
.status { display: inline-block; padding: .2rem .55rem; border-radius: var(--r-full); font-size: .74rem; font-weight: 700 }
.status-published { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok) }
.status-draft { background: var(--surface-2); color: var(--ink-soft) }
.pill { display: inline-block; padding: .2rem .6rem; border-radius: var(--r-full); background: color-mix(in srgb, var(--card, var(--primary)) 14%, transparent); color: var(--card, var(--primary)); font-size: .76rem; font-weight: 700 }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 .4rem; border-radius: var(--r-full); background: var(--danger); color: #fff; font-size: .74rem; font-weight: 700 }
.small { font-size: .86rem }
.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 }

/* course detail */
.course-hero { display: grid; gap: var(--s5); align-items: start }
@media (min-width: 768px) { .course-hero { grid-template-columns: 320px minmax(0,1fr) } }
.course-hero-art { border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); background: var(--surface-2) }
.course-hero-art img, .course-hero-art svg { width: 100%; display: block }
.progress-panel { display: flex; align-items: center; gap: var(--s4); margin: var(--s4) 0; padding: var(--s3) var(--s4);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: var(--surface-1) }
.progress-head { margin: 0 0 var(--s1); font-family: var(--font-display); font-size: 1.05rem; font-weight: 700 }
.stats-inline { display: flex; flex-wrap: wrap; gap: var(--s4); margin: var(--s4) 0; padding: 0; border: 0 }
.stats-inline div { margin: 0 }
.stats-inline dt { color: var(--ink-soft); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em }
.stats-inline dd { margin: 0; font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; color: var(--ink) }
.course-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s4) 0 var(--s2) }
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5) }

/* footer */
.foot { margin-top: var(--s8); padding-block: var(--s5); border-top: 1px solid var(--line-soft); color: var(--ink-soft); font-size: .88rem }
.foot .brand-signature { display: flex; align-items: center; gap: .6rem; margin-top: var(--s3) }
.brand-mark { width: 28px; height: 28px; border-radius: var(--r-sm) }

/* ---------- hero backdrop pattern ---------- */
.science-pattern { position: absolute; inset: 0; overflow: hidden; opacity: .35; pointer-events: none; z-index: 0 }
.doodle { position: absolute }
.doodle-one   { width: 130px; height: 130px; top: 12%; right: 8%;  color: #f0cd7e; animation: slDrift 12s ease-in-out infinite }
.doodle-two   { width: 86px;  height: 86px;  left: 5%;  top: 55%;  color: #f3b08c; transform: rotate(-14deg) }
.doodle-three { width: 70px;  height: 70px;  left: 42%; top: 9%;   color: #9fd0e8 }
.doodle-four  { width: 100px; height: 100px; right: 38%; bottom: 8%; color: #a8ddb9 }
.formula { position: absolute; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 1.25rem; color: rgba(255,255,255,.5) }
.formula-one   { left: 7%;  top: 23% }
.formula-two   { right: 8%; top: 49% }
.formula-three { left: 31%; bottom: 12% }
@keyframes slDrift { 50% { transform: translateY(14px) rotate(8deg) } }
@media (prefers-reduced-motion: reduce) { .doodle-one { animation: none } .slide { transition: opacity .2s linear; transform: none } }
@media (max-width: 639px) { .formula { font-size: 1rem } .doodle-three, .doodle-four { display: none } }

/* ---------- WhatsApp chat button ---------- */
.wa-float{
  position:fixed; z-index:60;
  right:max(16px,env(safe-area-inset-right));
  bottom:max(16px,env(safe-area-inset-bottom));
  display:grid; place-items:center; width:56px; height:56px;
  border-radius:var(--r-full); background:#25D366;
  box-shadow:0 10px 26px rgba(37,211,102,.38);
  transition:transform .2s var(--ease), box-shadow .2s var(--ease);
}
.wa-float svg{width:32px;height:32px;fill:#fff}
.wa-float:hover{transform:translateY(-2px) scale(1.04); box-shadow:0 14px 32px rgba(37,211,102,.48)}
.wa-float:focus-visible{outline:3px solid var(--ink); outline-offset:3px}
@media (max-width:639px){ .wa-float{width:52px;height:52px} .wa-float svg{width:29px;height:29px} }
@media print{ .wa-float{display:none} }
