/* ==========================================================================
   LingoAct 首頁樣式
   --------------------------------------------------------------------------
   這是一份獨立於 Vite 專案的靜態頁面：沒有建置步驟，沒有 npm 相依套件，
   整個 homepage/ 資料夾丟到 Cloudflare Pages 就能上線。顏色沿用
   src/index.css 的設計 token，讓首頁和學生端看起來是同一套產品。
   ========================================================================== */

:root {
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-subtle: #f4f4f6;
  --text: #17161a;
  --muted: #8a8792;
  --border: #e4e3e8;
  --border-strong: #d5d3da;
  --primary: #7b2d5e;
  --primary-dark: #5c2046;
  --primary-soft: #fdeaf2;
  --success: #2f6b52;
  --success-soft: #e9f4ef;
  --danger: #b4462a;
  --danger-soft: #fdefe9;
  --share: #1f6b74;
  --share-soft: #e8f4f6;
  --energy: #8a6415;
  --energy-soft: #f9f0d9;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgb(23 22 26 / 7%);
  --shadow-md: 0 14px 36px rgb(23 22 26 / 12%);
  --shell: 1160px;

  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  line-height: 1.65;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
}

code {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.1em 0.4em;
  white-space: nowrap;
}

.shell {
  margin: 0 auto;
  max-width: var(--shell);
  padding: 0 24px;
  width: 100%;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.skip-link {
  background: var(--primary);
  border-radius: 0 0 var(--radius-sm) 0;
  color: #fff;
  left: 0;
  padding: 10px 18px;
  position: absolute;
  top: -60px;
  transition: top 0.15s ease;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

:where(a, button, input):focus-visible {
  outline: 3px solid rgb(123 45 94 / 30%);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- header */

.site-header {
  background: rgb(255 255 255 / 86%);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  align-items: center;
  display: flex;
  gap: 24px;
  height: 64px;
}

.brand {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-text small {
  color: var(--muted);
  font-size: 11px;
}

.site-nav {
  display: flex;
  gap: 22px;
  margin-left: auto;
}

.site-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-nav a:hover {
  color: var(--primary);
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.conn-pill {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 7px;
  padding: 5px 12px;
  white-space: nowrap;
}

.conn-pill .dot {
  background: var(--muted);
  border-radius: 50%;
  height: 7px;
  width: 7px;
}

.conn-pill[data-state="ok"] {
  background: var(--success-soft);
  border-color: rgb(47 107 82 / 22%);
  color: var(--success);
}

.conn-pill[data-state="ok"] .dot {
  background: var(--success);
}

.conn-pill[data-state="error"] {
  background: var(--danger-soft);
  border-color: rgb(180 70 42 / 22%);
  color: var(--danger);
}

.conn-pill[data-state="error"] .dot {
  background: var(--danger);
}

/* ----------------------------------------------------------------- button */

.btn {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  padding: 10px 18px;
  text-decoration: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn[disabled] {
  cursor: progress;
  opacity: 0.6;
}

/* ------------------------------------------------------------------- hero */

.hero {
  background:
    radial-gradient(1100px 420px at 12% -12%, rgb(123 45 94 / 12%), transparent 62%),
    radial-gradient(900px 380px at 92% 4%, rgb(31 107 116 / 10%), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 64px 0 56px;
}

.hero-inner {
  align-items: start;
  display: grid;
  gap: 48px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
}

.eyebrow {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.hero h1 {
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero h1 span {
  color: var(--muted);
  display: block;
  font-size: 0.44em;
  font-weight: 600;
  letter-spacing: 0;
  margin-top: 10px;
}

.lede {
  color: var(--muted);
  font-size: 16px;
  margin-top: 18px;
  max-width: 56ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.join-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-top: 26px;
  max-width: 520px;
  padding: 18px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  flex: 1;
  font-family: inherit;
  font-size: 15px;
  min-width: 0;
  padding: 10px 14px;
}

.join-row input:focus {
  border-color: var(--primary);
  outline: none;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.field-hint[data-state="error"] {
  color: var(--danger);
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  position: sticky;
  top: 88px;
}

.hero-card h2 {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.kv-list {
  margin: 18px 0 0;
}

.kv {
  align-items: baseline;
  border-bottom: 1px dashed var(--border);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 10px 0;
}

.kv:last-child {
  border-bottom: none;
}

.kv dt {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.kv dd {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.hero-card-note {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
  font-size: 12.5px;
  margin-top: 18px;
  padding: 12px 14px;
}

/* ------------------------------------------------------------ setup guide */

.setup-guide {
  background: var(--energy-soft);
  border-bottom: 1px solid rgb(138 100 21 / 22%);
  padding: 36px 0;
}

.setup-guide h2 {
  font-size: 20px;
}

.setup-steps {
  color: var(--text);
  margin: 16px 0 0;
  padding-left: 22px;
}

.setup-steps li {
  margin-bottom: 8px;
}

.setup-note {
  color: var(--energy);
  font-size: 13px;
  margin-top: 16px;
}

/* ---------------------------------------------------------------- section */

.section {
  padding: 60px 0;
}

.section-alt {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.section-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.section-head h2 {
  font-size: clamp(22px, 3vw, 28px);
}

.section-note {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 7px;
}

/* ------------------------------------------------------------------ stats */

.stat-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
}

.section-alt .stat-card {
  border-color: var(--border);
}

.stat-card.is-live::before {
  background: var(--success);
  border-radius: 50%;
  content: "";
  height: 8px;
  position: absolute;
  right: 18px;
  top: 22px;
  width: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-value {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 6px;
}

.stat-hint {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 6px;
}

.stat-hint code {
  font-size: 11px;
}

/* --------------------------------------------------------------- features */

.feature-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.feature-card h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--muted);
  font-size: 14px;
}

/* ---------------------------------------------------------------- classes */

.class-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
}

.class-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  padding: 20px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.class-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.class-card-top {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.class-card h3 {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.badge {
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-soft);
  color: var(--success);
}

.badge-ended {
  background: var(--surface-subtle);
  color: var(--muted);
}

.class-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

.class-meta {
  border-top: 1px dashed var(--border);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 6px 16px;
  margin-top: 14px;
  padding-top: 12px;
}

.class-meta strong {
  color: var(--text);
}

.class-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.class-card-actions .btn {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
}

/* ------------------------------------------------------------------- live */

.live-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.live-feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}

.live-feed .empty {
  padding: 28px 12px;
}

.live-item {
  align-items: baseline;
  border-bottom: 1px solid var(--surface-subtle);
  display: flex;
  gap: 12px;
  padding: 10px 12px;
}

.live-item:last-child {
  border-bottom: none;
}

.live-name {
  color: var(--primary);
  flex: 0 0 84px;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-text {
  flex: 1;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.live-time {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 11.5px;
}

.live-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.live-side h3 {
  font-size: 15px;
}

.kv-list.compact .kv {
  padding: 8px 0;
}

.live-side-note {
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 16px;
  padding: 12px 14px;
}

.live-badge {
  background: var(--danger);
  border-radius: 50%;
  height: 8px;
  width: 8px;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.82);
  }
}

/* ----------------------------------------------------------- announcements */

.announcement-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.announcement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.announcement-card.is-pinned {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.announcement-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.announcement-card h3 {
  font-size: 16.5px;
  overflow-wrap: anywhere;
}

.pin-tag {
  background: var(--primary-soft);
  border-radius: 999px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  white-space: nowrap;
}

.announcement-body {
  color: var(--muted);
  font-size: 14px;
  margin-top: 10px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.announcement-foot {
  align-items: center;
  border-top: 1px dashed var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
}

.announcement-foot time {
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ files */

.file-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.file-row {
  align-items: center;
  border-bottom: 1px solid var(--surface-subtle);
  display: flex;
  gap: 14px;
  padding: 14px 18px;
}

.file-row:last-child {
  border-bottom: none;
}

.file-icon {
  align-items: center;
  background: var(--share-soft);
  border-radius: var(--radius-sm);
  color: var(--share);
  display: flex;
  flex: 0 0 38px;
  font-size: 11px;
  font-weight: 800;
  height: 38px;
  justify-content: center;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.file-row .btn {
  flex: 0 0 auto;
  font-size: 13px;
  padding: 7px 14px;
}

/* ---------------------------------------------------------------- sources */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.source-table {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 620px;
  width: 100%;
}

.source-table th,
.source-table td {
  border-bottom: 1px solid var(--surface-subtle);
  padding: 13px 18px;
  text-align: left;
}

.source-table tr:last-child td {
  border-bottom: none;
}

.source-table thead th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.source-table td:nth-child(2) {
  white-space: nowrap;
}

.source-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 16px;
}

/* ----------------------------------------------------------------- footer */

.site-footer {
  background: var(--surface-strong);
  color: #cfcbd6;
  padding: 34px 0;
}

.footer-inner {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
}

.footer-title {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.footer-note {
  font-size: 13px;
  margin-top: 4px;
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  color: #cfcbd6;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}

.footer-links a:hover {
  color: #fff;
}

/* ------------------------------------------------------------------ empty */

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 4px;
}

.empty.is-error {
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 16px;
}

.class-grid .empty,
.announcement-grid .empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 20px;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 960px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }

  .hero-card {
    position: static;
  }

  .stat-grid,
  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-grid {
    grid-template-columns: 1fr;
  }

  .site-nav {
    display: none;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 0 16px;
  }

  .hero {
    padding: 40px 0 36px;
  }

  .section {
    padding: 44px 0;
  }

  .stat-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .join-row {
    flex-direction: column;
  }

  .file-row {
    flex-wrap: wrap;
  }

  .live-name {
    flex-basis: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .live-badge {
    animation: none;
  }

  .btn,
  .class-card {
    transition: none;
  }
}
