/* 永懷義郎 — 素雅溫暖的紀念風格 */
:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --ink: #3a352e;
  --muted: #8a8177;
  --accent: #9a7b4f;
  --accent-dark: #7c6039;
  --border: #e5ded2;
  --gold: #c9a962;                      /* 描框用的金色 */
  --gold-soft: rgba(185, 152, 90, 0.45); /* 較淡的金，用於次要框線 */
  --serif: 'Noto Serif TC', 'PMingLiU', serif;
  --sans: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; }

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

img { max-width: 100%; }

/* ── 頁首導覽 ── */
.site-header {
  border-bottom: 1px solid var(--gold-soft);
  background: var(--surface);
}
.site-header .inner {
  max-width: 960px; margin: 0 auto; padding: 0.9rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
}
.site-header .brand {
  font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.15em;
  color: var(--ink);
}
.site-header nav { display: flex; gap: 1.4rem; }
.site-header nav a { color: var(--muted); font-size: 0.95rem; letter-spacing: 0.05em; }
.site-header nav a.active, .site-header nav a:hover { color: var(--accent-dark); }

main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 2.5rem 1.2rem 4rem; }

footer {
  border-top: 1px solid var(--gold-soft);
  color: var(--muted); text-align: center;
  padding: 1.6rem 1rem; font-size: 0.85rem; letter-spacing: 0.1em;
}

/* ── 首頁 ── */
.hero { text-align: center; padding: 2.5rem 0 1rem; }
.hero-photo img {
  width: 220px; height: 220px; object-fit: cover; border-radius: 50%;
  border: 4px solid var(--surface);
  box-shadow: 0 0 0 1px var(--gold), 0 4px 24px rgba(58, 53, 46, 0.15);
  margin-bottom: 1.8rem;
}
.hero h1 { font-size: 2.4rem; letter-spacing: 0.25em; margin-bottom: 0.6rem; }
.hero .subtitle { color: var(--muted); letter-spacing: 0.2em; margin-bottom: 2rem; }
.hero .intro {
  max-width: 620px; margin: 0 auto; text-align: left;
  white-space: pre-line; color: var(--ink);
}

.divider {
  width: 60px; height: 1px; background: var(--accent);
  margin: 2.5rem auto; border: none;
}

.event-info { text-align: center; }
.event-info h2 { font-size: 1.3rem; letter-spacing: 0.2em; margin-bottom: 1rem; }
.event-info p { color: var(--muted); white-space: pre-line; }

.cta { display: flex; gap: 1rem; justify-content: center; margin-top: 2.5rem; flex-wrap: wrap; }

/* ── 按鈕 ── */
.btn {
  display: inline-block; padding: 0.7rem 1.8rem; border-radius: 4px;
  border: 1px solid var(--accent); color: var(--accent-dark);
  background: transparent; font-size: 1rem; font-family: var(--sans);
  letter-spacing: 0.1em; cursor: pointer; transition: all 0.2s;
}
.btn:hover { background: rgba(154, 123, 79, 0.08); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 0.3rem 0.9rem; font-size: 0.85rem; }

/* ── 通行碼閘門 ── */
.gate-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.gate-box {
  background: var(--surface); border: 1px solid var(--gold); border-radius: 8px;
  padding: 2.5rem 2.2rem; width: min(360px, 90vw); text-align: center;
  box-shadow: 0 4px 24px rgba(58, 53, 46, 0.08);
}
.gate-box h2 { letter-spacing: 0.15em; margin-bottom: 0.5rem; }
.gate-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.4rem; }
.gate-box input {
  width: 100%; padding: 0.7rem; font-size: 1.1rem; text-align: center;
  border: 1px solid var(--border); border-radius: 4px; margin-bottom: 1rem;
  background: var(--bg); letter-spacing: 0.2em;
}
.gate-box input:focus { outline: 2px solid var(--accent); }
.gate-error { color: #a04040; font-size: 0.85rem; margin-top: 0.8rem; min-height: 1.4em; }

/* ── 表單 ── */
.form-card {
  background: var(--surface); border: 1px solid var(--gold); border-radius: 8px;
  padding: 2rem; max-width: 640px; margin: 0 auto;
}
.page-title { text-align: center; font-size: 1.6rem; letter-spacing: 0.2em; margin-bottom: 0.5rem; }
.page-sub { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }
.field { margin-bottom: 1.3rem; }
.field label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.35rem; }
.field input, .field textarea {
  width: 100%; padding: 0.65rem 0.8rem; font-size: 1rem; font-family: var(--sans);
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); }
.field textarea { min-height: 130px; resize: vertical; }
.field .hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

/* 公開／僅家屬選項 */
.radio-row {
  display: flex; gap: 0.7rem; align-items: flex-start;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.7rem 0.9rem; margin-top: 0.5rem; cursor: pointer;
}
.radio-row:has(input:checked) { border-color: var(--accent); background: rgba(154, 123, 79, 0.06); }
.radio-row input { margin-top: 0.35rem; accent-color: var(--accent); }
.radio-row small { color: var(--muted); line-height: 1.5; display: inline-block; }

.tag-private {
  display: inline-block; font-size: 0.72rem; color: #fff; background: var(--accent);
  border-radius: 3px; padding: 0.05rem 0.5rem; margin-left: 0.5rem; vertical-align: middle;
}

/* 回憶片段區塊 */
.section-title { text-align: center; font-size: 1.15rem; letter-spacing: 0.2em; margin-bottom: 0.4rem; }
.section-hint { text-align: center; font-size: 0.82rem; color: var(--muted); margin-bottom: 1.2rem; line-height: 1.7; }
.moment-block {
  border: 1px solid var(--gold-soft); border-radius: 6px;
  padding: 1.1rem 1.2rem 0.9rem; margin-bottom: 1.2rem; background: rgba(154, 123, 79, 0.03);
}
.moment-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem;
}
.moment-title { font-family: var(--serif); color: var(--accent-dark); letter-spacing: 0.1em; }
.remove-moment {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 0.82rem;
}
.remove-moment:hover { color: #a04040; }

/* 管理頁的片段 */
.admin-moment {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.6rem 0.8rem; margin-top: 0.6rem; background: var(--bg);
}
.admin-moment.is-hidden { opacity: 0.5; }
.admin-moment-head {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; flex-wrap: wrap;
}
.admin-moment-head span:first-child { flex: 1; min-width: 0; }

/* 檔案選擇 */
.file-drop {
  border: 2px dashed var(--border); border-radius: 6px; padding: 1.6rem;
  text-align: center; color: var(--muted); cursor: pointer; transition: border-color 0.2s;
}
.file-drop:hover { border-color: var(--accent); }
.file-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.file-item {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem 0.8rem;
}
.file-item img.preview { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
.file-item .file-icon {
  width: 48px; height: 48px; border-radius: 4px; background: var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0;
}
.file-item .file-meta { flex: 1; min-width: 0; }
.file-item .file-name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-size { font-size: 0.75rem; color: var(--muted); }
.file-item .remove-btn {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0.3rem;
}
.progress-track { height: 5px; background: var(--border); border-radius: 3px; margin-top: 0.35rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width 0.25s; border-radius: 3px; }

.submit-row { text-align: center; margin-top: 1.8rem; }
.form-status { text-align: center; color: var(--muted); font-size: 0.9rem; margin-top: 1rem; min-height: 1.4em; }
.form-status.error { color: #a04040; }

.success-card {
  text-align: center; background: var(--surface); border: 1px solid var(--gold);
  border-radius: 8px; padding: 3rem 2rem; max-width: 640px; margin: 0 auto;
}
.success-card h2 { letter-spacing: 0.15em; margin-bottom: 1rem; }
.success-card p { color: var(--muted); margin-bottom: 2rem; }
.hidden { display: none !important; }

/* ── 回憶牆 ── */
.year-section { margin-bottom: 3rem; }
.year-heading {
  font-family: var(--serif); font-size: 1.5rem; color: var(--accent-dark);
  letter-spacing: 0.15em; border-bottom: 1px solid var(--gold);
  padding-bottom: 0.5rem; margin-bottom: 1.5rem;
}
.memory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.4rem; }
.memory-card {
  background: var(--surface); border: 1px solid var(--gold-soft); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
}
.memory-media { display: grid; gap: 2px; }
.memory-media.multi { grid-template-columns: 1fr 1fr; }
.memory-media .thumb {
  position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--border); cursor: pointer; border: none; padding: 0;
}
.memory-media .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory-media .thumb .play-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; color: #fff; background: rgba(0, 0, 0, 0.25); pointer-events: none;
}
.memory-body { padding: 1.1rem 1.2rem 1.2rem; flex: 1; display: flex; flex-direction: column; }
.memory-message { white-space: pre-line; flex: 1; font-size: 0.95rem; }
.memory-meta { margin-top: 0.9rem; font-size: 0.82rem; color: var(--muted); }
.memory-meta .memory-name { color: var(--accent-dark); }

.empty-note { text-align: center; color: var(--muted); padding: 4rem 1rem; }

/* 燈箱 */
.lightbox {
  position: fixed; inset: 0; background: rgba(20, 18, 16, 0.92); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.lightbox img, .lightbox video { max-width: 92vw; max-height: 88vh; border-radius: 4px; }
.lightbox .close-btn {
  position: absolute; top: 1rem; right: 1.4rem; background: none; border: none;
  color: #fff; font-size: 2rem; cursor: pointer; line-height: 1;
}

/* ── 管理頁 ── */
.stats-row { display: flex; gap: 1rem; justify-content: center; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-box {
  background: var(--surface); border: 1px solid var(--gold-soft); border-radius: 8px;
  padding: 1rem 1.8rem; text-align: center; min-width: 140px;
}
.stat-box .num { font-family: var(--serif); font-size: 1.6rem; color: var(--accent-dark); }
.stat-box .label { font-size: 0.8rem; color: var(--muted); }
.admin-list { display: flex; flex-direction: column; gap: 1rem; }
.admin-item {
  background: var(--surface); border: 1px solid var(--gold-soft); border-radius: 8px;
  padding: 1.1rem 1.3rem; display: flex; gap: 1rem; align-items: flex-start;
}
.admin-item.is-hidden { opacity: 0.55; background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 10px, var(--bg) 10px, var(--bg) 20px); }
.admin-item .info { flex: 1; min-width: 0; }
.admin-item .head { font-size: 0.9rem; margin-bottom: 0.3rem; }
.admin-item .head .name { color: var(--accent-dark); font-weight: 600; }
.admin-item .head .meta { color: var(--muted); font-size: 0.8rem; margin-left: 0.6rem; }
.admin-item .msg { font-size: 0.9rem; white-space: pre-line; }
.admin-item .thumbs { display: flex; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.admin-item .thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.8rem; }
  .form-card { padding: 1.4rem; }
  main { padding: 1.5rem 1rem 3rem; }
}
