/* ================= 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;
  --mat: clamp(10px, 1.2vw, 18px);
  --keyline: #7f1734;
}
: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(251,250,248,.98);
  --lb-fg: #1a1816;
  --mat-bg: #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;
  --mat-bg: #fbfaf7;
}
: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;
  --mat-bg: #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;
  --mat-bg: #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;
  --mat-bg: #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(5.5rem, 12vh, 8rem) clamp(1.2rem, 4vw, 3rem) 4rem;
  max-width: 1760px; margin: 0 auto;
  animation: viewIn .55s cubic-bezier(.25,.6,.2,1) both;
}
.view.leaving { animation: viewOut .22s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes viewOut { to { opacity: 0; transform: translateY(-8px); } }

/* ================= home : cover tiles (natural aspect, never cropped) ================= */
/* column count adapts to the viewport: ~1 per 360px of width */
.tiles { columns: 360px; column-gap: 2.2rem; }
.tile {
  display: block; break-inside: avoid; margin-bottom: 2.6rem;
  opacity: 0; transform: translateY(18px);
}
.tile.reveal { animation: photoIn .9s cubic-bezier(.2,.65,.2,1) forwards; }
.tile-img { display: block; overflow: hidden; }
.tile img {
  width: 100%; height: auto; display: block;
  transform: scale(1.001); transition: transform 1.4s cubic-bezier(.2,.6,.2,1);
}
.tile:hover img { transform: scale(1.03); }
.tile-cap {
  display: flex; align-items: baseline; gap: .75rem;
  margin-top: .85rem; padding: 0 2px;
}
.tile-cap .idx { font-size: .62rem; letter-spacing: .2em; color: var(--accent); }
.tile-cap .name {
  font-family: var(--serif); font-size: 1.4rem; font-weight: 400;
  letter-spacing: .02em; line-height: 1.15; position: relative;
  transition: color .35s;
}
.tile:hover .tile-cap .name { color: var(--accent); }
.tile-cap .count { font-size: .66rem; letter-spacing: .18em; color: var(--muted); margin-left: auto; }

/* ================= gallery ================= */
.gallery-head { margin-bottom: 2.4rem; }
.gallery-head .back {
  font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
  display: inline-block; margin-bottom: 1rem; transition: color .3s;
}
.gallery-head .back:hover { color: var(--fg); }
.gallery-head h1 { font-family: var(--serif); font-size: clamp(2.4rem, 5.5vw, 4rem); font-weight: 400; letter-spacing: .01em; line-height: 1.05; }
.gallery-head .sub { color: var(--muted); font-size: .8rem; letter-spacing: .1em; margin-top: .4rem; }

.masonry { columns: 3 340px; column-gap: 1.9rem; }
.masonry figure {
  break-inside: avoid; margin: 0 0 1.9rem; position: relative; overflow: hidden;
  background: var(--card); cursor: zoom-in;
  opacity: 0; transform: translateY(18px);
}
.masonry figure.reveal { animation: photoIn .8s cubic-bezier(.2,.65,.2,1) forwards; }
@keyframes photoIn { to { opacity: 1; transform: none; } }
.masonry img { width: 100%; height: auto; transition: transform .8s cubic-bezier(.2,.6,.2,1); }
.masonry figure:hover img { transform: scale(1.02); }
/* descriptions live in the lightbox; grids stay clean */
.masonry figcaption { display: none; }
.work-divider {
  column-span: all; margin: 3.4rem 0 1.6rem; display: flex; align-items: baseline; gap: 1rem;
}
.work-divider:first-child { margin-top: 0; }
.work-divider .idx { font-size: .7rem; letter-spacing: .2em; color: var(--accent); }
.work-divider .wname { font-family: var(--serif); font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 400; }
.work-divider a { transition: color .3s; }
.work-divider a:hover { color: var(--accent); }
.work-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; }

/* ============ on-the-fly frame: quiet mat, one bordeaux plate line ============
   The line sits between the photo and the mat edge, like the plate mark on a
   fine-art print. No borders, no shadows — a single rule. */
[data-frames="on"] .masonry figure,
[data-frames="on"] .tile-img,
[data-frames="on"] .about-photo:not(.placeholder) {
  background: var(--mat-bg);
  padding: var(--mat);
}
[data-frames="on"] .masonry figure img,
[data-frames="on"] .tile-img img,
[data-frames="on"] .about-photo:not(.placeholder) img {
  outline: 1px solid var(--keyline);
  outline-offset: calc(var(--mat) * .42);
}
/* zooming inside a mat would spill over the plate line: stay still */
[data-frames="on"] .masonry figure:hover img,
[data-frames="on"] .tile:hover img { transform: none; }

/* ================= 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;
}
[data-frames="on"] .lb-frame {
  background: var(--mat-bg); padding: var(--mat);
}
[data-frames="on"] .lb-stage img {
  outline: 1px solid var(--keyline);
  outline-offset: calc(var(--mat) * .42);
  max-width: calc(92vw - 3 * var(--mat)); max-height: calc(88vh - 3 * var(--mat));
}
.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; }

.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); } }

/* ================= mobile ================= */
@media (max-width: 760px) {
  .view { padding-top: 5rem; padding-left: .9rem; padding-right: .9rem; }
  .site-header { padding: 1.1rem 1.2rem; background: var(--overlay); backdrop-filter: blur(8px); }
  .site-nav { gap: 1rem; }
  .tiles { columns: 1; }
  .tile { margin-bottom: 1.8rem; }
  .masonry { columns: 1; }
  .masonry figure { margin-bottom: 1.2rem; }
  .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; }
}
