/*
 * Släktens foton — stil
 * Varm, gammaldags känsla som passar släktens historiska foton.
 */

:root {
  --bg: #f3efe6;
  --paper: #faf8f3;
  --ink: #2b2520;
  --muted: #6e6357;
  --accent: #8b5a2b;
  --accent-hover: #6d4520;
  --border: #d6cfc3;
  --shadow: rgba(43, 37, 32, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.site-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

main {
  padding: 2rem 0 4rem;
}

.loading,
.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem;
  font-size: 1.1rem;
}

.upload-panel,
.export-panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 1.5rem;
  padding: 1rem;
}

.export-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, auto);
  align-items: end;
  gap: 1rem;
}

.export-panel__copy h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  line-height: 1.2;
  margin: 0 0 0.2rem;
}

.export-panel__copy p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

.export-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) auto;
  gap: 1rem;
  align-items: end;
}

.export-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(220px, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.upload-form__header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  line-height: 1.2;
  margin: 0 0 0.2rem;
}

.upload-form__header p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

.upload-form label span,
.export-form label span {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.upload-form input,
.export-form input {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.upload-form input:focus,
.export-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.upload-form input[type="file"] {
  padding: 0.45rem 0.7rem;
}

.upload-status {
  min-height: 1.4rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.export-status {
  grid-column: 1 / -1;
  min-height: 1.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-status--success,
.export-status--success {
  color: #286140;
}

.upload-status--error,
.export-status--error {
  color: #9b2c2c;
}

/* Galleri */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.gallery__item {
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gallery__item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px var(--shadow);
}

.gallery__item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #e9e3d8;
  transition: transform 0.3s ease;
}

.gallery__caption {
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 17, 13, 0.95);
  display: flex;
  align-items: stretch;
  padding: 0;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__close {
  position: absolute;
  z-index: 10;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox__close {
  top: 1rem;
  right: 1rem;
}

.lightbox__content {
  display: flex;
  width: 100%;
  height: 100%;
}

.lightbox__image-wrap {
  flex: 1 1 65%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 6rem;
  overflow: hidden;
}

.lightbox__image-wrap.zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  cursor: grab;
  overscroll-behavior: contain;
  touch-action: none;
  user-select: none;
}

.lightbox__image-wrap.zoomed.panning {
  cursor: grabbing;
}

.lightbox__image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox__image-wrap img.zoomed {
  cursor: grab;
  max-width: none;
  max-height: none;
}

.lightbox__image-wrap.panning img.zoomed {
  cursor: grabbing;
}

.lightbox__side-nav {
  position: absolute;
  top: 50%;
  z-index: 6;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  transform: translateY(-50%);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.lightbox__side-nav:hover,
.lightbox__side-nav:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.32);
  outline: none;
  transform: translateY(-50%) scale(1.04);
}

.lightbox__side-nav--prev {
  left: clamp(1.5rem, 4vw, 4rem);
}

.lightbox__side-nav--next {
  right: clamp(1.5rem, 4vw, 4rem);
}

.lightbox__panel {
  flex: 0 0 420px;
  max-width: 100%;
  background: var(--paper);
  color: var(--ink);
  padding: 1.75rem 2rem;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}

.panel__header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0;
  flex: 1;
  border-bottom: 1px dashed transparent;
  padding-bottom: 0.25rem;
}

.panel__title:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-style: italic;
}

.panel__title:hover,
.panel__title:focus {
  border-bottom-color: var(--border);
  outline: none;
}

.panel__meta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.panel__actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.panel__meta label span,
.comment-form label span {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.panel__meta input,
.panel__meta textarea,
.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.panel__meta input:focus,
.panel__meta textarea:focus,
.comment-form input:focus,
.comment-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

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

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  flex-shrink: 0;
}

.btn--secondary:hover {
  background: var(--accent);
  color: #fff;
}

.btn--danger {
  background: transparent;
  color: #9b2c2c;
  border: 1px solid #b86a6a;
}

.btn--danger:hover {
  background: #9b2c2c;
  color: #fff;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.panel__comments h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.comment {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.comment__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.comment__author {
  font-weight: 600;
  color: var(--accent);
}

.comment__text {
  margin: 0;
  white-space: pre-wrap;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.site-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

/* Mobilanpassning */
@media (max-width: 900px) {
  .upload-form {
    grid-template-columns: 1fr;
  }

  .export-panel,
  .export-form {
    grid-template-columns: 1fr;
  }

  .export-panel__actions {
    justify-content: stretch;
  }

  .export-panel__actions .btn {
    width: 100%;
  }

  .lightbox__content {
    flex-direction: column;
  }

  .lightbox__image-wrap {
    flex: 0 0 45vh;
    padding: 3rem 4.5rem 1rem;
  }

  .lightbox__side-nav {
    width: 48px;
    height: 48px;
    font-size: 1.55rem;
  }

  .lightbox__side-nav--prev {
    left: 0.8rem;
  }

  .lightbox__side-nav--next {
    right: 0.8rem;
  }

  .lightbox__panel {
    flex: 1 1 auto;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 1.25rem;
  }

  .panel__actions {
    grid-template-columns: 1fr;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }
}
