/* ===== Theme tokens: change colours here ===== */
:root {
  --bg: #f5efe6;        /* beige page */
  --surface: #ebe1d3;   /* light brown panels */
  --text: #3b2f25;      /* dark brown text */
  --muted: #7a6a5a;
  --brown: #a07c5a;     /* light brown accent */
  --winter: #6f8796;
  --spring: #6b8a4c;
  --summer: #9a7a2e;
  --autumn: #b5653b;
  --accent: var(--brown);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body {
  margin: 0;
  background: var(--page-bg, var(--bg));
  color: var(--text);
  transition: background-color 1.2s ease, color 1.2s ease;
  font: 17px/1.6 var(--sans);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

/* ===== Season accents ===== */
[data-season="winter"] { --accent: var(--winter); }
[data-season="spring"] { --accent: var(--spring); }
[data-season="summer"] { --accent: var(--summer); }
[data-season="autumn"] { --accent: var(--autumn); }

/* ===== Page background follows the season in view (set by script.js) ===== */
body[data-season="winter"]:not([data-theme]) { --page-bg: #edeeea; }
body[data-season="spring"]:not([data-theme]) { --page-bg: #eff0e1; }
body[data-season="summer"]:not([data-theme]) { --page-bg: #f7eedb; }
body[data-season="autumn"]:not([data-theme]) { --page-bg: #f4e5d8; }

/* ===== Festive themes: on event/trip blocks and their cards only.
   Colours checked for contrast in tests. ===== */
[data-theme] { color: var(--text); }
[data-theme="christmas"] { --page-bg: #6b1e1e; --bg: #6b1e1e; --surface: #7f2a27; --text: #f8efe1; --muted: #ecd6c0; --accent: #a8d1ad; }
[data-theme="new-year"]  { --page-bg: #16213a; --bg: #16213a; --surface: #22304f; --text: #f3ecdc; --muted: #cfc7b3; --accent: #d8b25a; }
[data-theme="midsummer"] { --page-bg: #e3eef6; --bg: #e3eef6; --surface: #d0e2ee; --text: #1f3447; --muted: #3f5568; --accent: #3a7345; }
[data-theme="easter"]    { --page-bg: #f8f0cf; --bg: #f8f0cf; --surface: #efe2ac; --text: #45371a; --muted: #62522f; --accent: #7a5aa3; }
[data-theme="vappu"]     { --page-bg: #fbfaf6; --bg: #fbfaf6; --surface: #efeee8; --text: #2b2b2b; --muted: #555555; --accent: #c8324f; }
/* Festive block: a full-width band in its theme colour. The colour beyond the
   content column is a wide shadow clipped to the block's height, so the page
   never scrolls sideways. */
.story[data-theme] {
  background: var(--page-bg);
  border-left: 0;
  border-radius: 0;
  box-shadow: 0 0 0 100vmax var(--page-bg);
  clip-path: inset(0 -100vmax);
}

/* ===== Hero ===== */
.hero {
  position: relative;
  min-height: 88vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 48px 16px;
  background: radial-gradient(ellipse at top, #fbf7f1, var(--bg) 60%, var(--surface));
  overflow: hidden;
}
.hero-photo {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: .35;
}
.hero-text { position: relative; }
.hero-kicker { letter-spacing: .25em; text-transform: uppercase; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.hero h1 { font-size: clamp(88px, 22vw, 220px); color: var(--brown); letter-spacing: -.02em; }
.hero-subtitle { font-family: var(--serif); font-size: clamp(18px, 3vw, 24px); font-style: italic; margin: 8px 0 32px; }
.hero-scroll {
  display: inline-block; padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--brown); text-decoration: none; font-size: 15px;
  transition: background .3s, color .3s;
}
.hero-scroll:hover { background: var(--brown); color: var(--bg); }

/* ===== Timeline months ===== */
#timeline { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.month {
  padding: 72px 0 32px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.month-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.month-num { font-family: var(--serif); font-size: 15px; color: color-mix(in srgb, var(--accent) 65%, var(--text)); letter-spacing: .2em; }
.month h2 { font-size: clamp(40px, 7vw, 72px); color: var(--accent); }
.intro { max-width: 680px; font-size: 18px; color: var(--muted); margin: 0 0 28px; }

/* ===== Photo grid (masonry-like columns) ===== */
.grid { columns: 1; column-gap: 16px; }
@media (min-width: 600px) { .grid { columns: 2; } }
@media (min-width: 1000px) { .grid { columns: 3; } }
.photo {
  break-inside: avoid;
  margin: 0 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(59, 47, 37, .08), 0 8px 24px rgba(59, 47, 37, .06);
}
.photo img { width: 100%; transition: transform .6s ease; }
.photo:hover img { transform: scale(1.03); }
.photo figcaption { padding: 10px 14px; font-size: 14px; color: var(--muted); background: var(--bg); }

/* Missing image → placeholder box */
.photo.missing img { display: none; }
.photo .ph {
  display: none;
  place-content: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface));
}
.photo.missing .ph { display: grid; }
.photo .ph span { display: block; font-family: ui-monospace, monospace; font-size: 12px; opacity: .8; }
.photo.landscape .ph { aspect-ratio: 3 / 2; }
.photo.portrait .ph { aspect-ratio: 3 / 4; }

/* ===== Event & trip blocks ===== */
.story {
  margin: 32px 0 16px;
  padding: 24px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border-left: 4px solid var(--accent);
}
.story-label { font-size: 12px; letter-spacing: .25em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) 65%, var(--text)); font-weight: 600; }
.story h3 { font-size: clamp(26px, 4vw, 36px); margin: 4px 0; }
.story-meta { color: var(--muted); font-size: 15px; margin: 0 0 12px; }
.story-text { max-width: 680px; margin: 0 0 20px; }

/* ===== Sticky month bar ===== */
#month-nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 4px; align-items: center;
  padding: 8px 16px;
  overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--surface);
}
#month-nav::-webkit-scrollbar { display: none; }
@media (min-width: 1000px) { #month-nav { justify-content: center; } }
#month-nav a {
  flex: none;
  padding: 6px 12px; border-radius: 999px;
  font-size: 14px; text-decoration: none; color: var(--muted);
  transition: background .3s, color .3s;
}
#month-nav a:hover { color: var(--text); }
#month-nav a.is-active { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.nav-sep { flex: none; width: 1px; height: 18px; background: var(--brown); opacity: .4; margin: 0 6px; }

/* ===== Trips & Events overview cards ===== */
.overview { max-width: 1200px; margin: 0 auto; padding: 72px 16px 24px; border-top: 1px solid var(--surface); }
.overview h2 { font-size: clamp(40px, 7vw, 64px); color: var(--brown); margin-bottom: 24px; }
.cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.card {
  display: block; text-decoration: none;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .35s ease, box-shadow .35s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(59, 47, 37, .12); }
.card-cover {
  aspect-ratio: 3 / 2;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, var(--surface)), var(--surface));
  background-size: cover; background-position: center;
}
.card-body { padding: 14px 18px 18px; }
.card-month { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) 65%, var(--text)); font-weight: 600; }
.card h3 { font-size: 24px; margin: 2px 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }

/* ===== Scroll reveal (only hidden when JS runs) ===== */
html.js .reveal {
  opacity: 0;
  transform: translateY(24px) scale(.98);
  transition: opacity .7s ease-out, transform .7s cubic-bezier(.2, .7, .2, 1);
  transition-delay: var(--delay, 0ms);
}
html.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body { transition: none; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  #viewer, #viewer img { animation: none; }
}
.noscript { max-width: 680px; margin: 48px auto; padding: 16px; text-align: center; background: var(--surface); border-radius: var(--radius); }

/* ===== Full-screen viewer ===== */
body.viewer-open { overflow: hidden; }
#viewer {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 56px 72px;
  background: rgba(36, 28, 22, .92);
  touch-action: none; /* let the page handle horizontal swipes */
  animation: fade .3s ease;
}
#viewer[hidden] { display: none; }
#viewer figure { margin: 0; max-width: 100%; max-height: 100%; text-align: center; }
#viewer img {
  max-width: min(100%, 1600px); max-height: calc(100vh - 160px);
  width: auto; height: auto; margin: 0 auto;
  border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  animation: pop .35s cubic-bezier(.2, .7, .2, 1);
}
#viewer.missing img { display: none; }
#viewer.missing figure::before {
  content: "Kuvan paikka\A" attr(data-file);
  white-space: pre; display: grid; place-items: center;
  width: min(80vw, 640px); aspect-ratio: 3 / 2; margin: 0 auto;
  border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 15px;
}
#viewer .caption { color: #f5efe6; font-family: var(--serif); font-size: 18px; margin-top: 14px; }
#viewer button {
  position: absolute; border: 0; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(245, 239, 230, .15); color: #f5efe6;
  font-size: 28px; line-height: 1;
  transition: background .2s;
}
#viewer button:hover, #viewer button:focus-visible { background: rgba(245, 239, 230, .3); outline: none; }
#viewer .close { top: 12px; right: 16px; }
#viewer .prev { left: 16px; top: 50%; transform: translateY(-50%); }
#viewer .next { right: 16px; top: 50%; transform: translateY(-50%); }
@media (max-width: 600px) {
  #viewer { padding: 56px 12px 88px; }
  #viewer .prev, #viewer .next { top: auto; bottom: 20px; transform: none; }
  #viewer .prev { left: calc(50% - 56px); }
  #viewer .next { right: calc(50% - 56px); }
}
.photo:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* ===== Footer ===== */
.site-footer { text-align: center; padding: 48px 16px 64px; color: var(--muted); font-size: 15px; }
