/*
 * Qlassia download site.
 * Tokens mirror the desktop app: lib/features/teacher/theme/teacher_theme.dart
 * (TeacherColors.light / .dark) and lib/core/theme/app_colors.dart.
 * Radii, borders and motion follow lib/features/teacher/widgets/ui.dart (TCard 14,
 * buttons 10-12, icon badges at 16% tint) and the shells' 180ms ease-out.
 */

:root {
  --bg: #F7F9F7;
  --surface: #FFFFFF;
  --surface-alt: #F0F5F2;
  --border: #DCE7E2;
  --text: #10201B;
  --text-muted: #63736D;
  --text-faint: #8FA09A;
  --primary: #087A5B;
  --primary-hover: #04563F;           /* AppColors.primaryDark (Deep Emerald) */
  --primary-soft: rgba(8, 122, 91, 0.12);
  --on-primary: #FFFFFF;
  --accent: #C9A45C;                  /* Luxury Accent */
  --accent-soft: #F1E7D1;
  --success: #16805C;
  --warning: #C9A45C;
  --danger: #B94A48;
  --info: #2F7F96;
  --shadow-frame: 0 24px 60px -24px rgba(16, 32, 27, 0.28);
  --focus: #087A5B;

  --radius-card: 14px;
  --radius-btn: 12px;
  --radius-sm: 10px;
  --header-h: 64px;
  --ease: cubic-bezier(0, 0, 0.58, 1); /* Curves.easeOut */
  --dur: 180ms;

  color-scheme: light;
}

/* Dark tokens: TeacherColors.dark (the dashboards' default theme). Filled buttons use Deep Emerald
   (#0B6B50) rather than the dark primary (#19A87A) so white labels keep 4.5:1. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07120F;
    --surface: #0C1B17;
    --surface-alt: #10241E;
    --border: #1D3930;
    --text: #F2F7F4;
    --text-muted: #91A59D;
    --text-faint: #6A8077;
    --primary: #19A87A;
    --primary-fill: #0B6B50;
    --primary-hover: #0F7F5E;
    --primary-soft: rgba(25, 168, 122, 0.18);
    --accent: #D6B66E;
    --accent-soft: #332B1D;
    --success: #32B985;
    --warning: #D6B66E;
    --danger: #E57373;
    --info: #5BB3CB;
    --shadow-frame: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
    --focus: #5ED3AA;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07120F;
  --surface: #0C1B17;
  --surface-alt: #10241E;
  --border: #1D3930;
  --text: #F2F7F4;
  --text-muted: #91A59D;
  --text-faint: #6A8077;
  --primary: #19A87A;
  --primary-fill: #0B6B50;
  --primary-hover: #0F7F5E;
  --primary-soft: rgba(25, 168, 122, 0.18);
  --accent: #D6B66E;
  --accent-soft: #332B1D;
  --success: #32B985;
  --warning: #D6B66E;
  --danger: #E57373;
  --info: #5BB3CB;
  --shadow-frame: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  --focus: #5ED3AA;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--primary); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 599px) { .container { padding: 0 16px; } }

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

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Header (mirrors the app's 64px top bar) ------------------------------------------------ */

.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.header-inner { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; border-radius: 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: #087A5B; color: #fff;
  display: inline-grid; place-items: center;
}
:root[data-theme="dark"] .brand-mark { background: #0B6B50; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark { background: #0B6B50; } }
.brand-mark .icon { width: 18px; height: 18px; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }

.header-nav { display: flex; gap: 4px; margin-left: 8px; }
.header-nav a {
  color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 8px;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.header-nav a:hover { color: var(--text); background: var(--surface-alt); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-button {
  width: 40px; height: 40px; border-radius: 999px; border: 0; background: transparent;
  color: var(--text-muted); display: inline-grid; place-items: center; cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-button:hover { background: var(--surface-alt); color: var(--text); }
.icon-button .icon { width: 22px; height: 22px; }
.icon-when-dark { display: none; }
:root[data-theme="dark"] .icon-when-dark { display: block; }
:root[data-theme="dark"] .icon-when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-when-dark { display: block; }
  :root:not([data-theme="light"]) .icon-when-light { display: none; }
}

@media (max-width: 719px) {
  .header-nav { display: none; }
}

/* ---- Buttons (FilledButton / OutlinedButton themes) ------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 12px 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn-sm { min-height: 40px; padding: 9px 14px; }
.btn-sm .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary-fill, var(--primary)); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-alt); }
.btn-block { width: 100%; }

/* Download buttons: the auth screen's primary button (radius 12, 16px semibold). Default is
   filled; when the visitor's OS is detected, the other platform switches to outlined. */
.btn-download {
  min-height: 56px; padding: 16px 24px; border-radius: var(--radius-btn);
  font-size: 16px; background: var(--primary-fill, var(--primary)); color: var(--on-primary);
}
.btn-download .icon { width: 22px; height: 22px; }
.btn-download:hover { background: var(--primary-hover); }
.btn-download:active { transform: translateY(1px); }
.btn-download.is-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-download.is-secondary:hover { background: var(--surface-alt); }
.btn-download[aria-disabled="true"] {
  background: var(--surface-alt); color: var(--text-muted); border-color: var(--border);
  cursor: not-allowed;
}
.btn-download[aria-disabled="true"]:active { transform: none; }

/* ---- Hero --------------------------------------------------------------------------------- */

.hero { padding: 88px 0 40px; text-align: center; }
.hero-inner { display: flex; flex-direction: column; align-items: center; }
.hero h1 {
  font-size: clamp(36px, 6vw, 60px); font-weight: 800; line-height: 1.08; letter-spacing: -0.03em;
  max-width: 20ch;
}
.hero h1 .phrase { white-space: nowrap; }
@media (max-width: 399px) { .hero h1 .phrase { white-space: normal; } }
.lede { margin-top: 20px; max-width: 640px; font-size: clamp(16px, 2vw, 18px); color: var(--text-muted); }
.hero-downloads { margin-top: 36px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.hero-downloads .btn-download { min-width: 260px; }
.hero-note { margin-top: 18px; font-size: 14px; color: var(--text-muted); }
.hero-status { margin-top: 6px; font-size: 13px; color: var(--text-muted); min-height: 1.5em; }

@media (max-width: 599px) {
  .hero { padding: 56px 0 28px; }
  .hero-downloads { width: 100%; flex-direction: column; }
  .hero-downloads .btn-download { width: 100%; min-width: 0; }
}

/* ---- Preview ------------------------------------------------------------------------------ */

.preview { padding: 24px 0 72px; }

/* TTabs: pill track on surfaceAlt, selected tab on surface. */
.tabs {
  display: flex; width: max-content; max-width: 100%; margin: 0 auto 20px; padding: 4px; gap: 4px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tab {
  border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 18px; border-radius: 8px; cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.preview-frame {
  margin: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow-frame);
  aspect-ratio: 1800 / 1125;
}
.preview-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: opacity var(--dur) var(--ease); }
.preview-frame img.is-loading { opacity: 0.4; }
.preview-caption { margin-top: 14px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---- Cards, features --------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }

.section-head { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.section-head p { margin-top: 10px; color: var(--text-muted); }

.features { padding: 72px 0; border-top: 1px solid var(--border); }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 959px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .feature-grid { grid-template-columns: 1fr; } }

.feature { padding: 20px; }
.feature h3 { margin-top: 14px; font-size: 15px; font-weight: 700; }
.feature p { margin-top: 6px; font-size: 14px; color: var(--text-muted); line-height: 1.5; }

/* IconBadge: tone at 16% behind the tone-coloured glyph. */
.icon-badge {
  --tone: var(--primary);
  width: 40px; height: 40px; border-radius: var(--radius-sm); flex: none;
  display: inline-grid; place-items: center;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.tone-primary .icon-badge { --tone: var(--primary); }
.tone-info .icon-badge { --tone: var(--info); }
.tone-warning .icon-badge { --tone: var(--warning); }
.tone-success .icon-badge { --tone: var(--success); }
.tone-danger .icon-badge { --tone: var(--danger); }
.icon-badge-lg { width: 52px; height: 52px; border-radius: 12px; }
.icon-badge-lg .icon { width: 26px; height: 26px; }

/* ---- Download ---------------------------------------------------------------------------- */

.download { padding: 72px 0 88px; border-top: 1px solid var(--border); }
.platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 880px; margin: 0 auto; }
@media (max-width: 719px) { .platform-grid { grid-template-columns: 1fr; } }

.platform { padding: 24px; display: flex; flex-direction: column; gap: 18px; transition: border-color var(--dur) var(--ease); }
.platform.is-detected { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.platform-head { display: flex; align-items: center; gap: 14px; }
.platform-head h3 { font-size: 20px; font-weight: 700; line-height: 1.2; margin-bottom: 6px; }
.platform-status { font-size: 13px; color: var(--text-muted); margin-top: -6px; }
.platform-status:empty { display: none; }

/* StatusChip */
.chip {
  --tone: var(--text-muted);
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.chip + .chip { margin-left: 6px; }
.chip-success { --tone: var(--success); }
.chip-warning { --tone: var(--warning); }
.chip-primary { --tone: var(--primary); }

.meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.meta:empty { display: none; }
.meta dt { color: var(--text-muted); }
.meta dd { margin: 0; color: var(--text); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.meta dd code { font-size: 12px; }

.notice {
  max-width: 880px; margin: 16px auto 0; padding: 16px 18px;
  display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-muted);
}
.notice .icon { color: var(--primary); margin-top: 1px; }
.notice strong { color: var(--text); }
.notice p + p { margin-top: 6px; }
code {
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace; font-size: 13px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
  overflow-wrap: anywhere;
}

/* ---- Footer ------------------------------------------------------------------------------ */

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; }
.footer-inner { display: flex; align-items: center; gap: 16px 28px; flex-wrap: wrap; }
.brand-static .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.brand-static .brand-mark .icon { width: 16px; height: 16px; }
.footer-links { display: flex; gap: 4px 18px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); font-size: 14px; font-weight: 500; text-decoration: none; border-radius: 4px; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.copyright { margin-left: auto; font-size: 13px; color: var(--text-muted); }
@media (max-width: 599px) { .copyright { margin-left: 0; width: 100%; } }

/* ---- Motion ------------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
