:root {
  --bg: #faf7f2;
  --bg-deep: #f2ece2;
  --ink: #2c2620;
  --ink-soft: #6b6256;
  --line: #e3dccf;
  --accent: #a67c52;
  --accent-deep: #8a6440;
  --white: #fffdf9;
  --gap: 8px;
  --shadow: 0 18px 50px -22px rgba(60, 45, 30, 0.35);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* The [hidden] attribute must win over display rules like `.gate { display:grid }`. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 0.6rem;
  font-weight: 500;
}

.script {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 1;
  margin: 0;
}

/* ---------- Login gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg) 0%, var(--bg-deep) 100%);
  z-index: 50;
}
.gate-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.gate-card .script {
  font-size: clamp(3.2rem, 12vw, 5rem);
  margin-bottom: 0.5rem;
}
.gate-sub {
  color: var(--ink-soft);
  margin: 0 0 1.8rem;
  font-size: 1rem;
}
#login-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
#login-form input {
  flex: 1 1 200px;
  min-width: 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 1rem;
  font-family: var(--sans);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(166, 124, 82, 0.15);
}
button,
.linkbtn {
  cursor: pointer;
  font-family: var(--sans);
}
#login-form button {
  padding: 0.85rem 1.8rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.1s;
}
#login-form button:hover {
  background: var(--accent-deep);
}
#login-form button:active {
  transform: scale(0.98);
}
.error {
  color: #b1442e;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ---------- Masthead ---------- */
.masthead {
  text-align: center;
  padding: clamp(3rem, 8vw, 6rem) 20px clamp(1.5rem, 4vw, 3rem);
  position: relative;
}
.masthead .script {
  font-size: clamp(3rem, 11vw, 6.5rem);
}
.masthead-sub {
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  margin: 0.8rem 0 0;
  font-size: 0.95rem;
}
.topnav {
  position: absolute;
  top: 20px;
  right: 22px;
  display: flex;
  gap: 18px;
  align-items: center;
}
.topnav a,
.linkbtn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.2s;
}
.topnav a:hover,
.linkbtn:hover {
  color: var(--accent-deep);
}

/* ---------- Justified grid ---------- */
.grid {
  padding: 0 clamp(8px, 2vw, 22px) 40px;
  max-width: 1680px;
  margin: 0 auto;
}
.row {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.cell {
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
  border-radius: 3px;
  cursor: zoom-in;
  flex: 0 0 auto; /* never shrink/grow — width is computed exactly */
}
.cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.5s ease;
}
.cell img.loaded {
  opacity: 1;
}
.cell:hover img {
  transform: scale(1.04);
}
.cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.28), transparent 42%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.cell:hover::after {
  opacity: 1;
}

/* Admin delete button on each cell */
.cell .del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 15, 10, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 2;
  transition: background 0.15s, transform 0.1s;
}
.cell .del:hover {
  background: #c0392b;
}
.cell .del:active {
  transform: scale(0.9);
}
body.is-admin .cell:hover .del {
  display: flex;
}

/* ---------- misc ---------- */
.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 6rem 20px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-style: italic;
}
.foot {
  text-align: center;
  padding: 2rem 20px 4rem;
  border-top: 1px solid var(--line);
  margin-top: 2rem;
}
.script-sm {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.8rem;
  color: var(--accent);
}

.skeleton {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  padding: 5rem 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* PhotoSwipe caption + download tweaks */
.pswp__custom-caption {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  padding: 0 20px;
}
.pswp__button--download {
  background: none;
}
