/* Tiny Reflections — dark minimal theme */

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --fg: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --accent: #1c1c1c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { margin: 0 auto; padding: 24px 4px 64px; }
.narrow { max-width: 520px; margin: 0 auto; }
.narrow.wide { max-width: 900px; }
.center { text-align: center; padding: 80px 0; }
.muted { color: var(--muted); font-size: 0.9em; }

.site-header {
  padding: 28px 20px 12px;
  text-align: center;
}
.brand {
  font-size: 1.4em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.tagline {
  margin: -10px 0 0;
  font-size: 0.85em;
  font-style: italic;
  color: #555;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85em;
  text-align: center;
  padding: 20px;
}

/* ---- tag bar ---- */
.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 28px;
}

.chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.8em;
  color: var(--muted);
  letter-spacing: 0.03em;
}
a.chip:hover { color: var(--fg); border-color: var(--fg); text-decoration: none; }
.chip.active { color: var(--fg); border-color: var(--fg); }
.chip .count { opacity: 0.6; font-size: 0.9em; }

/* ---- masonry grid: the inline script (render.php) distributes cards into
   .grid-col flex columns in round-robin order, so consecutive photos
   fill each row left-to-right, then wrap top-to-bottom ---- */
.grid {
  display: flex;
  align-items: flex-start;
  gap: var(--grid-gap);
  --grid-min: 300px;
  --grid-gap: 4px;
}
.grid-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--grid-gap); }
.thumb { display: block; overflow: hidden; background: var(--bg-card); position: relative; }
.thumb img {
  width: 100%;
  height: auto;
  display: block;
}
/* light overlay over the whole image, with title + tags (old-site look) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.card:hover .overlay,
.card:focus-within .overlay { opacity: 1; }
.ov-title {
  font-size: 1.25em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  line-height: 1.3;
}
.ov-tags { font-size: 0.9em; color: var(--muted); }
.card-link { display: block; }
.ov-tag { color: inherit; }
.ov-tag:hover { color: var(--fg); text-decoration: underline; }
/* The overlay lets clicks through to the photo link; only the tags catch
   them, and only where hover exists (on touch the overlay is invisible). */
@media (hover: hover) {
  .card:hover .ov-tag { pointer-events: auto; }
}
.card { display: block; color: inherit; }
.card:hover { text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips-lg { margin: 10px 0 18px; }
.chips-lg .chip { font-size: 0.9em; }

/* ---- photo page ---- */
.pn {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.95em;
}
.pn-link { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo { margin: 0 auto; text-align: center; }
.photo img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}
.photo-title {
  text-align: center;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 22px 0 0;
}
.desc {
  max-width: 720px;
  margin: 14px auto 0;
  color: var(--fg);
  opacity: 0.88;
}

.exif {
  max-width: 720px;
  margin: 26px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 24px;
  font-size: 0.9em;
}
.exif dt { color: var(--muted); }
.exif dd { margin: 0; }

/* ---- forms / upload ---- */
h1 { font-weight: 400; letter-spacing: 0.04em; }

.login-form, .upload-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.login-form label { color: var(--muted); font-size: 0.9em; }
input[type="password"], input[type="text"] {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 12px;
  font-size: 1em;
  border-radius: 4px;
  width: 100%;
}
.inline-input { width: auto; }
button {
  background: var(--fg);
  color: var(--bg);
  border: 0;
  padding: 10px 22px;
  font-size: 1em;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-start;
}
button:disabled { opacity: 0.4; cursor: default; }
.btn-link { align-self: flex-start; }
.row { display: flex; gap: 16px; align-items: center; }

.form-error { color: #e08585; }
.form-ok { color: #9fd09f; }
.uploaded { margin: 6px 0 0; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.2s;
}
.dropzone.dragover { border-color: var(--fg); color: var(--fg); }
#file-input { display: none; }
.dropzone { cursor: pointer; }

.file-list { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.file-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.file-item img { width: 90px; height: 70px; object-fit: cover; display: block; border-radius: 4px; }
.file-fields { display: flex; flex-direction: column; gap: 6px; }
.file-fields .frow { display: flex; gap: 8px; }
.file-fields input { flex: 1; padding: 7px 10px; font-size: 0.92em; }
.file-fields .hint { font-size: 0.78em; color: var(--muted); }
.remove-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 0.8em;
  border-radius: 4px;
}
.remove-btn:hover { color: #e08585; border-color: #e08585; }

/* tag autocomplete dropdown (upload.js) */
.tag-sug {
  position: absolute;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.9em;
}
.tag-sug div { padding: 6px 10px; cursor: pointer; }
.tag-sug div:hover, .tag-sug div.sel { background: var(--line); }

/* photo delete (visible only when authenticated) */
.del-form { margin-top: 30px; text-align: center; }
.del-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 16px;
  font-size: 0.85em;
  align-self: auto;
}
.del-btn:hover { color: #e08585; border-color: #e08585; }

@media (max-width: 560px) {
  .grid { --grid-min: 150px; --grid-gap: 4px; }
  .file-item { grid-template-columns: 1fr; }
  .file-item img { width: 100%; height: 120px; }
}
/* On touch devices the overlay is never forced on: without a pointer there
   is no hover, and a persistent title over every photo hides the images. */

/* ---- lightbox overlay (fullscreen carousel over the page) ---- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(250, 250, 250, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#lightbox.open { opacity: 1; }
#lightbox[hidden] { display: none; }

.lb-stage {
  position: relative;
  max-width: 94vw;
  max-height: 92vh;
  line-height: 0;
}
.lb-img {
  max-width: 94vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  display: block;
  box-shadow: 0 8px 60px rgba(0,0,0,0.6);
  transform-origin: top left;
  will-change: transform;
}

/* info overlayed on the image (bottom-right corner) */
.lb-info {
  position: absolute;
  right: 0;
  bottom: 0;
  /* cap at 30% of the image width, but never narrower than ~50% of a
     portrait photo's displayed width (storvika: 61vh wide -> 30vh) */
  max-width: max(30vh, 30%);
  padding: 48px 20px 18px;
  overflow-wrap: break-word;
  /* log-like fade: stays dark, then eases out slowly instead of a linear drop */
  background: linear-gradient(to top,
    rgba(0,0,0,0.92) 0%,
    rgba(0,0,0,0.92) 18%,
    rgba(0,0,0,0.84) 34%,
    rgba(0,0,0,0.72) 48%,
    rgba(0,0,0,0.58) 60%,
    rgba(0,0,0,0.44) 71%,
    rgba(0,0,0,0.32) 80%,
    rgba(0,0,0,0.21) 88%,
    rgba(0,0,0,0.12) 94%,
    rgba(0,0,0,0.06) 98%,
    rgba(0,0,0,0) 100%);
  color: #fff;
  text-align: right;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s ease 0.15s;
}
#lightbox.open .lb-info { opacity: 1; }
.lb-title { margin: 0; font-size: 1.4em; font-weight: 400; letter-spacing: 0.03em; }
.lb-desc { margin: 6px 0 0; font-size: 0.95em; opacity: 0.9; overflow-wrap: break-word; }
.lb-exif {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: max-content max-content;
  grid-template-rows: auto;
  gap: 2px 22px;
  justify-content: end;
  font-size: 0.68em;
  line-height: 1.7;
}
.lb-exif dt { color: rgba(255,255,255,0.6); }
.lb-exif dd { margin: 0; color: #fff; }

.lb-close {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 2;
  background: none;
  border: 0;
  color: var(--fg);
  font-size: 2.2em;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
}
.lb-close:hover { color: var(--muted); }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 2em;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.lb-nav:hover { background: #fff; border-color: var(--muted); }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

.lb-counter {
  position: absolute;
  bottom: 14px;
  left: 22px;
  color: var(--muted);
  font-size: 0.85em;
  letter-spacing: 0.08em;
}

@media (max-width: 640px) {
  .lb-nav { width: 44px; height: 44px; font-size: 1.6em; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}
@media (orientation: portrait) {
  .lb-stage { display: flex; flex-direction: column; line-height: normal; }
  .lb-img { max-height: 66vh; }
  /* In portrait the image only fills the top part of the screen; the
     middle-height side arrows would float over the info text. Anchor
     them to the bottom corners instead. */
  .lb-nav { top: auto; transform: none; bottom: 14px; }
  /* the bottom-left counter would sit under the prev button: move it up */
  .lb-counter { bottom: auto; top: 14px; }
  .lb-info {
    position: static;
    width: 100%;
    max-width: 100%;
    padding: 14px 0 80px; /* bottom room for the nav buttons */
    background: none;
    color: var(--fg);
    text-align: left;
    opacity: 1;
    transition: none;
  }
  .lb-title { font-size: 1.1em; }
  .lb-desc { opacity: 0.85; }
  .lb-exif { justify-content: start; }
  .lb-exif dt { color: var(--muted); }
  .lb-exif dd { color: var(--fg); }
}

/* ---- front page intro ---- */
.intro {
  max-width: 640px;
  margin: 8px auto 26px;
  text-align: center;
  color: var(--fg);
  font-size: 1.05em;
  letter-spacing: 0.01em;
}
