/*
Theme Name: Scout Theme (彰化縣童軍會專屬主題)
Theme URI: https://changhua-scout.tw
Author: 彰化縣童軍會資訊小組
Description: 專為彰化縣童軍會設計之現代化 RWD 響應式主題，具備無障礙友善結構、全螢幕與行動裝置最適化體驗。
Version: 1.1.0
License: GNU General Public License v2 or later
Text Domain: scout-theme
*/

:root {
  --primary: #1b5e20;        /* 童軍綠 */
  --primary-light: #2e7d32;
  --primary-dark: #0f3d13;
  --accent: #f9a825;         /* 童軍金黃 */
  --navy: #1a237e;           /* 徽章藍 */
  --text-main: #212121;
  --text-muted: #616161;
  --bg-light: #f4f6f8;
  --bg-white: #ffffff;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  color: var(--text-main);
  background-color: var(--bg-light);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 16px; /* 避免 iOS Safari 點擊聚焦時自動放大畫面 */
  -webkit-appearance: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover, a:focus {
  color: var(--primary-light);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 20px);
}

/* ==========================================================================
   Header & Navigation (RWD Mobile First)
   ========================================================================== */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  box-shadow: var(--shadow-md);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1000;
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  position: relative;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.site-logo-img {
  width: auto;
  height: clamp(38px, 6vw, 48px);
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35));
  transition: transform 0.2s ease;
}

.site-logo-link:hover .site-logo-img {
  transform: scale(1.05);
}

.site-title {
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  font-weight: 700;
  color: white;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-title a {
  color: white;
  text-decoration: none;
}

.site-tagline {
  font-size: clamp(0.72rem, 2vw, 0.85rem);
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

/* 漢堡選單按鈕 */
.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  width: 42px;
  height: 42px;
  padding: 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.nav-toggle:hover, .nav-toggle:focus {
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}

.hamburger-line {
  width: 22px;
  height: 2px;
  background-color: white;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle.active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 10px;
}

.nav-menu a {
  color: white;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background 0.2s ease;
  display: inline-block;
}

.nav-menu a:hover, .nav-menu .current-menu-item a {
  background: rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

/* 行動端導覽適配 */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

  .site-nav.active {
    display: block;
    animation: fadeInDown 0.2s ease-out;
  }

  .nav-menu {
    flex-direction: column;
    gap: 6px;
  }

  .nav-menu a {
    display: block;
    padding: 12px 16px;
    font-size: 1.05rem;
    background: rgba(255, 255, 255, 0.1);
  }

  .nav-menu a:active {
    background: rgba(255, 255, 255, 0.25);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero-section {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: clamp(16px, 3vw, 30px) 0;
  margin-bottom: clamp(16px, 3vw, 30px);
}

.hero-banner {
  background: linear-gradient(rgba(15, 61, 19, 0.82), rgba(15, 61, 19, 0.92)), url('https://images.unsplash.com/photo-1510312305653-8ed496efae75?auto=format&fit=crop&w=1200&q=80') center/cover;
  color: white;
  padding: clamp(24px, 5vw, 45px) clamp(16px, 4vw, 30px);
  border-radius: var(--radius);
  text-align: center;
}

.hero-banner h1 {
  font-size: clamp(1.4rem, 4.5vw, 2.2rem);
  margin-bottom: 8px;
  font-weight: 700;
}

.hero-banner p {
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  color: #ffeb3b;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Layout Grid & Cards
   ========================================================================== */
.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 30px);
  margin-bottom: 30px;
}

@media (max-width: 860px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow-sm);
  margin-bottom: clamp(16px, 3vw, 25px);
  border: 1px solid rgba(0,0,0,0.03);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  margin-bottom: 16px;
  gap: 10px;
}

.section-title {
  font-size: clamp(1.15rem, 3vw, 1.35rem);
  color: var(--primary-dark);
  font-weight: 700;
}

/* ==========================================================================
   News List (Mobile Optimized)
   ========================================================================== */
.news-list {
  list-style: none;
}

.news-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-color);
  gap: 15px;
}

.news-item:last-child {
  border-bottom: none;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.news-date {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.news-badge {
  background: var(--bg-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.news-title {
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 500;
  flex-grow: 1;
  line-height: 1.5;
  word-break: break-word;
}

/* 行動端公告列表自動折行排版 */
@media (max-width: 640px) {
  .news-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 0;
  }

  .news-meta {
    font-size: 0.8rem;
    gap: 6px;
  }

  .news-title {
    font-size: 1rem;
    width: 100%;
  }
}

/* ==========================================================================
   Album Grid (2-column on mobile)
   ========================================================================== */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 45vw, 240px), 1fr));
  gap: clamp(10px, 2.5vw, 20px);
}

.album-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.album-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.album-thumbnail {
  width: 100%;
  height: clamp(120px, 25vw, 160px);
  object-fit: cover;
  background: #eee;
}

.album-info {
  padding: 10px 12px;
  flex-grow: 1;
}

.album-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
}

/* ==========================================================================
   Single Article Content & RWD Tables
   ========================================================================== */
.entry-content {
  font-size: clamp(0.98rem, 2.5vw, 1.05rem);
  line-height: 1.8;
  word-break: break-word;
  overflow-wrap: break-word;
}

.entry-content p {
  margin-bottom: 1em;
}

/* 自適應橫向捲動表格（解決 Word 匯入之固定寬度表格在手機破版問題） */
.entry-content table {
  display: block;
  width: 100% !important;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 15px 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.entry-content th,
.entry-content td {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
}

.entry-content img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
  margin: 10px 0;
}

/* ==========================================================================
   Attachments Box
   ========================================================================== */
.attachments-box {
  background: #f1f8e9;
  border: 1px solid #c8e6c9;
  border-radius: var(--radius);
  padding: clamp(12px, 3vw, 20px);
  margin: 25px 0;
}

.attachments-title {
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: white;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid #dcedc8;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment-item strong {
  word-break: break-all;
  font-size: 0.95rem;
}

/* ==========================================================================
   Links & Buttons
   ========================================================================== */
.link-list {
  list-style: none;
}

.link-item {
  margin-bottom: 10px;
}

.link-btn {
  display: block;
  padding: 12px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-main);
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
  text-align: center;
  min-height: 44px;
}

.link-btn:hover {
  background: #e8f5e9;
  border-color: var(--primary);
  text-decoration: none;
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination {
  margin-top: 25px;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.9rem;
}

.pagination .page-numbers.current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination .page-numbers:hover:not(.current) {
  background: var(--bg-light);
  text-decoration: none;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: #263238;
  color: #cfd8dc;
  padding: clamp(20px, 4vw, 35px) 0;
  margin-top: 40px;
  font-size: 0.85rem;
  text-align: center;
  border-top: 3px solid var(--accent);
}

/* ==========================================================================
   WordPress File Block (PDF & Document Download Box - No Inline Embed)
   ========================================================================== */
.wp-block-file__embed,
.wp-block-file object {
  display: none !important;
  height: 0 !important;
  visibility: hidden !important;
}

.wp-block-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4fbf4;
  border: 1px solid #c8e6c9;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin: 18px 0;
  gap: 15px;
  flex-wrap: wrap;
}

.wp-block-file a:not(.wp-block-file__button) {
  font-weight: 600;
  color: var(--primary-dark);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
}

.wp-block-file a:not(.wp-block-file__button)::before {
  content: '📄 ';
  font-size: 1.15rem;
}

.wp-block-file a.wp-block-file__button {
  background: var(--primary);
  color: white !important;
  padding: 8px 18px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s ease;
  display: inline-block;
  min-height: 40px;
  line-height: 24px;
}

.wp-block-file a.wp-block-file__button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}
