:root {
  --ink: #f2efe6;
  --paper: #000000;
  --paper-alt: #161513;
  --line: #333029;
  --accent: #c9743f;
  --accent-dark: #e29466;
  --muted: #a49c8c;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

input, textarea, select {
  font-family: inherit;
  background: var(--paper-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

body {
  margin: 0;
  font-family: "Times New Roman", Times, "Iowan Old Style", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--accent-dark); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Header */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
}
.site-nav a {
  margin-left: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--accent); }

.site-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 0 3rem;
}

/* About */
.about h1 {
  font-size: 2.4rem;
  margin: 0 0 0.75rem;
}
.about-text {
  max-width: 640px;
  color: #3a382f;
  white-space: pre-wrap;
}
.about-form textarea {
  width: 100%;
  max-width: 640px;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-alt);
  color: var(--ink);
}

/* Buttons */
.btn, button {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.5rem 0.95rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover, button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger-outline {
  background: transparent;
  color: #a33;
  border-color: #c99;
}
.btn-danger-outline:hover { background: #a33; color: white; border-color: #a33; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  text-decoration: underline;
  padding: 0;
  font-size: 0.9rem;
  cursor: pointer;
}
.link-btn:hover { background: none; color: var(--accent); }

.form-actions { display: flex; gap: 0.6rem; margin-top: 0.6rem; }

/* Sections */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 1rem;
  flex-wrap: wrap;
}
.section-header h1, .section-header h2 { margin: 0; }

/* New category form */
.new-category-form, .upload-form, .journal-form {
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 520px;
}
.new-category-form input, .upload-form input, .upload-form textarea,
.journal-form input, .journal-form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
}
.journal-form { max-width: 100%; }
.journal-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }

/* Breakout: stretch an element edge-to-edge across the full viewport width,
   ignoring the centered .site-main container's max-width/padding. */
.breakout {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

/* Homepage welcome photo */
.hero {
  position: relative;
  margin-bottom: 2.5rem;
  background: var(--paper-alt);
}
.hero-img {
  display: block;
  width: 100%;
  height: clamp(280px, 48vh, 620px);
  object-fit: cover;
}
.hero-empty {
  height: clamp(200px, 32vh, 380px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
  border-bottom: 1px dashed var(--line);
}
.hero-controls {
  position: absolute;
  right: 1.5rem;
  bottom: 1.25rem;
  display: flex;
  gap: 0.6rem;
  z-index: 2;
}
.hero-controls .btn {
  background: rgba(15, 13, 10, 0.55);
  color: var(--paper);
  border-color: rgba(255,255,255,0.5);
  backdrop-filter: blur(2px);
}
.hero-empty-state .hero-controls {
  position: static;
  justify-content: center;
  margin-top: 0.75rem;
}
.hero-upload-form {
  max-width: 420px;
  margin: 0.75rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 1rem;
}

/* Collage grid inside a gallery: a masonry-style layout (like a photo
   collage/scrapbook — mixed rectangle sizes fitting together, each photo
   keeping its own proportions) via CSS columns. Click one to open the
   full-screen scrollable viewer below. */
.photo-collage {
  column-count: 3;
  column-gap: 3px;
  background: #000;
}
@media (min-width: 641px) {
  .photo-collage { column-count: 5; column-gap: 4px; }
}
@media (min-width: 1000px) {
  .photo-collage { column-count: 7; }
}
.photo-collage .photo-thumb {
  display: block;
  width: 100%;
  margin: 0 0 3px;
  padding: 0;
  border: 1px solid #fff;
  box-sizing: border-box;
  border-radius: 0;
  background: #000;
  break-inside: avoid;
  cursor: zoom-in;
}
.photo-collage .photo-thumb img {
  display: block;
  width: 100%;
  height: auto;
}
.photo-collage .photo-thumb:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Gallery grid on homepage */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}
.gallery-card {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-alt);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gallery-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(255,255,255,0.06); }
.gallery-card-cover {
  aspect-ratio: 4 / 3;
  background: var(--paper-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card-empty { color: var(--muted); font-size: 0.85rem; }
.gallery-card-info { padding: 0.7rem 0.9rem; display: flex; justify-content: space-between; align-items: baseline; }
.gallery-card-info h3 { margin: 0; font-size: 1.05rem; }
.gallery-card-info span { font-size: 0.8rem; color: var(--muted); }

/* Gallery detail page */
.back-link { display: inline-block; margin-bottom: 1rem; text-decoration: none; font-size: 0.9rem; }
.gallery-header h1 { margin-bottom: 0.25rem; }
.gallery-actions { display: flex; gap: 0.6rem; margin: 0.9rem 0 1.5rem; }

.empty-state { color: var(--muted); font-style: italic; }

/* Lightbox: click a thumb, then move through the whole gallery full-screen */
.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
}
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 52;
  font-size: 1.6rem;
  line-height: 1;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
}
.lightbox-counter {
  position: fixed;
  top: 1.15rem;
  left: 1.25rem;
  z-index: 52;
  color: rgba(250,248,244,0.85);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 52;
  font-size: 1.8rem;
  line-height: 1;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
  color: var(--paper);
  cursor: pointer;
}
.lightbox-nav:disabled { opacity: 0.25; cursor: default; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-scroll {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}
.lightbox-item {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3.5rem 4.5rem 1.5rem;
}
.lightbox-item img {
  max-width: min(92vw, 1100px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 2px;
  border: 6px solid #fff;
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .lightbox-nav { display: none; }
  .lightbox-item { padding: 3rem 1rem 1.25rem; }
}
.lightbox-meta {
  width: min(92vw, 700px);
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.lightbox-title, .lightbox-description {
  font-family: inherit;
  background: transparent;
  color: var(--paper);
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  border-radius: 0;
  padding: 0.25rem 0.1rem;
  width: 100%;
  font-size: 0.88rem;
}
.lightbox-title { font-weight: 600; }
.lightbox-description { resize: vertical; min-height: 2.4em; }
.lightbox-title:focus, .lightbox-description:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.lightbox-title::placeholder, .lightbox-description::placeholder { color: rgba(250,248,244,0.45); }
.lightbox-actions { display: flex; align-items: center; gap: 0.6rem; }
.save-status { font-size: 0.82rem; color: #c8e6c9; }

/* Journal */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.post-list a { text-decoration: none; font-weight: 600; }
.post-date { color: var(--muted); font-size: 0.82rem; margin-left: 0.6rem; }
.post-list-full li { padding: 1rem 0; }
.post-excerpt { margin: 0.35rem 0 0; color: #4a473d; }
.post-title { font-size: 1.15rem; }

.journal-post h1 { margin-bottom: 0.2rem; }
.journal-body p { margin: 0 0 1rem; white-space: pre-wrap; }
.journal-post-actions { display: flex; gap: 0.6rem; margin-top: 2rem; }

/* Shop */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.shop-card {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-alt);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.shop-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(255,255,255,0.06); }
.shop-card-image { position: relative; aspect-ratio: 1 / 1; background: var(--paper-alt); overflow: hidden; }
.shop-card-image img { width: 100%; height: 100%; object-fit: cover; }
.shop-card-info { padding: 0.7rem 0.9rem; display: flex; justify-content: space-between; align-items: baseline; }
.shop-card-info h3 { margin: 0; font-size: 1.02rem; }
.shop-card-info span { font-weight: 600; }

.badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(28,28,26,0.82);
  color: var(--paper);
  letter-spacing: 0.02em;
}
.badge-print { background: rgba(122,62,31,0.85); }
.badge-sold { left: auto; right: 0.5rem; background: #a33; }

.shop-item { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: start; }
.shop-item-image img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.shop-item-info .badge { position: static; display: inline-block; margin-bottom: 0.6rem; }
.shop-item-info h1 { margin: 0 0 0.3rem; }
.shop-price { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.75rem; }
.shop-description { color: var(--ink); margin-bottom: 1rem; white-space: pre-wrap; }
.btn-buy { background: var(--accent); border-color: var(--accent); font-size: 1rem; padding: 0.7rem 1.2rem; }
.btn-buy:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.small { font-size: 0.82rem; }
.admin-controls { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); display: flex; gap: 1rem; }
.danger-link { color: #a33; }
.shop-notice {
  background: rgba(230, 180, 90, 0.1);
  border: 1px solid rgba(230, 180, 90, 0.4);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}
.shop-notice code { background: rgba(255,255,255,0.1); padding: 0.1rem 0.3rem; border-radius: 3px; }
.print-only-field { color: var(--muted); }

.shop-message { text-align: center; padding: 3rem 1rem; }
.shop-message h1 { margin-bottom: 0.5rem; }

.orders-table-wrap { overflow-x: auto; }
.orders-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.orders-table th, .orders-table td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.orders-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.address-cell { max-width: 220px; }
.order-status { padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }
.order-status-paid { background: rgba(230, 180, 90, 0.25); color: var(--ink); }
.order-status-fulfilled { background: rgba(120, 200, 140, 0.25); color: var(--ink); }

@media (max-width: 700px) {
  .shop-item { grid-template-columns: 1fr; }
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-form {
  max-width: 320px;
  width: 100%;
}
.login-form h1 { margin: 0 0 0.5rem; font-size: 1.6rem; text-align: center; }
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.login-form button { width: 100%; }
.login-error { color: #a33; font-size: 0.88rem; margin: 0; }

.logout-form { display: inline; margin-left: 1.25rem; }
.logout-form button {
  background: none;
  border: none;
  color: var(--ink);
  padding: 0;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.logout-form button:hover { color: var(--accent-dark); }

@media (max-width: 600px) {
  .site-header { padding: 1rem 1.1rem; }
  .site-main { padding: 1.5rem 1rem 3rem; }
}
