/*
 * 計算Pro — calculator/index.php 列表頁樣式
 * 分頁引用：同層 href="style.css"；子目錄 href="../style.css"
 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap');

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

:root {
  /* 站方指定色票 */
  --bg-main: #f0f0f0;
  --bg-sub: #f1f1f1;
  --bg-panel: #f1f0eb;
  --btn-primary: #a80000;
  --btn-secondary: #b3a290;
  --btn-tertiary: #dae1e7;
  --contrast: #2b3e50;

  /* 語意別名（版面沿用） */
  --brand: var(--btn-primary);
  --brand-light: #f5efea;
  --brand-dark: #7a0000;
  --bg: var(--bg-main);
  --surface: #ffffff;
  --text: var(--contrast);
  --text-muted: #666;
  --text-hint: #888;
  --border: rgba(43, 62, 80, 0.1);
  --border-hover: rgba(43, 62, 80, 0.22);
  --shadow: 0 1px 3px rgba(43, 62, 80, 0.08), 0 1px 2px rgba(43, 62, 80, 0.05);
  --shadow-hover: 0 4px 12px rgba(43, 62, 80, 0.12), 0 2px 4px rgba(43, 62, 80, 0.06);
  --pin-gold: #c9a227;
}

body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--bg-main) 0%, var(--bg-sub) 45%, var(--bg-panel) 100%);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, var(--btn-primary) 0%, var(--brand-dark) 100%);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

header p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 1.2rem;
}

.search-wrap {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.95);
  color: var(--contrast);
  outline: none;
  transition: box-shadow 0.15s;
}

.search-wrap input:focus {
  box-shadow: 0 0 0 3px rgba(218, 225, 231, 0.9);
}

.header-links {
  margin-top: 1rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 0.5rem;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--btn-tertiary);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem 0.35rem;
  text-align: center;
}

.header-links a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.header-links a:hover,
.header-links a:focus {
  color: var(--btn-tertiary);
}

.header-links a:active,
.header-links a:visited {
  color: #fff;
}

.header-links .sep {
  color: rgba(255, 255, 255, 0.65);
  user-select: none;
  margin: 0 0.15rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.45;
  pointer-events: none;
}

.sticky-cats {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.sticky-cats::-webkit-scrollbar { display: none; }

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-sub);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--text-muted);
  transition: all 0.15s;
  margin-right: 0.4rem;
}

.cat-btn:hover {
  border-color: var(--btn-secondary);
  color: var(--contrast);
  background: var(--bg-panel);
}

.cat-btn.active {
  background: var(--btn-primary);
  border-color: var(--btn-primary);
  color: #fff;
  font-weight: 500;
}

.cat-count {
  font-size: 0.7rem;
  background: var(--btn-tertiary);
  border-radius: 10px;
  padding: 0 5px;
  color: var(--contrast);
}

.cat-btn.active .cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.big-section {
  margin-bottom: 2.5rem;
}

.big-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--contrast);
  margin: 1rem 0 0.8rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--btn-primary);
  background: var(--bg-panel);
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.big-section-title .count-badge {
  font-size: 0.72rem;
  font-weight: 500;
  color: #fff;
  background: var(--btn-primary);
  padding: 2px 8px;
  border-radius: 10px;
}

.big-section.favorites .big-section-title {
  color: var(--contrast);
  border-left-color: var(--pin-gold);
  background: #faf6e8;
}

.big-section.favorites .big-section-title .count-badge {
  background: var(--pin-gold);
  color: var(--contrast);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin: 1rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--btn-secondary);
  transform: translateY(-2px);
}

.card a {
  display: block;
  padding: 0.85rem 2.25rem 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  height: 100%;
}

.card a:hover {
  color: var(--btn-primary);
}

.card-emoji {
  font-size: 1.2rem;
  margin-bottom: 6px;
  display: block;
  line-height: 1;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-all;
}

.pin-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-hint);
  opacity: 0.45;
  transition: all 0.15s;
  padding: 0;
  z-index: 2;
}

.pin-btn:hover {
  opacity: 1;
  background: var(--btn-tertiary);
  transform: scale(1.1);
}

.pin-btn.pinned {
  opacity: 1;
  color: var(--pin-gold);
  filter: drop-shadow(0 0 2px rgba(201, 162, 39, 0.45));
}

.card.is-pinned {
  border-color: rgba(201, 162, 39, 0.45);
  box-shadow: 0 1px 3px rgba(201, 162, 39, 0.18), 0 1px 2px rgba(43, 62, 80, 0.05);
}

.no-result {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-hint {
  background: var(--bg-panel);
  border: 1.5px dashed var(--btn-secondary);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-hint);
  font-size: 0.85rem;
}

.stats-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-hint);
}

.cat-section { margin-bottom: 0.5rem; }
.cat-section.hidden { display: none; }
.big-section.hidden { display: none; }

.app-promo {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem 2.5rem;
  text-align: center;
  background: var(--bg-sub);
  border-top: 1px solid var(--border);
}

.app-promo-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--contrast);
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.app-promo-link {
  display: inline-block;
  max-width: min(100%, 640px);
  width: 100%;
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}

.app-promo-link:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.app-promo-link img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
}

.site-footer {
  text-align: center;
  padding: 1.25rem 1rem 2rem;
  font-size: 0.8rem;
  color: var(--text-hint);
}

@media (max-width: 480px) {
  header { padding: 1.5rem 1rem 1.2rem; }
  header h1 { font-size: 1.4rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
