/* Millzik+ MK2 — shared design system. Zero external dependencies.
   Concept: 「旋動生態」— orbital spin energy; concentric rings + a blue→orange
   gradient that reads as motion, fusing 廣播(聲動校園) and 競技(爆旋陀螺).

   品牌色（藍／橙／金／綠）對齊全站單一真實來源 mk2/assets/palette.css，
   讓生態頁與市集／活動頁共用同一組 Millzik 品牌色（Navy／Orange），永不漂移。
   生態專屬的舊變數名（--blue / --gold / --card …）保留，但值改由 palette token 提供。 */
@import "/mk3/assets/palette.css";

:root {
  /* 品牌色：對齊 palette.css（--navy / --orange / --green）。
     --orange、--green 不在此重新宣告，直接沿用 palette.css 的值，避免漂移。 */
  --blue: var(--navy);
  --blue-700: var(--navy-hover);
  --gold: var(--orange);
  /* 語義狀態色（對齊 palette.css / admin design-system.css）。徽章／狀態藥丸請用這組 token。 */
  --success: #10b981;
  --success-soft: #dcfce7;
  --success-strong: #166534;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --warning-strong: #92400e;
  --error: #ef4444;
  --error-soft: #fee2e2;
  --error-strong: #b91c1c;
  --info: #3b82f6;
  --info-soft: #dbeafe;
  --info-strong: #1d4ed8;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(36, 85, 166, .18);
  --maxw: 1160px;
  --grad: linear-gradient(120deg, var(--blue) 0%, var(--navy-mid) 45%, var(--orange) 100%);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- top navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-container {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  font-weight: 800; font-size: 1.12rem; color: var(--ink);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand span {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-menu {
  display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap;
}
.nav-menu a {
  color: var(--ink); font-weight: 600; padding: 8px 12px; border-radius: 10px;
  font-size: .95rem;
}
.nav-menu a:hover { background: #eef2ff; text-decoration: none; }
.nav-menu a[aria-current="page"] { background: #eef2ff; color: var(--blue-700); }
.btn-directory {
  margin-left: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  font: inherit; font-weight: 700; padding: 8px 14px; border-radius: 10px; color: var(--ink);
}
.btn-directory:hover { border-color: var(--blue); color: var(--blue-700); }
.nav-toggle {
  display: none; margin-left: auto; font-size: 1.4rem; background: none;
  border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; cursor: pointer;
}

/* ---------- breadcrumb ---------- */
.breadcrumb { padding: 14px 0 2px; color: var(--muted); font-size: .88rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb b { color: var(--ink); }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: var(--grad);
  padding: 78px 0 86px;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(420px 420px at 88% 18%, rgba(251, 171, 24, .35), transparent 60%),
    radial-gradient(540px 540px at 8% 90%, rgba(255, 255, 255, .14), transparent 60%);
}
.spin-rings {
  position: absolute; right: -120px; top: -120px; width: 460px; height: 460px;
  border-radius: 50%; opacity: .35; pointer-events: none;
  background:
    repeating-radial-gradient(circle, rgba(255,255,255,.5) 0 2px, transparent 2px 26px);
  animation: spin 38s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hero .wrap { position: relative; z-index: 1; }
.eyebrow {
  display: inline-block; background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .35); padding: 5px 12px; border-radius: 999px;
  font-size: .82rem; font-weight: 700; letter-spacing: .04em; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.12; margin: 0 0 14px; font-weight: 800; }
.hero p.lead { font-size: clamp(1rem, 2.2vw, 1.22rem); max-width: 640px; opacity: .95; margin: 0 0 26px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 700; padding: 12px 22px; border-radius: 12px;
  border: 1px solid transparent; transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { box-shadow: 0 10px 22px rgba(251, 171, 24, .35); }
.btn-secondary { background: #fff; color: var(--blue-700); }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .6); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ghost { background: #eef2ff; color: var(--blue-700); }
.btn[disabled], .btn.is-soon { opacity: .85; cursor: default; }

/* ---------- sections + cards ---------- */
section { padding: 56px 0; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 36px; }
.section-head h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin: 0 0 10px; }
.section-head p { color: var(--muted); margin: 0; }
.kicker { color: var(--orange); font-weight: 800; letter-spacing: .06em; font-size: .8rem; text-transform: uppercase; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card.hover { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.card.hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #c7d2fe; }
.card h3 { margin: 0 0 8px; font-size: 1.18rem; }
.card .ico { font-size: 2rem; line-height: 1; }

.pillar {
  display: block; color: inherit; position: relative; overflow: hidden;
}
.pillar:hover { text-decoration: none; }
.pillar .ico {
  width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.8rem; margin-bottom: 14px; background: #eef2ff;
}
.pillar .arrow { color: var(--orange); font-weight: 800; margin-top: 12px; display: inline-block; }

/* ---------- status pills ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-active { background: var(--success-soft); color: var(--success-strong); }
.status-progress { background: #fef9c3; color: #a16207; }
.status-planned { background: #f1f5f9; color: #64748b; }

.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; background: #eef2ff; color: var(--blue-700); }

.muted { color: var(--muted); }
.mt { margin-top: 10px; }
.center { text-align: center; }

/* ---------- tiers (BeySTEM) ---------- */
.tier {
  border-left: 6px solid var(--blue); background: var(--card); border: 1px solid var(--line);
  border-left-width: 6px; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.tier.l1 { border-left-color: #2563eb; }
.tier.l2 { border-left-color: #7c3aed; }
.tier.l3 { border-left-color: var(--orange); }
.tier.l4 { border-left-color: var(--green); }
.tier .tier-no { font-size: .8rem; font-weight: 800; color: var(--orange); letter-spacing: .08em; }
.tier h3 { margin: 4px 0 6px; font-size: 1.3rem; }
.stem { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 8px; font-weight: 800; font-size: .82rem; color: #fff; margin-right: 6px; }
.stem.s { background: #0ea5e9; } .stem.t { background: #6366f1; }
.stem.e { background: #ea580c; } .stem.a { background: #ec4899; } .stem.m { background: #10b981; }

/* progress bar */
.progress { height: 9px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* ---------- directory ---------- */
.dir-search {
  width: 100%; font: inherit; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff;
}
.dir-search:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.dir-cat { margin-top: 30px; }
.dir-cat h3 { display: flex; align-items: baseline; gap: 10px; }
.dir-cat h3 small { color: var(--muted); font-weight: 600; }
.dir-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.dir-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; color: inherit;
}
.dir-item:hover { text-decoration: none; border-color: var(--blue); box-shadow: var(--shadow); }
.dir-item .nm { font-weight: 700; }
.dir-item .en { color: var(--muted); font-size: .82rem; }
.dir-item .path { color: var(--muted); font-size: .78rem; font-family: ui-monospace, monospace; }
.dir-item .status { margin-left: auto; }

/* ---------- modal (directory quick-open) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; width: min(720px, 100%); max-height: 78vh; overflow: auto;
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.modal-head { position: sticky; top: 0; background: #fff; padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line); }
.modal-head .row { display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-x { margin-left: auto; background: #f1f5f9; border: none; border-radius: 10px;
  width: 34px; height: 34px; font-size: 1.1rem; cursor: pointer; }
.modal-body { padding: 10px 20px 20px; }
.kbd { font: .76rem ui-monospace, monospace; background: #f1f5f9; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--muted); }

/* ---------- about / pillars strip ---------- */
.about-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }

/* ---------- footer ---------- */
.footer { background: var(--ink); color: #cbd5e1; padding: 44px 0 30px; margin-top: 20px; }
.footer a { color: #cbd5e1; }
.footer .cols { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.footer h4 { color: #fff; margin: 0 0 12px; font-size: .95rem; }
.footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer .fine { border-top: 1px solid #1e293b; margin-top: 28px; padding-top: 18px;
  color: #94a3b8; font-size: .85rem; }

/* ---------- floating directory button ---------- */
.fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  padding: 13px 18px; border-radius: 999px; font: inherit; font-weight: 700;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .3);
}
.fab:hover { background: var(--blue-700); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 120;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer .cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-menu {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: #fff; border-bottom: 1px solid var(--line); flex-direction: column;
    align-items: stretch; gap: 0; padding: 8px 12px 14px;
  }
  .nav-menu.open { display: flex; }
  .nav-menu a, .btn-directory { width: 100%; text-align: left; margin: 2px 0; }
  .topbar { position: relative; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .dir-list, .about-pillars { grid-template-columns: 1fr; }
  .footer .cols { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ---------- responsive tables (stacked on mobile) ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.responsive { width: 100%; border-collapse: collapse; }
table.responsive th, table.responsive td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.responsive thead th { font-size: .85rem; color: var(--muted); }

@media (max-width: 640px) {
  table.responsive thead { display: none; }
  table.responsive tbody tr {
    display: block; margin-bottom: 12px; border: 1px solid var(--line);
    border-radius: 12px; padding: 8px 12px; background: var(--card);
  }
  table.responsive tbody td {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 6px 0; border: none;
  }
  table.responsive tbody td::before {
    content: attr(data-label); font-weight: 700; color: var(--muted);
  }
}

/* ---------- touch optimisation ---------- */
@media (hover: none) and (pointer: coarse) {
  .btn, .btn-directory, .nav-menu a, .fab { min-height: 44px; }
  .card.hover:hover, .btn:hover { transform: none; }
  .card.hover:active, .btn:active { transform: scale(.98); opacity: .92; }
}

/* ---------- tablet ---------- */
@media (min-width: 641px) and (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- landscape phones ---------- */
@media (max-width: 760px) and (orientation: landscape) {
  .hero { padding: 40px 0 46px; }
  .modal { max-height: 84vh; }
}

/* ---------- high contrast ---------- */
@media (prefers-contrast: more) {
  .card, .kpi-card, .tier { border-width: 2px; }
  .btn { border: 2px solid currentColor; }
}
