/* ==========================================================================
   ASHTRAY STUDIO — 炭與餘燼（Ash & Ember）設計系統
   全站唯一視覺正本：design token ＋ 共用元件。
   規則：palette 十六進位色值只准出現在本檔；其他樣式表一律 var() 消費。
   零 webfont、零外部資源；紋理與圖形一律 inline SVG data URI。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens
   暗色預設「炭室」；明亮變體「日光卷軸」。
   三態機制：無偏好跟系統（media query）、data-theme 手動覆寫。
   -------------------------------------------------------------------------- */

:root {
  /* 炭室（暗色，預設） */
  --bg: #171412;
  --panel: #201c18;
  --line: #35302a;
  --text: #e6ddd0;
  --muted: #a2988a;
  --accent: #d9a441;
  --ember: #b5483a;

  /* 衍生層（由 palette 派生，供元件消費） */
  --accent-dim: #8a6a2c;
  --shadow-press: rgba(0, 0, 0, 0.45);
  --highlight-bevel: rgba(230, 221, 208, 0.06);
  --dot-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23e6ddd0' fill-opacity='0.05'/%3E%3C/svg%3E");

  /* 字型堆疊（零 webfont，平台退化為有意識的取捨） */
  --font-display: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --font-body: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* 幾何與節奏 */
  --radius: 10px;
  --theme-transition: 0.3s;

  color-scheme: dark;
}

/* 手動選亮 */
[data-theme="light"] {
  --bg: #e7dcc8;
  --panel: #f2ead9;
  --line: #c9b99f;
  --text: #3a2f22;
  --muted: #7a6c58;
  --accent: #a8731f;
  --ember: #8b2b2b;

  --accent-dim: #c5964a;
  --shadow-press: rgba(58, 47, 34, 0.25);
  --highlight-bevel: rgba(255, 255, 255, 0.55);
  --dot-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1' fill='%233a2f22' fill-opacity='0.05'/%3E%3C/svg%3E");

  color-scheme: light;
}

/* 無手動偏好時，跟隨系統的亮色 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #e7dcc8;
    --panel: #f2ead9;
    --line: #c9b99f;
    --text: #3a2f22;
    --muted: #7a6c58;
    --accent: #a8731f;
    --ember: #8b2b2b;

    --accent-dim: #c5964a;
    --shadow-press: rgba(58, 47, 34, 0.25);
    --highlight-bevel: rgba(255, 255, 255, 0.55);
    --dot-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1' fill='%233a2f22' fill-opacity='0.05'/%3E%3C/svg%3E");

    color-scheme: light;
  }
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: var(--dot-grid);
  color: var(--text);
  font: 17px/1.75 var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition:
    background-color var(--theme-transition),
    color var(--theme-transition);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

img,
svg {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-wrap: balance; /* 多行標題左右均衡，避免尾行孤字 */
}

p {
  text-wrap: pretty; /* 段落斷行避免孤字（不支援的瀏覽器自動忽略） */
}

/* 孤字保險：包住句尾詞組，強制整組換行、不讓單字落單 */
.keep {
  white-space: nowrap;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* 版心容器 */
.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding-inline: 1.2rem;
}

/* meta 層：eyebrow、日期、標籤、狀態、footer 資訊——一律等寬字 */
.meta {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   3. Header 與導覽（全站共用；雙軌一致的正本樣式）
   佈局以最多 5 個導覽項驗證（家庭入口預留）。
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background-color: var(--panel);
  transition:
    background-color var(--theme-transition),
    border-color var(--theme-transition);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.4rem;
  padding-block: 0.85rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--text);
}

.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.4rem;
  margin-inline-start: auto;
}

.site-nav a {
  padding: 0.3rem 0.65rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--line);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-color: var(--line);
  background-color: var(--bg);
}

.site-nav a[aria-current="page"]::before {
  content: "▸ ";
  font-family: var(--font-mono);
  font-size: 0.8em;
}

/* --------------------------------------------------------------------------
   4. 按壓手感（90 年代點綴其一）
   raised → inset ＋ 1–2px 位移；適用按鈕與主題切換鈕。
   -------------------------------------------------------------------------- */

.btn,
.theme-toggle {
  display: inline-block;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  background-color: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
  box-shadow:
    0 2px 0 var(--shadow-press),
    inset 0 1px 0 var(--highlight-bevel);
  transition:
    background-color var(--theme-transition),
    color var(--theme-transition),
    border-color var(--theme-transition);
}

.btn:hover,
.theme-toggle:hover {
  border-color: var(--accent-dim);
  text-decoration: none;
}

.btn:active,
.theme-toggle:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px var(--shadow-press);
}

.btn-primary {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.theme-toggle {
  padding: 0.3rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   5. Footer（全站共用，含 88×31 徽章）
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background-color: var(--panel);
  transition:
    background-color var(--theme-transition),
    border-color var(--theme-transition);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1.4rem;
  padding-block: 1.3rem;
}

.site-footer .meta {
  margin: 0;
}

.badge-88 {
  display: inline-block;
  line-height: 0;
}

.badge-88 img {
  width: 88px;
  height: 31px;
  image-rendering: auto;
}

/* --------------------------------------------------------------------------
   6. Hero 與簽名元素：ASHTRAY 字標的餘燼明滅
   全站唯一的 ambient 動畫；純 CSS、週期 6s、reduced-motion 停用。
   -------------------------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 5.5rem 1.2rem 4rem;
}

.hero .eyebrow {
  margin: 0 0 1.6rem;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 10vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em; /* 抵銷末字母的字距，維持光學置中 */
  line-height: 1.1;
  color: var(--text);
}

.ember-letter {
  color: var(--accent);
  animation: ember-breathe 6s ease-in-out infinite;
}

@keyframes ember-breathe {
  0%,
  100% {
    color: var(--text);
    text-shadow: none;
  }
  45% {
    color: var(--ember);
    text-shadow: 0 0 24px var(--ember);
  }
  60% {
    color: var(--accent);
    text-shadow: 0 0 14px var(--accent);
  }
}

/* 餘燼線：hero 下的漸層細線，像一炷香的殘火 */
.ember-rule {
  width: min(320px, 60%);
  height: 1px;
  margin: 2.2rem auto 0;
  border: 0;
  background: linear-gradient(
    to right,
    transparent,
    var(--accent),
    var(--ember),
    var(--accent),
    transparent
  );
}

.tagline {
  margin: 1.8rem auto 0;
  max-width: 34em;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 2.4rem;
}

@media (prefers-reduced-motion: reduce) {
  .ember-letter {
    animation: none;
    color: var(--accent);
    text-shadow: none;
  }
}

/* --------------------------------------------------------------------------
   7. 內容區塊與卡片
   -------------------------------------------------------------------------- */

main.page {
  flex: 1;
  padding-block: 2.6rem 4rem;
}

.page-title {
  font-size: 1.9rem;
  margin: 0 0 0.4rem;
}

.page-lede {
  color: var(--muted);
  max-width: 40em;
  margin-top: 0;
}

.section-title {
  font-size: 1.3rem;
  margin: 2.8rem 0 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.prose {
  max-width: 42em;
}

.prose p {
  margin-block: 0.9rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
  margin-block: 1.6rem;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--panel);
  color: var(--text);
  transition:
    background-color var(--theme-transition),
    border-color var(--theme-transition),
    color var(--theme-transition);
}

a.card:hover {
  border-color: var(--accent-dim);
  text-decoration: none;
}

.card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.card .card-sub {
  margin: 0;
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}

.card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.card .meta {
  margin-top: auto;
  padding-top: 0.6rem;
}

/* 專案狀態標記 */
.status-mark {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.status-mark::before {
  content: "[ ";
  color: var(--accent-dim);
}

.status-mark::after {
  content: " ]";
  color: var(--accent-dim);
}

.back-link {
  display: inline-block;
  margin-top: 2.4rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   8. Fellowship 成員卡（關於頁）
   -------------------------------------------------------------------------- */

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
  margin-block: 1.6rem;
  padding: 0;
  list-style: none;
}

.member-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--panel);
  transition:
    background-color var(--theme-transition),
    border-color var(--theme-transition);
}

/* 1:1 頭像畫框（素材另案，先以畫框與字母占位） */
.portrait-frame {
  aspect-ratio: 1 / 1;
  width: 96px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  background-color: var(--bg);
  background-image: var(--dot-grid);
  color: var(--accent-dim);
  font-family: var(--font-display);
  font-size: 2rem;
}

.member-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.member-card .member-role {
  margin: 0;
  font-size: 0.92rem;
  color: var(--accent);
}

.member-card .member-intro {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.member-card .gag {
  margin: auto 0 0;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
}

/* --------------------------------------------------------------------------
   9. 錯誤頁（404／50x）——核心訊息不依賴 JS
   -------------------------------------------------------------------------- */

.error-page {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4rem 1.2rem;
}

.error-page .error-code {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1;
}

.error-page h1 {
  font-size: 1.5rem;
  margin: 1.2rem 0 0.4rem;
}

.error-page p {
  color: var(--muted);
  max-width: 30em;
  margin: 0.4rem auto;
}

.error-page .hero-actions {
  margin-top: 1.8rem;
}

/* --------------------------------------------------------------------------
   10. 響應式細節
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .hero {
    padding: 3.6rem 1rem 2.8rem;
  }

  main.page {
    padding-block: 2rem 3rem;
  }

  .site-footer .wrap {
    justify-content: center;
    text-align: center;
  }
}
