/* ===========================================================
   Contact Sheet — a darkroom-inspired photo library
   Palette: near-black room, warm safelight accent, paper text
   =========================================================== */

:root {
  --bg: #121110;
  --bg-panel: #1a1815;
  --bg-panel-raised: #201d19;
  --line: #322e28;
  --line-soft: #262320;
  --text: #efe8db;
  --text-muted: #9a9184;
  --text-faint: #625b50;
  --accent: #c1440e;
  --accent-bright: #e0621f;
  --accent-soft: rgba(193, 68, 14, 0.16);
  --danger: #9c3b3b;
  --danger-bright: #c24d4d;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 3px;
  --edge: 1px solid var(--line);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, #1c1815 0%, var(--bg) 45%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Decorative sprocket rail across the very top of the page */
.sprocket-rail {
  height: 10px;
  width: 100%;
  background-image: repeating-linear-gradient(
    90deg,
    var(--bg-panel-raised) 0 6px,
    transparent 6px 20px
  );
  background-color: #0d0c0b;
  border-bottom: var(--edge);
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
  border-bottom: var(--edge);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-mark {
  color: var(--accent);
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 0.92rem;
  font-weight: 500;
}

.site-nav a {
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav .cta {
  color: var(--bg);
  background: var(--accent);
  padding: 9px 16px;
  border-radius: var(--radius);
  transition: background 0.15s ease;
}

.site-nav .cta:hover {
  background: var(--accent-bright);
  color: var(--bg);
}

.logout-form {
  display: inline-flex;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}

.link-btn:hover {
  color: var(--text);
}

/* ---------------- Layout ---------------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 56px) 100px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin: 0 0 14px;
}

.back-link {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.back-link:hover {
  color: var(--accent-bright);
}

.hero {
  padding-bottom: 40px;
  margin-bottom: 12px;
  border-bottom: var(--edge);
}

.hero--compact {
  padding-bottom: 28px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
  margin: 0 0 16px;
  max-width: 16ch;
}

.hero-sub {
  color: var(--text-muted);
  max-width: 56ch;
  font-size: 1.02rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: var(--edge);
  background: var(--bg-panel-raised);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--bg-panel);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #17110c;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger-bright);
}

.btn--danger:hover {
  background: rgba(156, 59, 59, 0.12);
  border-color: var(--danger-bright);
}

.inline-form {
  display: inline-flex;
}

/* ---------------- Messages ---------------- */

.messages {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 1180px;
  padding: 0 clamp(20px, 5vw, 56px);
}

.message {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: var(--edge);
  background: var(--bg-panel);
  font-size: 0.9rem;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
}

.message--error {
  border-left-color: var(--danger-bright);
}

/* ---------------- Contact sheet grid ---------------- */

.sheet-section {
  margin-top: 44px;
}

.sheet-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: var(--edge);
  padding-bottom: 12px;
  margin-bottom: 22px;
}

.sheet-heading h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.4rem;
  margin: 0;
}

.count-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}

.frame {
  position: relative;
  display: block;
  background: var(--bg-panel);
  border: var(--edge);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.frame:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.frame-number {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text);
  background: rgba(10, 9, 8, 0.65);
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.03em;
}

.frame-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  color: #17110c;
  background: var(--accent-bright);
  padding: 2px 7px;
  border-radius: 2px;
}

.frame-image {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #0d0c0b;
  overflow: hidden;
}

.frame-image img,
.frame-image video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.frame:hover .frame-image img,
.frame:hover .frame-image video {
  transform: scale(1.045);
}

.frame-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* Stacked-print effect behind album covers */
.frame-stack {
  position: absolute;
  inset: 6px 6px auto auto;
  width: 0;
}

.frame--album .frame-image::after,
.frame--album .frame-image::before {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  left: 6px;
  top: 6px;
  border: 1px solid rgba(239, 232, 219, 0.14);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
}

.frame-caption {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.frame-caption strong {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 30px 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty-state a {
  color: var(--accent-bright);
  font-weight: 500;
}

/* ---------------- Forms ---------------- */

.form-section {
  max-width: 560px;
}

.form-section h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2rem;
  margin: 0 0 12px;
}

.stack-form {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="file"],
.field textarea,
.field select {
  background: var(--bg-panel);
  border: var(--edge);
  border-radius: var(--radius);
  color: var(--text);
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.field-help {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin: 0;
}

.field-error {
  font-size: 0.82rem;
  color: var(--danger-bright);
  margin: 0;
}

.field--error input,
.field--error textarea,
.field--error select {
  border-color: var(--danger-bright);
}

/* ---------------- Light table / carousel ---------------- */

.light-table {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.light-table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.light-table-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.frame-counter {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.viewer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0908;
  border: var(--edge);
  border-radius: 4px;
  padding: clamp(10px, 2vw, 26px);
  min-height: min(64vh, 620px);
}

.viewer-frame {
  max-width: 100%;
  max-height: min(60vh, 600px);
  display: flex;
  transition: opacity 0.12s ease;
}

.viewer-frame.is-fading {
  opacity: 0;
}

.viewer-frame img,
.viewer-frame video {
  max-width: 100%;
  max-height: min(60vh, 600px);
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: var(--edge);
  background: rgba(18, 17, 16, 0.75);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
  z-index: 3;
}

.viewer-nav:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.viewer-nav--prev {
  left: clamp(6px, 2vw, 20px);
}

.viewer-nav--next {
  right: clamp(6px, 2vw, 20px);
}

.viewer-caption {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.viewer-caption strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
}

.viewer-caption p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Filmstrip */

.filmstrip-wrap {
  background: #0d0c0b;
  border: var(--edge);
  border-radius: 4px;
  overflow: hidden;
}

.filmstrip-sprockets {
  height: 10px;
  background-image: repeating-linear-gradient(
    90deg,
    #1c1a17 0 6px,
    transparent 6px 20px
  );
}

.filmstrip {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.filmstrip-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  height: 66px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  background: #060605;
  opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.filmstrip-thumb img,
.filmstrip-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #efe8db;
  font-size: 0.8rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.filmstrip-thumb:hover {
  opacity: 0.85;
}

.filmstrip-thumb.is-active {
  opacity: 1;
  border-color: var(--accent);
}

.delete-current {
  align-self: flex-start;
}

/* ---------------- Footer ---------------- */

.site-footer {
  text-align: center;
  padding: 30px 0 40px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
  }

  .viewer-nav {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }

  .contact-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
