/* 馬可福音網站共用樣式（和合本）。
    手機優先；深淺色依系統設定切換；不載入任何外部資源。 */

/* ===== 顏色變數：淺色為預設，深色依系統設定切換 ===== */
:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --card-bg: #fffcf5;
  --fg: #2c2b28;
  --muted: #635f56;
  --border: #ded8cc;
  --accent: #7a4a1f;
  --accent-fg: #ffffff;
  --accent-soft: #f3ead8;
  --focus: #b35400;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #22201c;
    --card-bg: #28251f;
    --fg: #ede9df;
    --muted: #aba69b;
    --border: #3d3932;
    --accent: #deb068;
    --accent-fg: #171614;
    --accent-soft: #352c1e;
    --focus: #e0a45c;
  }
}

/* ===== 基本設定：手機優先、無橫向捲動 ===== */
* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang TC", "Microsoft JhengHei",
    "Noto Sans TC", sans-serif;
  line-height: 1.75;
  overflow-x: hidden;
  min-width: 0;
  overflow-wrap: break-word;
}

/* 內容置中，最大寬度約 40em */
.container {
  width: 100%;
  max-width: 40em;
  margin-left: auto;
  margin-right: auto;
  padding: 0.75em 1em;
}

.container-wide {
  width: 100%;
  max-width: 40em;
  margin-left: auto;
  margin-right: auto;
  padding: 0.75em 1em;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin: 0.75em 0 1em;
}

.reading-layout {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.reading-main {
  width: 100%;
  max-width: 40em;
  margin-left: auto;
  margin-right: auto;
}

.chapter-sidebar {
  width: 100%;
  max-width: 40em;
  margin-left: auto;
  margin-right: auto;
  padding: 0.75em 1em;
}

/* ===== 導覽列 ===== */
#nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
}

.nav-list li {
  margin: 0;
}

.nav-list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.6em 1em;
  color: var(--fg);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.4;
}

.nav-list a:hover,
.nav-list a:focus {
  background: var(--border);
}

.nav-list a.active {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 3px solid var(--accent);
  border-radius: 0;
}

#chapter-links a {
  min-height: 48px;
}

/* ===== 頁面標題與說明 ===== */
h1 {
  font-size: 1.375rem;
  line-height: 1.35;
  font-weight: 700;
  margin: 0.5em 0 0.75em;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 600;
  margin: 1.25em 0 0.5em;
}

h3 {
  font-size: 1.05em;
  line-height: 1.3;
  margin: 1em 0 0.4em;
}

p {
  margin: 0.25em 0 0.75em;
}

/* ===== 章節格線（目錄頁） ===== */
.chapter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75em;
  margin: 0.75em 0;
}

@media (min-width: 30em) {
  .chapter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 48em) {
  .chapter-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.chapter-card {
  display: block;
  min-height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75em;
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.chapter-card:hover,
.chapter-card:focus {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.chapter-card .ch-title {
  font-weight: 700;
  font-size: 1.05em;
}

.chapter-card .ch-count {
  color: var(--muted);
  font-size: 0.9em;
}

/* ===== 經文清單（逐章閱讀頁） ===== */
.verse-list {
  list-style: none;
  margin: 0.75em 0;
  padding: 0;
}

.verse-list li {
  display: flex;
  gap: 0.6em;
  padding: 0.35em 0;
  border-bottom: 1px solid var(--border);
}

.verse-num {
  flex: 0 0 3rem;
  width: 3rem;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.8125rem;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 0.15em;
}

.verse-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
}

/* 參照區 */
.notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75em 1em;
  margin-top: 1em;
}

.notes ul {
  margin: 0;
  padding-left: 1.2em;
}

/* ===== 搜尋結果 ===== */
.search-results {
  list-style: none;
  margin: 0.75em 0;
  padding: 0;
}

.search-results li {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.6em 0.9em;
  margin-bottom: 0.5em;
  overflow-wrap: break-word;
}

.search-ref {
  display: inline-block;
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.4em;
  white-space: nowrap;
}

/* ===== 按鈕與表單 ===== */
button,
.btn,
input[type="submit"] {
  font: inherit;
  display: inline-block;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 6px;
  padding: 0.55em 1.2em;
  cursor: pointer;
  line-height: 1.3;
}

button:hover,
.btn:hover,
input[type="submit"]:hover {
  filter: brightness(1.08);
}

button:focus,
.btn:focus,
input[type="submit"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  filter: none;
}

input[type="text"],
input[type="search"] {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 0.55em 0.8em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
}

input[type="text"]:focus,
input[type="search"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

select {
  font: inherit;
  min-height: 44px;
  padding: 0.4em 0.6em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
}

/* ===== 錯誤訊息 ===== */
.error {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.1);
  padding: 0.6em 0.9em;
  border-radius: 6px;
}

@media (prefers-color-scheme: dark) {
  .error {
    color: #ff8a7a;
  }
}

/* ===== 頁尾 ===== */
footer {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9em;
  text-align: center;
}

.nav-list a:focus-visible,.chapter-card:focus-visible,.book-tabs a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ===== 書卷連結（四福音版）：橫向排列，手機可自動換行 ===== */
.book-tabs {
  list-style: none;
  margin: 0.5em 0 0.75em;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
}

.book-tabs li {
  margin: 0;
}

.book-tabs a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.45em 0.9em;
  color: var(--fg);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  line-height: 1.3;
}

.book-tabs a:hover,
.book-tabs a:focus {
  background: var(--border);
}

/* 目前這卷：明顯的目前狀態 */
.book-tabs a.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ===== 桌面：增大標題、經文與容器留白（≥48em） ===== */
@media (min-width: 48em) {
  h1 {
    font-size: 1.625rem;
  }

  .verse-text {
    font-size: 1.0625rem;
  }

  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .container-wide {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .reading-main,
  .chapter-sidebar {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .search-form {
    flex-direction: row;
    align-items: stretch;
  }

  .search-form input[type="search"] {
    flex: 1 1 auto;
  }

  .search-form select {
    flex: 0 0 auto;
    min-width: 130px;
  }

  .search-form button {
    flex: 0 0 auto;
    min-width: 80px;
  }
}

/* ===== 電腦／筆電版面（≥64em / 1024px） ===== */
@media (min-width: 64em) {
  .container {
    max-width: 64em;
  }

  .container-wide {
    max-width: 66em;
  }

  #nav .nav-list {
    max-width: 64em;
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
    gap: 0.5em;
    padding: 0.25em 1rem;
  }

  .nav-list a {
    padding: 0.6em 1.25em;
    border-radius: 8px;
    font-size: 1.025rem;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .nav-list a:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .chapter-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.85em;
  }

  .chapter-card {
    padding: 0.85em 1em;
  }

  .chapter-card .ch-title {
    font-size: 1.1rem;
  }

  /* 逐章閱讀頁：主閱讀欄 40-44em 置中，經文行長約 40 字，右側 sticky 章節導航 */
  .reading-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2.25rem;
    max-width: 64em;
    padding: 0 1.5rem;
  }

  .reading-main {
    flex: 1 1 42em;
    max-width: 44em;
    margin: 0;
    padding: 0.75em 0;
  }

  .chapter-sidebar {
    flex: 0 0 13.5em;
    margin: 1.25rem 0 0;
    padding: 0;
    position: sticky;
    top: 2rem;
  }

  .chapter-sidebar-sticky {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1em 1em;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }

  .chapter-sidebar-sticky h3 {
    margin-top: 0;
    margin-bottom: 0.75em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid var(--border);
  }

  .chapter-sidebar #chapter-links {
    flex-direction: column;
    gap: 0.5em;
  }

  .chapter-sidebar #chapter-links li {
    width: 100%;
  }

  .chapter-sidebar #chapter-links a {
    width: 100%;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .chapter-sidebar #chapter-links a:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }

  /* 搜尋結果分欄（2 欄） */
  .search-results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1em;
  }

  .search-results li {
    margin-bottom: 0;
    padding: 0.85em 1.1em;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .search-results li:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
}

/* ===== 寬螢幕桌面（≥90em / 1440px / 1920px） ===== */
@media (min-width: 90em) {
  .container {
    max-width: 78em;
  }

  .container-wide {
    max-width: 80em;
  }

  #nav .nav-list {
    max-width: 78em;
    gap: 0.75em;
  }

  .chapter-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 1em;
  }

  .chapter-card {
    padding: 1em 1.1em;
  }

  .reading-layout {
    max-width: 68em;
    gap: 3rem;
  }

  .reading-main {
    max-width: 45em;
  }

  .chapter-sidebar {
    flex: 0 0 14.5em;
  }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
