@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;800&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=Space+Mono:wght@400;700&display=swap');

:root {
  --ocean-deep: #0a1826;
  --ocean-mid: #12283c;
  --ocean-line: #23405a;
  --buff: #c98a3b;
  --buff-bright: #e0a355;
  --ivory: #ece3d0;
  --ivory-dim: #d9cdb4;
  --brass: #a3813f;
  --pennant: #7c3232;
  --ink: #201a10;
  --fog: #b9c6cf;

  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ocean-deep);
  background-image:
    radial-gradient(ellipse at top, rgba(35, 64, 90, 0.55), transparent 60%);
  color: var(--fog);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: inherit; }

::selection { background: var(--buff); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--buff-bright);
  outline-offset: 3px;
}

/* ---------- Header / Hero ---------- */

.hero {
  border-bottom: 1px solid var(--ocean-line);
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  position: relative;
}

.hero::before,
.hero::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass) 20%, var(--brass) 80%, transparent);
}
.hero::before { top: 10px; }
.hero::after { bottom: 10px; }

.hero-eyebrow {
  font-family: var(--font-mono);
  letter-spacing: 0.35em;
  font-size: 0.7rem;
  color: var(--buff-bright);
  text-transform: uppercase;
  margin: 0 0 0.75rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: clamp(2.75rem, 8vw, 5.5rem);
  margin: 0;
  color: var(--ivory);
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fog);
  margin-top: 0.75rem;
  letter-spacing: 0.05em;
}

.hero-nav {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-nav a {
  color: var(--fog);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
.hero-nav a:hover { color: var(--buff-bright); border-color: var(--buff-bright); }

/* ---------- Search ---------- */

.search-bar {
  max-width: 640px;
  margin: 2rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.search-bar input {
  flex: 1;
  background: var(--ocean-mid);
  border: 1px solid var(--ocean-line);
  border-radius: 3px;
  padding: 0.7rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ivory);
}
.search-bar input::placeholder { color: #6d7f8c; }

.count-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--buff-bright);
  align-self: center;
  white-space: nowrap;
}

/* ---------- Gallery grid ---------- */

.gallery {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  font-family: var(--font-mono);
  color: var(--fog);
}

/* ---------- Book card (ticket-stub) ---------- */

.book-card {
  background: var(--ivory);
  color: var(--ink);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  cursor: pointer;
  position: relative;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  border: 1px solid var(--ivory-dim);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.book-card:hover, .book-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}

/* perforated stub divider between porthole and details */
.book-card::after {
  content: '';
  position: absolute;
  left: 92px;
  top: 6px;
  bottom: 6px;
  width: 0;
  border-left: 2px dashed var(--ivory-dim);
}

.porthole {
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  position: relative;
  padding: 6px;
  background: radial-gradient(circle at 35% 30%, #d9be86, var(--brass) 70%, #5c4726 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.25);
}

.porthole-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ocean-mid) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><rect width="60" height="60" fill="%2312283c"/></svg>') center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
}
.porthole-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.porthole-inner .no-photo { font-family: var(--font-mono); font-size: 0.6rem; color: #5f7180; }

.rivet {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #3c2e14;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.rivet.r1 { top: 2px; left: 50%; transform: translateX(-50%); }
.rivet.r2 { bottom: 2px; left: 50%; transform: translateX(-50%); }
.rivet.r3 { left: 2px; top: 50%; transform: translateY(-50%); }
.rivet.r4 { right: 2px; top: 50%; transform: translateY(-50%); }

.book-meta { flex: 1; min-width: 0; padding-left: 0.5rem; }

.book-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.15;
  margin: 0 0 0.15rem;
  color: var(--ink);
}

.book-author {
  font-size: 0.9rem;
  font-style: italic;
  color: #4a4030;
  margin: 0 0 0.4rem;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-tags span {
  background: rgba(124, 50, 50, 0.08);
  border: 1px solid rgba(124, 50, 50, 0.3);
  color: var(--pennant);
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 12, 18, 0.82);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  background: var(--ivory);
  color: var(--ink);
  max-width: 780px;
  width: 100%;
  border-radius: 6px;
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0 0 0.25rem;
}

.modal .modal-author {
  font-style: italic;
  color: #4a4030;
  margin: 0 0 1rem;
}

.modal-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border-top: 1px dashed var(--ivory-dim);
  border-bottom: 1px dashed var(--ivory-dim);
  padding: 1rem 0;
  margin-bottom: 1.25rem;
}
.modal-facts dt { color: var(--pennant); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.15rem; }
.modal-facts dd { margin: 0; }

.modal-notes { line-height: 1.6; margin-bottom: 1.5rem; }

.filmstrip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.filmstrip img {
  height: 140px;
  border-radius: 3px;
  border: 1px solid var(--ivory-dim);
  flex: none;
}

/* ---------- Forms (admin) ---------- */

.panel {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem 4rem;
}

.card {
  background: var(--ocean-mid);
  border: 1px solid var(--ocean-line);
  border-radius: 5px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h3 {
  font-family: var(--font-display);
  color: var(--ivory);
  margin-top: 0;
  letter-spacing: 0.02em;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--buff-bright);
  margin-bottom: 0.3rem;
}

input, textarea, select {
  width: 100%;
  background: var(--ocean-deep);
  border: 1px solid var(--ocean-line);
  border-radius: 3px;
  color: var(--ivory);
  padding: 0.55rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
}

textarea { resize: vertical; min-height: 70px; }

.field { margin-bottom: 1rem; }

.btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: none;
  border-radius: 3px;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  background: var(--buff);
  color: #1c1408;
  font-weight: 700;
}
.btn:hover { background: var(--buff-bright); }
.btn.secondary { background: transparent; border: 1px solid var(--ocean-line); color: var(--fog); }
.btn.danger { background: var(--pennant); color: var(--ivory); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row-actions { display: flex; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }

.admin-book-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  border-bottom: 1px solid var(--ocean-line);
  padding: 0.9rem 0;
}
.admin-book-row:last-child { border-bottom: none; }
.admin-book-row .porthole { width: 54px; height: 54px; }
.admin-book-row .book-title { color: var(--ivory); font-size: 1rem; }
.admin-book-row .book-author { color: var(--fog); }

.photo-strip {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.photo-thumb {
  position: relative;
  width: 84px; height: 84px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--ocean-line);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,0.7);
  color: var(--ivory);
  border: none;
  border-radius: 2px;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 1px 4px;
}

.login-wrap {
  max-width: 380px;
  margin: 6rem auto;
  padding: 0 1.5rem;
}

.status-msg {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  margin-bottom: 1rem;
}
.status-msg.error { background: rgba(124,50,50,0.2); border: 1px solid var(--pennant); color: #f0c9c9; }
.status-msg.success { background: rgba(76,110,60,0.2); border: 1px solid #4c6e3c; color: #cfe7c2; }

footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #5a6d78;
  padding: 2rem 1rem 3rem;
  letter-spacing: 0.04em;
}

@media (max-width: 480px) {
  .book-card { flex-direction: row; }
  .hero { padding: 2.25rem 1rem 1.5rem; }
}
