:root {
  --paper: #f6f0e4;
  --paper-2: #efe6d3;
  --card: #fbf8f1;
  --ink: #2b241c;
  --ink-2: #5d5244;
  --muted: #8a7c69;
  --line: #ddd1ba;
  --accent: #7b4a2a;
  --accent-ink: #fff8ee;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 8px 24px rgba(60, 40, 20, .10);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d1914;
    --paper-2: #262019;
    --card: #2a241c;
    --ink: #eee4d3;
    --ink-2: #cbbda7;
    --muted: #9b8c76;
    --line: #3d3428;
    --accent: #d9a273;
    --accent-ink: #1d1914;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--serif);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
h1, h2, .card-title { font-family: var(--display); font-weight: 600; line-height: 1.1; letter-spacing: .005em; }
h1 { font-size: clamp(2.4rem, 6vw, 4rem); margin: .2em 0 .3em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); margin: 0 0 .6em; }
.eyebrow { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.lead { font-size: 1.2rem; color: var(--ink-2); max-width: 40em; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem max(16px, calc((100% - 1200px) / 2));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-size: 1.45rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 1.15rem;
}
.topbar nav { display: flex; gap: 1.2rem; }
.topbar nav a { color: var(--ink-2); text-decoration: none; font-size: .98rem; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--accent); }
@media (max-width: 480px) { .topbar nav a[href$="#album"] { display: none; } }

main { padding: 0 16px; }
main > section, .album-head, .search { max-width: 1200px; margin-inline: auto; }

/* ---------- start ---------- */
.hero {
  display: grid; grid-template-columns: 1fr 1.15fr; gap: clamp(1.5rem, 5vw, 4rem); align-items: center;
  padding: clamp(2rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 4rem);
}
.hero-img img { border-radius: 4px; box-shadow: var(--shadow); filter: sepia(.15); }
.hero-img figcaption { font-size: .9rem; color: var(--muted); font-style: italic; margin-top: .6rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.6rem; }
.btn {
  display: inline-block; padding: .7rem 1.3rem; border-radius: 999px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; border: 1px solid var(--accent);
}
.btn-ghost { background: transparent; color: var(--accent); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } .hero-img { order: -1; } }

.prose p { margin: 0 0 1em; }
.intro { max-width: 40em !important; padding: 2.5rem 0; border-top: 1px solid var(--line); }
.intro .sign { font-style: italic; color: var(--ink-2); text-align: right; }
.intro .sub { font-family: var(--display); font-size: 1.35rem; font-style: italic; color: var(--ink-2); }
.story { margin-bottom: 2rem; }

.albums { padding: 2.5rem 0 3rem; border-top: 1px solid var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.6rem; }
.card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); }
.card-img { aspect-ratio: 4 / 3; overflow: hidden; background: #fff; border-bottom: 1px solid var(--line); }
.card-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card-body { display: flex; flex-direction: column; gap: .3rem; padding: 1rem 1.1rem 1.2rem; }
.card-title { font-size: 1.5rem; color: var(--ink); }
.card-text { font-size: .95rem; color: var(--ink-2); line-height: 1.5; }

/* ---------- album ---------- */
.album-head { padding: clamp(1.8rem, 5vw, 3.5rem) 0 1.5rem; }
.album-layout {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 120px minmax(0, 760px); gap: 2.5rem; justify-content: center;
}
.thumbs {
  position: sticky; top: 4.5rem; align-self: start; max-height: calc(100vh - 5.5rem); overflow-y: auto;
  display: flex; flex-direction: column; gap: .7rem; padding: .2rem .4rem .2rem 0; scrollbar-width: thin;
}
.thumbs a { display: block; position: relative; border: 2px solid transparent; border-radius: 3px; opacity: .7; transition: opacity .15s; }
.thumbs a:hover, .thumbs a.is-current { opacity: 1; border-color: var(--accent); }
.thumbs img { background: #fff; }
.thumbs span {
  position: absolute; right: 3px; bottom: 3px; font-size: .7rem; line-height: 1;
  background: var(--ink); color: var(--paper); padding: .2rem .35rem; border-radius: 2px;
}
.pages { display: flex; flex-direction: column; gap: 2.5rem; }
.page { margin: 0; scroll-margin-top: 4.5rem; }
.page-open {
  display: block; width: 100%; padding: 0; border: 0; background: #fff; cursor: zoom-in;
  box-shadow: var(--shadow); border-radius: 2px;
}
.page-open img { width: 100%; }
.page figcaption { padding: .8rem .1rem 0; }
.pageno { display: block; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pagetext { margin-top: .3rem; }
.pagetext summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.pagetext .prose { margin-top: .8rem; padding: 1.1rem 1.3rem .3rem; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.pagetext-none { margin: .2rem 0 0; font-size: .92rem; color: var(--muted); font-style: italic; }
@media (max-width: 760px) {
  .album-layout { grid-template-columns: minmax(0, 1fr); }
  .thumbs { display: none; }
}

.album-pager {
  max-width: 1200px; margin: 3.5rem auto 2rem; padding-top: 2rem; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.album-pager a { text-decoration: none; font-family: var(--display); font-size: 1.3rem; font-weight: 600; }
.album-pager small { display: block; font-family: var(--serif); font-size: .78rem; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.album-pager .next { text-align: right; }

/* ---------- viewer ---------- */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #120f0b; color: #eee4d3; overflow: hidden;
}
.viewer::backdrop { background: #120f0b; }
.viewer-bar {
  position: absolute; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; background: linear-gradient(#120f0bdd, #120f0b00);
}
.viewer-count { margin-right: auto; font-size: .9rem; opacity: .85; }
.viewer button {
  font: inherit; color: inherit; background: #ffffff1a; border: 1px solid #ffffff2a; border-radius: 999px;
  padding: .35rem .9rem; cursor: pointer;
}
.viewer button:hover { background: #ffffff33; }
.viewer-stage { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; padding: 3.2rem .5rem .5rem; overscroll-behavior: contain; }
.viewer-stage img { max-height: calc(100dvh - 3.7rem); width: auto; cursor: zoom-in; background: #fff; }
.viewer.zoomed .viewer-stage { place-items: start center; }
.viewer.zoomed .viewer-stage img { max-height: none; width: min(1600px, 200vw); max-width: none; cursor: zoom-out; }
.viewer-prev, .viewer-next {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
  width: 3rem; height: 3rem; padding: 0 !important; font-size: 2rem !important; line-height: 1;
}
.viewer-prev { left: .8rem; }
.viewer-next { right: .8rem; }
@media (max-width: 600px) { .viewer-prev, .viewer-next { top: auto; bottom: .8rem; transform: none; } }

/* ---------- sök ---------- */
.search { padding: clamp(1.8rem, 5vw, 3.5rem) 0 3rem; max-width: 820px !important; }
.search-form input {
  width: 100%; font: inherit; font-size: 1.2rem; padding: .8rem 1.1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; outline-offset: 2px;
}
.search-form input:focus { outline: 2px solid var(--accent); }
.search-status { color: var(--muted); font-size: .95rem; }
.results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.results a {
  display: grid; grid-template-columns: 72px 1fr; gap: 1rem; padding: .9rem; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
}
.results a:hover { border-color: var(--accent); }
.results img { background: #fff; box-shadow: var(--shadow); }
.results .where { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.results .snip { margin: .2rem 0 0; font-size: .97rem; line-height: 1.55; }
.results mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; padding: 0 .1em; border-radius: 2px; }

.foot { border-top: 1px solid var(--line); padding: 2rem 16px; text-align: center; color: var(--muted); font-size: .9rem; }
.foot p { margin: 0; }
.pagetext mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; padding: 0 .1em; border-radius: 2px; }
