/* ================= fonts ================= */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/cormorant-garamond.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/cormorant-garamond-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ================= themes ================= */
:root {
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}
:root, :root[data-theme="porcelain"] {
  --bg: #ffffff;
  --fg: #1a1816;
  --muted: #8f8b86;
  --line: #eae7e3;
  --card: #f7f5f2;
  --accent: #7f1734;
  --overlay: rgba(255,255,255,.92);
  --lb-bg: rgba(12,12,12,.95);
  --lb-fg: #ffffff;
}
:root[data-theme="charcoal"] {
  --bg: #161618;
  --fg: #e6e4e1;
  --muted: #85837f;
  --line: #2a2a2d;
  --card: #1f1f22;
  --accent: #a04452;
  --overlay: rgba(22,22,24,.93);
  --lb-bg: rgba(10,10,11,.97);
  --lb-fg: #ffffff;
}
:root[data-theme="mono"] {
  --bg: #ffffff;
  --fg: #0c0c0c;
  --muted: #909090;
  --line: #e8e8e8;
  --card: #f7f7f7;
  --accent: #0c0c0c;
  --overlay: rgba(255,255,255,.92);
  --lb-bg: rgba(8,8,8,.96);
  --lb-fg: #ffffff;
}
:root[data-theme="pastel-blue"] {
  --bg: #eef3f9;
  --fg: #10151b;
  --muted: #8494a6;
  --line: #dbe5f0;
  --card: #ffffff;
  --accent: #9db8dc;
  --overlay: rgba(238,243,249,.92);
  --lb-bg: rgba(13,18,26,.96);
  --lb-fg: #ffffff;
}
:root[data-theme="pastel-blush"] {
  --bg: #faf5f0;
  --fg: #171310;
  --muted: #a4948a;
  --line: #eee2d8;
  --card: #ffffff;
  --accent: #e3bfb6;
  --overlay: rgba(250,245,240,.92);
  --lb-bg: rgba(20,15,12,.96);
  --lb-fg: #ffffff;
}

/* ================= base ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .5s ease, color .5s ease;
  min-height: 100vh;
}
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--bg); }

/* ================= header ================= */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 1.4rem clamp(1.2rem, 4vw, 3rem);
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}
.site-header a { pointer-events: auto; }
.brand {
  font-family: var(--serif); font-size: 1.5rem; font-weight: 500; letter-spacing: .12em;
  text-transform: lowercase; transition: letter-spacing .5s ease;
}
.brand:hover { letter-spacing: .17em; }
.site-header { transition: background .4s, box-shadow .4s; }
.site-header.scrolled {
  background: var(--overlay); backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--line);
}
.site-nav { display: flex; gap: 1.6rem; }
.site-nav a {
  font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
  position: relative; transition: color .3s;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; height: 1px; width: 100%;
  background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform .35s cubic-bezier(.7,0,.2,1);
}
.site-nav a:hover, .site-nav a.active { color: var(--fg); }
.site-nav a.active::after { transform: scaleX(1); transform-origin: left; }

/* ================= view / transitions ================= */
.view {
  padding: clamp(4.6rem, 9vh, 6rem) clamp(.6rem, 1.4vw, 1.4rem) 3rem;
  animation: viewIn .4s cubic-bezier(.25,.6,.2,1) both;
}
/* only the gallery runs edge to edge; prose and the admin stay readable */
.about, .admin { max-width: 1500px; margin: 0 auto; padding: 2rem clamp(.6rem, 2.6vw, 2rem) 0; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============ the gallery: justified rows, one page, edge to edge ============
   Photos keep their aspect ratio; every row is flush with both edges. Rows are
   packed in js (justify.js) and flexed here, so a resize keeps them justified. */
.album { margin-bottom: clamp(2.4rem, 4.5vw, 4rem); }
.album h2 {
  font-family: var(--serif); font-weight: 500; letter-spacing: .02em;
  font-size: clamp(1.45rem, 2.5vw, 2rem); line-height: 1.2;
  margin: 0 0 .85rem .1rem;
}
.rows { display: flex; flex-direction: column; gap: var(--gap, 24px); }
.row { display: flex; gap: var(--gap, 24px); }
.row figure { min-width: 0; background: var(--card); cursor: zoom-in; }
.row img { width: 100%; height: auto; }
.row figcaption { display: none; }
.empty { color: var(--muted); font-style: italic; margin-top: 2rem; }

/* ================= about ================= */
.about { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.about-photo { overflow: hidden; background: var(--card); }
.about-photo img { width: 100%; }
.about-photo.placeholder { aspect-ratio: 4/5; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .75rem; letter-spacing: .2em; }
.about-text {
  font-family: var(--serif); font-weight: 400; font-size: 1.35rem; line-height: 1.75;
  max-width: 30em; white-space: pre-line;
}
.about-text .placeholder { color: var(--muted); font-style: italic; }
.about-contact { margin-top: 2.2rem; font-size: .8rem; letter-spacing: .12em; color: var(--muted); }
.dots { display: flex; gap: .9rem; margin-top: 3.2rem; align-items: center; }
.dot-admin, .dot-legacy {
  display: block; width: 13px; height: 13px; border-radius: 50%;
  opacity: .85; transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .3s;
}
.dot-admin { background: var(--fg); }
.dot-legacy { border: 1.5px solid var(--fg); }
.dot-admin:hover, .dot-legacy:hover { transform: scale(1.35); opacity: 1; }

/* ================= password popup ================= */
.popup {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: var(--overlay); backdrop-filter: blur(10px);
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.popup-card { text-align: center; animation: popIn .4s cubic-bezier(.2,1.2,.3,1); }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(8px); } }
.popup-card input {
  background: none; border: 0; border-bottom: 1px solid var(--fg); outline: none;
  font-size: 1.6rem; letter-spacing: .6em; text-align: center; width: 9rem; padding: .3rem 0 .5rem .6em;
  color: var(--fg);
}
.popup-card input::placeholder { color: var(--muted); }
.popup-card.shake { animation: shake .45s; }
@keyframes shake {
  20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); }
}

/* ================= lightbox ================= */
.lightbox { position: fixed; inset: 0; z-index: 80; background: var(--lb-bg); backdrop-filter: blur(6px); animation: fadeIn .25s ease; touch-action: none; }
.lb-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lb-frame {
  display: inline-flex; line-height: 0;
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
  will-change: transform;
}
.lb-frame.gesturing { transition: none; }
.lb-frame.zoomed { cursor: grab; }
.lb-stage img {
  max-width: 92vw; max-height: 88vh; user-select: none; cursor: zoom-in;
  transition: opacity .25s;
}
.lb-btn {
  position: absolute; z-index: 2; color: var(--lb-fg); opacity: .6; font-size: 1.5rem; line-height: 1;
  padding: 1.1rem; transition: opacity .25s, transform .25s;
}
.lb-btn:hover { opacity: 1; transform: scale(1.12); }
.lb-close { top: .6rem; right: .8rem; font-size: 1.05rem; }
.lb-prev { left: .4rem; top: 50%; transform: translateY(-50%); font-size: 2.2rem; }
.lb-next { right: .4rem; top: 50%; transform: translateY(-50%); font-size: 2.2rem; }
.lb-prev:hover, .lb-next:hover { transform: translateY(-50%) scale(1.15); }
.lb-caption {
  position: absolute; left: 1.4rem; bottom: 1.1rem; max-width: 60vw;
  color: var(--lb-fg); opacity: .85; font-family: var(--serif); font-style: italic;
  font-size: 1.05rem; letter-spacing: .03em;
}
.lb-counter { position: absolute; right: 1.4rem; bottom: 1.1rem; color: var(--lb-fg); opacity: .45; font-size: .72rem; letter-spacing: .2em; }

/* ================= admin ================= */
.admin { display: grid; grid-template-columns: 240px 1fr; gap: 2.5rem; }
.admin-side { position: sticky; top: 6rem; align-self: start; }
.admin-side h2 { font-size: .72rem; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); margin: 1.6rem 0 .7rem; font-weight: 500; }
.admin-works { list-style: none; }
.admin-works li {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .6rem; border-radius: 3px; font-size: .92rem; cursor: pointer;
  border: 1px dashed transparent; transition: background .25s, border-color .25s;
}
.admin-works li:hover { background: var(--card); }
.admin-works li.sel { background: var(--card); font-weight: 500; }
.admin-works li.drop-target { border-color: var(--fg); background: var(--card); }
.admin-works li .n { margin-left: auto; font-size: .68rem; color: var(--muted); }
.admin-works li .grip { color: var(--muted); font-size: .8rem; cursor: grab; }
.admin-add {
  font-size: .8rem; color: var(--muted); padding: .45rem .6rem; transition: color .3s;
}
.admin-add:hover { color: var(--fg); }
.admin-main { min-width: 0; }
.admin-bar { display: flex; align-items: baseline; gap: 1.2rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.admin-bar h1 { font-size: 1.6rem; font-weight: 300; }
.admin-bar .spacer { flex: 1; }
.admin-bar button, .admin-ghost {
  font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  transition: color .3s;
}
.admin-bar button:hover, .admin-ghost:hover { color: var(--fg); }
.admin-bar button.danger:hover { color: #c0392b; }

.dropzone {
  border: 1px dashed var(--line); border-radius: 3px; padding: 1.1rem; text-align: center;
  font-size: .78rem; letter-spacing: .14em; color: var(--muted); cursor: pointer;
  margin-bottom: 1.4rem; transition: border-color .3s, color .3s, background .3s;
}
.dropzone.drag, .dropzone:hover { border-color: var(--fg); color: var(--fg); background: var(--card); }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .8rem; }
.admin-grid .ph {
  position: relative; border-radius: 2px; overflow: hidden; cursor: grab; background: var(--card);
  aspect-ratio: 1; transition: transform .25s, box-shadow .25s, opacity .2s;
}
.admin-grid .ph img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.admin-grid .ph:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -12px rgba(0,0,0,.4); }
.admin-grid .ph.dragging { opacity: .3; }
.admin-grid .ph.drop-before::before {
  content: ""; position: absolute; left: -5px; top: 0; bottom: 0; width: 2px; background: var(--fg); z-index: 2;
}
.admin-grid .ph .badges { position: absolute; top: .3rem; left: .3rem; display: flex; gap: .25rem; }
.admin-grid .ph .badge { background: rgba(0,0,0,.55); color: #fff; font-size: .6rem; padding: .1rem .35rem; border-radius: 2px; letter-spacing: .08em; }
/* an archived photo stays here, greyed out, and off the site */
.admin-grid .ph.archived img { opacity: .32; filter: grayscale(1); }
.admin-grid .ph.archived:hover img { opacity: .55; }
.admin-grid .ph .badge.archived { background: var(--fg); color: var(--bg); }

.editor {
  position: fixed; inset: 0 0 0 auto; width: min(420px, 100vw); z-index: 70; background: var(--bg);
  border-left: 1px solid var(--line); padding: 2rem; overflow-y: auto;
  animation: slideIn .4s cubic-bezier(.2,.8,.2,1);
  box-shadow: -30px 0 60px -40px rgba(0,0,0,.3);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.editor img { border-radius: 2px; margin-bottom: 1.2rem; max-height: 42vh; object-fit: contain; }
.editor label { display: block; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 1.2rem 0 .4rem; }
.editor textarea, .editor input[type=text] {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 3px;
  padding: .6rem .7rem; font-size: .9rem; outline: none; resize: vertical; transition: border-color .3s;
}
.editor textarea:focus, .editor input:focus { border-color: var(--fg); }
.editor .row { display: flex; gap: .8rem; margin-top: 1.6rem; flex-wrap: wrap; }

.theme-pick { display: flex; gap: .7rem; flex-wrap: wrap; }
.theme-pick button {
  width: 70px; height: 44px; border-radius: 3px; border: 1px solid var(--line); position: relative;
  overflow: hidden; transition: transform .25s, border-color .25s;
}
.theme-pick button:hover { transform: translateY(-2px); }
.theme-pick button.sel { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
.theme-pick .sw { position: absolute; inset: 0; }
.theme-pick .sw i { position: absolute; display: block; }

.settings-form { max-width: 480px; }
.settings-form label { display: block; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 1.4rem 0 .4rem; }
.settings-form input[type=text], .settings-form textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 3px;
  padding: .6rem .7rem; font-size: .9rem; outline: none; transition: border-color .3s;
}
.settings-form input:focus, .settings-form textarea:focus { border-color: var(--fg); }
.save-btn {
  margin-top: 1.6rem; border: 1px solid var(--fg); border-radius: 3px; padding: .55rem 1.6rem;
  font-size: .74rem; letter-spacing: .2em; text-transform: uppercase;
  transition: background .3s, color .3s;
}
.save-btn:hover { background: var(--fg); color: var(--bg); }
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--fg); color: var(--bg); font-size: .76rem; letter-spacing: .12em;
  padding: .5rem 1.2rem; border-radius: 3px; animation: toastIn .3s cubic-bezier(.2,1,.3,1);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---- upload progress: a long drop of 30 MB exports needs a moving bar,
   not a toast, and must say when it switches from sending to encoding ---- */
.uploader {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 120;
  background: var(--overlay); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: .7rem 1.2rem .8rem;
  animation: upIn .25s cubic-bezier(.2,1,.3,1);
}
@keyframes upIn { from { opacity: 0; transform: translateY(100%); } }
.uploader-row {
  display: flex; align-items: baseline; gap: 1rem;
  font-size: .72rem; letter-spacing: .1em; color: var(--fg);
}
.uploader-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploader-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.uploader-track {
  margin-top: .5rem; height: 2px; background: var(--line); overflow: hidden;
}
.uploader-fill {
  height: 100%; width: 0; background: var(--accent);
  transition: width .18s linear;
}
/* the server is still encoding: bytes are all sent, so sweep instead of fill */
.uploader.working .uploader-fill {
  width: 100% !important; transition: none;
  background: linear-gradient(90deg, var(--line) 0 40%, var(--accent) 50%, var(--line) 60% 100%);
  background-size: 250% 100%;
  animation: upSweep 1.1s linear infinite;
}
@keyframes upSweep { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .uploader { animation: none; }
  .uploader.working .uploader-fill { animation: none; background: var(--accent); }
}

/* ================= mobile ================= */
@media (max-width: 760px) {
  .view { padding-top: 4.4rem; padding-left: .5rem; padding-right: .5rem; }
  .site-header { padding: 1.1rem 1.2rem; background: var(--overlay); backdrop-filter: blur(8px); }
  .site-nav { gap: 1rem; }
  .about { grid-template-columns: 1fr; }
  .about-photo { max-width: 340px; }
  .admin { grid-template-columns: 1fr; }
  .admin-side { position: static; }
  .lb-caption { max-width: 78vw; bottom: 2.6rem; }
  .lb-prev, .lb-next { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
