/* ===== Reset & Variables ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e28;
  --surface: #1e2332;
  --surface2: #252b3b;
  --border: #2a3048;
  --border2: #353d55;
  --gold: #c9a84c;
  --gold2: #e8c97a;
  --gold-dim: rgba(201, 168, 76, 0.15);
  --text: #e8e4d8;
  --text2: #b8b3a5;
  --text3: #7a7568;
  --accent: #7b9fc4;
  --tag-bg: rgba(123, 159, 196, 0.12);
  --tag-color: #7b9fc4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.6);
  --transition: 0.25s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans TC', 'PingFang TC', sans-serif;
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  color: var(--gold);
  font-size: 18px;
}
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.header-sub {
  font-size: 13px;
  color: var(--text3);
  letter-spacing: 0.08em;
  border-left: 1px solid var(--border2);
  padding-left: 16px;
}

/* ===== Hero ===== */
.hero {
  max-width: 800px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  text-align: center;
}
.hero-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.hero-quote {
  border: none;
  margin-bottom: 20px;
}
.hero-quote-text {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(23px, 3.5vw, 32px);
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
  transition: opacity var(--transition);
}
.hero-quote-en {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: clamp(15px, 2vw, 18px);
  color: var(--text3);
  line-height: 1.5;
  transition: opacity var(--transition);
}
.hero-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.hero-author {
  font-size: 15px;
  font-weight: 500;
  color: var(--gold2);
}
.hero-source {
  font-size: 14px;
  color: var(--text3);
}
.hero-source::before {
  content: '· ';
}
.hero-depth {
  font-size: 15px;
  color: var(--text2);
  font-style: italic;
  max-width: 600px;
  margin: 0 auto 28px;
  padding: 12px 20px;
  border-left: 2px solid var(--gold);
  text-align: left;
  background: var(--gold-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.btn-random {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 10px 24px;
  border-radius: 32px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.04em;
}
.btn-random:hover {
  background: var(--gold);
  color: var(--bg);
}
.btn-icon {
  font-size: 16px;
}

/* ===== Filter Section ===== */
.filter-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 24px 0;
}
.filter-label {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.filter-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 20px;
}
.tag-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 14px;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.tag-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.tag-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold2);
}

/* ===== Search ===== */
.search-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px 0;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 16px;
  font-size: 18px;
  color: var(--text3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 12px 44px 12px 44px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input::placeholder {
  color: var(--text3);
}
.search-input:focus {
  border-color: var(--gold);
}
.search-clear {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  display: none;
  line-height: 1;
}
.search-clear:hover {
  color: var(--text);
}
.search-input:not(:placeholder-shown) + .search-clear {
  display: block;
}
.result-count {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text3);
  min-height: 18px;
}

/* ===== Cards Grid ===== */
.cards-grid {
  max-width: 960px;
  margin: 24px auto 0;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ===== Quote Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '❝';
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 40px;
  color: var(--border2);
  font-family: Georgia, serif;
  line-height: 1;
  pointer-events: none;
}
.card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  background: var(--surface2);
}
.card-quote {
  font-family: 'Noto Serif TC', serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  flex: 1;
  padding-right: 20px;
}
.card-author {
  font-size: 14px;
  color: var(--gold2);
  font-weight: 500;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card-tag {
  font-size: 13px;
  background: var(--tag-bg);
  color: var(--tag-color);
  border-radius: 12px;
  padding: 3px 10px;
  letter-spacing: 0.03em;
}
.card-hint {
  font-size: 11px;
  color: var(--text3);
  text-align: right;
  letter-spacing: 0.05em;
}

/* ===== No Result ===== */
.no-result {
  text-align: center;
  padding: 64px 24px;
  color: var(--text3);
}
.no-result-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
  transform: translateY(12px);
  transition: transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 16px 16px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  z-index: 10;
  transition: all var(--transition);
}
.modal-close:hover {
  color: var(--text);
  border-color: var(--text3);
}
.modal-content {
  padding: 24px 32px 36px;
}

.modal-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 16px;
}
.modal-quote {
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 10px;
}
.modal-quote-en {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--text3);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-author-block {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 24px;
}
.modal-author-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--gold2);
  margin-bottom: 4px;
}
.modal-author-bio {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.6;
}
.modal-section-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.modal-story {
  font-size: 16px;
  color: var(--text2);
  line-height: 1.85;
  margin-bottom: 24px;
  white-space: pre-line;
}
.modal-depth {
  background: var(--gold-dim);
  border-left: 2px solid var(--gold);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 16px;
  color: var(--text);
  font-style: italic;
  line-height: 1.7;
  margin-bottom: 20px;
}
.modal-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.modal-tag {
  font-size: 14px;
  background: var(--tag-bg);
  color: var(--tag-color);
  border-radius: 12px;
  padding: 4px 12px;
}
.modal-source {
  font-size: 14px;
  color: var(--text3);
  margin-top: 16px;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 24px;
  font-size: 15px;
  color: var(--text3);
  font-style: italic;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.card {
  animation: fadeIn 0.3s ease both;
}

/* ===== RWD ===== */
@media (max-width: 600px) {
  .hero {
    padding: 40px 16px 32px;
  }
  .filter-section,
  .search-section {
    padding-left: 16px;
    padding-right: 16px;
  }
  .cards-grid {
    padding: 0 16px 48px;
    grid-template-columns: 1fr;
  }
  .modal-content {
    padding: 20px 20px 28px;
  }
  .header-sub {
    display: none;
  }
}
