/* Album hành trình — thiết kế editorial ấm, ảnh làm chủ đạo. Sáng + tối.
   Palette: giấy ấm + mực + accent đất nung (terracotta). Một accent duy nhất, một hệ bo góc. */
:root {
  color-scheme: light dark;
  --paper: #f6f1e9;
  --paper-raised: #fffdf8;
  --ink: #2c2420;
  --muted: #7c6f66;
  --accent: #b85c3f;
  --accent-deep: #8d3f28;
  --line: #e7dccf;
  --line-soft: color-mix(in srgb, var(--line) 60%, transparent);
  --shadow-sm: 0 2px 10px rgba(66, 43, 31, .06);
  --shadow: 0 14px 34px rgba(66, 43, 31, .10);
  --shadow-lg: 0 26px 60px rgba(66, 43, 31, .16);
  --radius: 16px;
  --radius-sm: 11px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.02em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Màn khoá (mở album) ---------- */
.lock-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 15% 0%, color-mix(in srgb, var(--accent) 18%, transparent) 0, transparent 42%),
    radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--accent) 10%, transparent) 0, transparent 50%),
    var(--paper);
}
.lock-card {
  width: min(100%, 430px);
  padding: clamp(30px, 7vw, 52px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
}
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent-deep);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.lock-card h1 { margin: 0; font-size: clamp(2.1rem, 7vw, 2.9rem); line-height: 1.05; }
.lock-card > p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.6; }
#login-form { display: grid; gap: 10px; }
label { font-size: 1.02rem; font-weight: 650; }
.password-row { display: flex; gap: 8px; }
input {
  min-width: 0; flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus { border-color: var(--accent); }
.icon-button, .text-button { border: 0; border-radius: var(--radius-sm); color: var(--accent-deep); background: transparent; font-weight: 650; }
.icon-button { padding: 0 12px; }
.icon-button:hover, .text-button:hover { color: var(--accent); }
.primary-button {
  min-height: 48px; margin-top: 10px;
  border: 0; border-radius: var(--radius-sm);
  color: #fffaf5; background: var(--accent); font-weight: 700; letter-spacing: .01em;
  transition: background .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
  box-shadow: var(--shadow-sm);
}
.primary-button:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: var(--shadow); }
.primary-button:active { transform: translateY(0) scale(.99); }
.primary-button:disabled { cursor: wait; opacity: .7; }
.form-message { min-height: 1.2em; margin: 2px 0 0; color: #b02a1f; font-size: .88rem; line-height: 1.4; }

/* ---------- Khung hành trình ---------- */
.journey { width: min(100%, 1180px); margin: 0 auto; padding: 0 24px 96px; }
.hero { padding: 24px 0 clamp(40px, 7vw, 76px); }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--accent-deep); font-family: var(--serif); font-size: 1.2rem; font-weight: 600; text-decoration: none; }
.brand:hover { color: var(--accent); }
.text-button { padding: 9px 2px; font-size: .92rem; }
.hero-copy { max-width: 20ch; margin-top: clamp(32px, 6vw, 76px); }
.hero h1 { margin: 0; font-size: clamp(2.6rem, 8vw, 5.2rem); line-height: 1.0; letter-spacing: -.03em; }
.arrival-date { min-height: 1.4em; margin: 18px 0 0; max-width: 40ch; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.12rem); line-height: 1.5; }

.journey-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px; margin: clamp(30px, 5vw, 48px) 0 0;
  border-top: 1px solid var(--line);
}
.journey-stats div { padding: 16px 14px 0 0; }
.journey-stats dt { color: var(--muted); font-size: .78rem; letter-spacing: .01em; }
.journey-stats dd { margin: 4px 0 0; font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.1rem); color: var(--ink); }

/* ---------- Tabs ---------- */
.view-tabs { display: flex; gap: 4px; margin-bottom: 34px; border-bottom: 1px solid var(--line); }
.tab-button { position: relative; padding: 14px 6px; border: 0; color: var(--muted); background: transparent; font-weight: 650; transition: color .18s var(--ease); }
.tab-button:hover { color: var(--ink); }
.tab-button::after { position: absolute; right: 6px; bottom: -1px; left: 6px; height: 2px; content: ""; background: transparent; border-radius: 2px; transition: background .2s var(--ease); }
.tab-button.is-active { color: var(--ink); }
.tab-button.is-active::after { background: var(--accent); }
.content-panel { min-height: 320px; }

/* ---------- Dòng thời gian ---------- */
.timeline { display: grid; gap: clamp(40px, 6vw, 64px); }
.day-section { position: relative; }
.day-heading {
  position: sticky; z-index: 3; top: 12px;
  width: fit-content; margin: 0 0 18px; padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-deep);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  font-family: var(--serif); font-size: .96rem;
  box-shadow: var(--shadow-sm);
}
/* Masonry theo cột (multicol): mỗi thẻ giữ TỈ LỆ THẬT của ảnh, không cắt.
   Thứ tự chảy theo cột (trên→dưới từng cột). */
.photo-grid { columns: 2; column-gap: 12px; }

.photo-card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
  transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .28s var(--ease);
}
.photo-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.photo-button { display: block; width: 100%; padding: 0; border: 0; text-align: left; background: transparent; }
.photo-frame {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--paper)), color-mix(in srgb, var(--accent) 6%, var(--paper)));
}
/* Skeleton shimmer khi ảnh chưa về — tắt khi <img> đã tải (dùng :has). */
.photo-frame::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--paper-raised) 55%, transparent) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: shimmer 1.5s var(--ease) infinite;
}
.photo-frame:has(img.is-loaded)::after, .photo-frame:has(.photo-error)::after { content: none; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s var(--ease), transform .5s var(--ease); }
.photo-frame img.is-loaded { opacity: 1; }
.photo-card:hover .photo-frame img.is-loaded { transform: scale(1.045); }
.photo-frame .spinner { display: none; } /* skeleton shimmer thay cho spinner trong ô ảnh */
@keyframes shimmer { to { background-position: -200% 0; } }

.photo-info { display: grid; gap: 3px; padding: 11px 12px 13px; }
.photo-place { overflow: hidden; font-size: .92rem; font-weight: 650; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.photo-time, .photo-note { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.photo-note { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-style: italic; }
.photo-error { display: grid; height: 100%; place-items: center; padding: 14px; color: var(--muted); font-size: .78rem; text-align: center; }

.spinner { display: inline-block; width: 24px; height: 24px; border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state, .status-state {
  display: grid; min-height: 260px; place-items: center; gap: 14px;
  margin: 0; padding: 34px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center;
}

/* ---------- Bản đồ ---------- */
#map { height: min(68vh, 640px); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); box-shadow: var(--shadow-sm); }
.map-popup { min-width: 176px; }
.map-popup img { display: block; width: 100%; max-height: 132px; margin-bottom: 8px; border-radius: 7px; object-fit: cover; }
.map-popup p { margin: 3px 0; font-size: .82rem; }
.map-popup .map-popup-place { font-family: var(--serif); font-weight: 600; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; z-index: 10; inset: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 24px;
  background: rgba(24, 18, 15, .94);
  backdrop-filter: blur(4px);
}
.lightbox[hidden] { display: none; }
.lightbox-figure { display: grid; justify-items: center; max-width: min(100%, 1280px); max-height: calc(100dvh - 70px); margin: 0 auto; color: #fdf6ee; }
.lightbox-figure img { display: block; max-width: 100%; max-height: calc(100dvh - 128px); border-radius: 6px; object-fit: contain; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.lightbox-figure figcaption { max-width: 68ch; margin-top: 14px; color: rgba(253, 246, 238, .82); font-size: .9rem; text-align: center; }
.lightbox-close, .lightbox-nav, .download-button {
  border: 1px solid rgba(253, 246, 238, .28); color: #fdf6ee; background: rgba(253, 246, 238, .1);
  transition: background .18s var(--ease), transform .12s var(--ease);
}
.lightbox-close:hover, .lightbox-nav:hover, .download-button:hover:not(:disabled) { background: rgba(253, 246, 238, .22); }
.lightbox-nav:active, .download-button:active:not(:disabled) { transform: scale(.95); }
.lightbox-close { position: absolute; top: 18px; right: 20px; width: 42px; height: 42px; border-radius: 50%; font-size: 1.7rem; line-height: 1; }
.lightbox-nav { width: 44px; height: 60px; border-radius: 12px; font-size: 2rem; }
.download-button { position: absolute; right: 24px; bottom: 22px; padding: 11px 16px; border-radius: 10px; font-weight: 650; }
.download-button:disabled { opacity: .45; cursor: wait; }
.loading-inline { color: #fdf6ee; opacity: .85; }

/* ---------- Responsive ---------- */
@media (min-width: 680px) { .photo-grid { columns: 3; column-gap: 16px; } .photo-card { margin-bottom: 16px; } }
@media (min-width: 1024px) { .photo-grid { columns: 4; } }
@media (max-width: 600px) {
  .journey { padding: 0 16px 64px; }
  .lightbox { grid-template-columns: 1fr; padding: 20px 14px 72px; }
  .lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); }
  .lightbox-previous { left: 12px; } .lightbox-next { right: 12px; }
  .lightbox-close { top: 12px; right: 12px; }
  .download-button { right: 50%; bottom: 16px; transform: translateX(50%); }
}

/* ---------- Tôn trọng prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
  .photo-card, .photo-frame img, .primary-button { transition: none; }
  .photo-card:hover { transform: none; }
  .photo-card:hover .photo-frame img.is-loaded { transform: none; }
  .photo-frame::after, .spinner { animation: none; }
  .photo-frame::after { opacity: .4; }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1b19;
    --paper-raised: #2a2320;
    --ink: #f3ebe3;
    --muted: #bdaea4;
    --accent: #e08a68;
    --accent-deep: #f0a688;
    --line: #453832;
    --line-soft: color-mix(in srgb, var(--line) 60%, transparent);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .2);
    --shadow: 0 14px 34px rgba(0, 0, 0, .3);
    --shadow-lg: 0 26px 60px rgba(0, 0, 0, .42);
  }
  .primary-button { color: #241a14; }
  .form-message { color: #f0938a; }
  .leaflet-popup-content-wrapper, .leaflet-popup-tip { color: var(--ink); background: var(--paper-raised); }
}
