/* 周氏大家族的點點滴滴 — 樣式 */

:root {
  --ink: #2b2320;
  --ink-soft: #6b5d55;
  --ink-faint: #9c8d84;
  --paper: #faf7f2;
  --paper-2: #f2ece3;
  --line: #e3dad0;
  --accent: #9a5b3d;
  --accent-dark: #7c452c;
  --dark: #1a1512;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43,35,32,.06), 0 8px 24px rgba(43,35,32,.08);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

.muted { color: var(--ink-faint); }

/* ---------- 頂欄 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(250,247,242,.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .06em;
  text-decoration: none;
}

.nav { display: flex; align-items: center; gap: clamp(.75rem, 2vw, 1.5rem); }
.nav a { text-decoration: none; font-size: .92rem; color: var(--ink-soft); white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav-cta {
  background: var(--accent); color: #fff !important;
  padding: .4rem .9rem; border-radius: 100px; font-weight: 500;
}
.nav-cta:hover { background: var(--accent-dark); }

/* ---------- 封面 ---------- */

.hero {
  position: relative;
  min-height: min(78vh, 640px);
  display: grid; place-items: center;
  text-align: center;
  color: #fff;
  overflow: hidden;
  background: var(--dark);
}
.hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: .62;
}
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(26,21,18,.5) 0%, rgba(26,21,18,.25) 40%, rgba(26,21,18,.85) 100%);
}
.hero-inner { position: relative; padding: 4rem 1.25rem 3rem; max-width: 44rem; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.6rem);
  letter-spacing: .1em;
  margin: 0 0 .75rem;
  text-shadow: 0 2px 24px rgba(0,0,0,.5);
}
.hero p {
  margin: 0 auto 1.75rem;
  font-size: clamp(.95rem, 2.2vw, 1.1rem);
  color: rgba(255,255,255,.9);
  text-shadow: 0 1px 12px rgba(0,0,0,.6);
  max-width: 32rem;
}
.hero-cta {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #fff; color: var(--ink);
  text-decoration: none;
  padding: .8rem 1.6rem;
  border-radius: 100px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  transition: transform .15s ease;
}
.hero-cta:hover { transform: translateY(-2px); }

/* ---------- 版面 ---------- */

.wrap { max-width: 76rem; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 2.5rem); }

.section-head { margin-bottom: 1.75rem; }
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  margin: 0 0 .25rem;
  letter-spacing: .04em;
}
.section-head p { margin: 0; color: var(--ink-faint); font-size: .92rem; }

/* ---------- 相簿列表 ---------- */

.albums { display: grid; gap: clamp(1rem, 2.5vw, 1.75rem); grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }

.album-card {
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
  display: block;
}
.album-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(43,35,32,.08), 0 16px 40px rgba(43,35,32,.14); }
.album-cover { aspect-ratio: 4/3; background: var(--paper-2); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-body { padding: .9rem 1.1rem 1.1rem; }
.album-date { font-size: .78rem; color: var(--accent); letter-spacing: .1em; font-weight: 500; }
.album-title { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin: .1rem 0 .3rem; }
.album-meta { font-size: .82rem; color: var(--ink-faint); }

/* ---------- 照片格 ---------- */

.grid {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border: none; padding: 0; margin: 0;
  background: var(--paper-2);
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.tile:hover img { transform: scale(1.05); }
.tile-badge {
  position: absolute; left: .4rem; bottom: .4rem;
  background: rgba(26,21,18,.72); color: #fff;
  font-size: .68rem; padding: .1rem .4rem; border-radius: 4px;
  backdrop-filter: blur(4px);
}

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--ink-faint); text-decoration: none; font-size: .9rem; }
.back-link:hover { color: var(--accent); }

/* ---------- 找自己 ---------- */

.finder { max-width: 52rem; margin: 0 auto; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: clamp(2rem, 6vw, 3.5rem) 1.5rem;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.dropzone.over { border-color: var(--accent); background: #fffaf6; }
.dropzone h3 { font-family: var(--serif); margin: 0 0 .4rem; font-size: 1.2rem; }
.dropzone p { margin: 0; color: var(--ink-faint); font-size: .9rem; }
.dz-icon { font-size: 2rem; margin-bottom: .5rem; opacity: .5; }

.steps { display: grid; gap: 1.5rem; margin-top: 2rem; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.panel h3 { font-family: var(--serif); margin: 0 0 .2rem; font-size: 1.05rem; }
.panel > p.hint { margin: 0 0 1rem; font-size: .86rem; color: var(--ink-faint); }

.facepick { display: flex; flex-wrap: wrap; gap: .75rem; }
.facepick button {
  border: 3px solid transparent;
  border-radius: 8px;
  padding: 0; background: none; cursor: pointer;
  line-height: 0;
  transition: border-color .15s, transform .15s;
  position: relative;
}
.facepick button img { width: 84px; height: 84px; object-fit: cover; border-radius: 5px; }
.facepick button:hover { transform: translateY(-2px); }
.facepick button.on { border-color: var(--accent); }
.facepick button.weak { opacity: .3; cursor: not-allowed; filter: grayscale(1); }
.facepick button.weak:hover { transform: none; }

.maybe {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}
.maybe > summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-size: .9rem;
  padding: .5rem 0;
  margin-bottom: 1rem;
}
.maybe > summary:hover { color: var(--accent); }
.facepick button.on::after {
  content: "✓";
  position: absolute; right: -6px; top: -6px;
  background: var(--accent); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 12px; line-height: 20px; text-align: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: 100px;
  padding: .7rem 1.5rem;
  font-family: var(--sans); font-size: .95rem; font-weight: 500;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-dark); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: none; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.btn-sm { padding: .4rem 1rem; font-size: .85rem; }

.field { display: flex; gap: .5rem; flex-wrap: wrap; }
.input {
  flex: 1; min-width: 12rem;
  border: 1px solid var(--line); border-radius: 8px;
  padding: .65rem .9rem;
  font-family: var(--sans); font-size: .95rem;
  background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.strictness { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-soft); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 100px; overflow: hidden; }
.seg button {
  border: none; background: #fff; color: var(--ink-soft);
  padding: .35rem .9rem; font-size: .82rem; cursor: pointer; font-family: var(--sans);
}
.seg button.on { background: var(--accent); color: #fff; }

.loading { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); font-size: .9rem; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { height: 3px; background: var(--paper-2); border-radius: 2px; overflow: hidden; margin-top: .5rem; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- 結果 ---------- */

.result-group { margin-bottom: 2.5rem; }
.result-group h3 {
  font-family: var(--serif); font-size: 1.1rem; margin: 0 0 .1rem;
  display: flex; align-items: baseline; gap: .6rem;
}
.result-group h3 .rg-date { font-family: var(--sans); font-size: .78rem; color: var(--accent); letter-spacing: .08em; }
.result-group h3 .rg-count { font-family: var(--sans); font-size: .78rem; color: var(--ink-faint); font-weight: 400; }
.result-group .grid { margin-top: .8rem; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-faint); }
.empty h3 { font-family: var(--serif); color: var(--ink); margin: 0 0 .4rem; }

/* ---------- 家人 ---------- */

.people-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr)); }
.person-card {
  text-decoration: none; text-align: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem .5rem; box-shadow: var(--shadow);
  transition: transform .15s;
}
.person-card:hover { transform: translateY(-2px); }
.person-card img {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; margin: 0 auto .6rem;
  border: 2px solid var(--paper-2);
}
.person-card .pname { font-family: var(--serif); font-weight: 600; font-size: .98rem; }
.person-card .pcount { font-size: .75rem; color: var(--ink-faint); }

/* ---------- 燈箱 ---------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,12,10,.96);
  display: flex; flex-direction: column;
}
.lightbox[hidden] { display: none; }
.lb-stage { flex: 1; display: grid; place-items: center; padding: 3rem 1rem 1rem; min-height: 0; }
.lb-imgwrap { position: relative; max-width: 100%; max-height: 100%; line-height: 0; }
.lb-imgwrap img { max-width: 100%; max-height: calc(100vh - 8rem); object-fit: contain; }
.lb-faces { position: absolute; inset: 0; pointer-events: none; }
.lb-faces.on { pointer-events: auto; }
.lb-face {
  position: absolute;
  border: 2px solid rgba(255,255,255,.85);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  cursor: pointer;
}
.lb-face:hover { border-color: var(--accent); }
.lb-face.named { border-color: #6fbf73; }
.lb-face .lbl {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -1.35rem; white-space: nowrap;
  background: rgba(0,0,0,.75); color: #fff;
  font-size: .7rem; padding: .05rem .35rem; border-radius: 3px;
}
.lb-close {
  position: absolute; top: .5rem; right: .75rem; z-index: 2;
  background: none; border: none; color: #fff; opacity: .7;
  font-size: 2.2rem; line-height: 1; cursor: pointer;
}
.lb-close:hover { opacity: 1; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  background: rgba(255,255,255,.1); border: none; color: #fff;
  width: 3rem; height: 4.5rem; font-size: 2rem; cursor: pointer;
  border-radius: 6px;
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: .5rem; }
.lb-next { right: .5rem; }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .75rem clamp(.75rem, 3vw, 2rem);
  color: rgba(255,255,255,.75); font-size: .82rem;
  border-top: 1px solid rgba(255,255,255,.1);
}
.lb-caption { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.lb-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  padding: .35rem .85rem; border-radius: 100px;
  font-size: .8rem; cursor: pointer; text-decoration: none;
  font-family: var(--sans);
}
.lb-btn:hover { background: rgba(255,255,255,.25); }

/* ---------- 提示 ---------- */

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: .65rem 1.2rem; border-radius: 100px;
  font-size: .88rem; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }

/* ---------- 管理模式 ---------- */

.admin-bar {
  background: #2b2320; color: #fff;
  padding: .5rem clamp(1rem, 4vw, 2.5rem);
  font-size: .82rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.admin-bar .btn { padding: .3rem .9rem; font-size: .78rem; }

/* ---------- 頁尾 ---------- */

.footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: .85rem;
  color: var(--ink-faint);
  font-family: var(--serif);
}
.footer p { margin: .15rem 0; }

@media (max-width: 640px) {
  .nav a:not(.nav-cta) { display: none; }
  .lb-nav { width: 2.25rem; height: 3.5rem; font-size: 1.5rem; }
}
