/* varhola.net — minimal photo gallery. Light and dark follow the system setting. */

:root {
  --bg: #fafaf9;
  --fg: #0f0f10;
  --muted: rgba(15, 15, 16, .5);
  --faint: rgba(15, 15, 16, .28);
  --line: rgba(15, 15, 16, .09);
  --skeleton: rgba(15, 15, 16, .05);
  --glass: rgba(250, 250, 249, .72);
  --nav-w: 248px;
  --pad: clamp(16px, 2.2vw, 28px);
  --gap: 6px;
  --row: clamp(160px, 16vw, 280px);
  --radius: 3px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sans: Geist, 'Hiragino Sans', 'Yu Gothic', 'Noto Sans CJK JP', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --fg: #ededec;
    --muted: rgba(237, 237, 236, .5);
    --faint: rgba(237, 237, 236, .26);
    --line: rgba(237, 237, 236, .1);
    --skeleton: rgba(237, 237, 236, .05);
    --glass: rgba(11, 11, 12, .66);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { margin: 0; background: var(--bg); color: var(--fg); word-wrap: break-word; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 3px; border-radius: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* Page transitions (Chrome / Safari; others just navigate normally). */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
::view-transition-group(photo) { animation-duration: .42s; animation-timing-function: var(--ease); }
::view-transition-old(photo), ::view-transition-new(photo) { height: 100%; object-fit: cover; }

/* ---------- Sidebar ---------- */
.site-nav {
  position: fixed; inset: 0 auto 0 0; z-index: 10;
  width: var(--nav-w);
  padding: calc(var(--pad) + 4px) var(--pad) var(--pad);
  display: flex; flex-direction: column;
}
.brand { font-weight: 600; letter-spacing: -.015em; font-size: 1rem; flex-shrink: 0; }
.toggle { position: absolute; opacity: 0; pointer-events: none; }
.menu-btn { display: none; }
.site-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-top: 2.25rem; }
.site-menu .tags {
  flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 1px;
  margin: 0 -8px; padding: 0 8px 2.5rem;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
}
.site-menu .tags::-webkit-scrollbar { display: none; }
.tag {
  display: flex; align-items: baseline; gap: .75rem;
  padding: .2rem 0;
  color: var(--muted);
  transition: color .15s;
}
.tag span:first-child { flex: 1; min-width: 0; position: relative; transition: transform .25s var(--ease); }
.tag .n { font-family: var(--mono); font-size: .72rem; color: var(--faint); font-variant-numeric: tabular-nums; transition: color .15s; }
.tag:hover, .tag.active { color: var(--fg); }
.tag:hover .n, .tag.active .n { color: var(--muted); }
.tag:hover span:first-child { transform: translateX(3px); }
.tag.active span:first-child { transform: translateX(12px); }
.tag.active span:first-child::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  width: 5px; height: 5px; margin-top: -2px; border-radius: 50%; background: var(--fg);
}
.menu-foot { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; padding-top: 1rem; font-size: .87rem; }
.menu-foot a { color: var(--muted); transition: color .15s; }
.menu-foot a:hover, .menu-foot a.active { color: var(--fg); }

/* ---------- Feed ---------- */
.feed { margin-left: var(--nav-w); padding: calc(var(--pad) - 2px) var(--pad) var(--pad) 0; min-height: 100vh; }
.feed-head { padding: .25rem 0 calc(var(--pad) + 8px); }
.feed-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  font-weight: 500; letter-spacing: -.045em; line-height: 1;
}
.feed-head p { margin: .7rem 0 0; font-family: var(--mono); font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.newer {
  display: inline-block; margin-bottom: var(--pad);
  font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.newer:hover { color: var(--fg); }

/* Justified rows: every tile grows in proportion to its aspect ratio, so each row fills the width. */
.posts { display: flex; flex-wrap: wrap; gap: var(--gap); }
.posts::after { content: ""; flex-grow: 1000000; }
.post {
  position: relative; display: block; overflow: hidden;
  width: calc(var(--w) / var(--h) * var(--row));
  flex-grow: calc(var(--w) / var(--h) * 100);
  aspect-ratio: var(--w) / var(--h);
  border-radius: var(--radius);
  background: var(--skeleton);
  cursor: zoom-in;
  transition: opacity .35s var(--ease);
}
.post img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .7s var(--ease);
}
.js .post img { opacity: 0; }
.js .post img.loaded { opacity: 1; animation: rise .7s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: scale(1.04); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@media (hover: hover) {
  .posts:has(.post:hover) .post:not(:hover) { opacity: .55; }
  .post:hover img { transform: scale(1.025); }
}

/* Infinite scroll status / fallback pagination */
.feed-status { display: none; }
.js .feed-status {
  display: flex; align-items: center; justify-content: center;
  min-height: 9rem; padding: 2rem 0 1rem;
  font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.feed-status > * { display: none; }
.feed-status[data-state="loading"] .loading,
.feed-status[data-state="error"] .retry { display: inline-flex; }
.feed-status[data-state="done"] .end { display: flex; }
.loading { gap: 6px; }
.loading i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1s infinite ease-in-out both; }
.loading i:nth-child(2) { animation-delay: .15s; }
.loading i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.retry { text-transform: inherit; letter-spacing: inherit; border-bottom: 1px solid var(--faint); }
.end { align-items: center; gap: .9rem; width: 100%; }
.end::before, .end::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.end a:hover { color: var(--fg); }
.end .dot { color: var(--faint); }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 2.5rem 0 1rem; font-family: var(--mono); font-size: .8rem; color: var(--muted);
}
.pager a { color: var(--fg); }
.pager a:hover { opacity: .6; }
.js .pager { display: none; }

/* ---------- Text pages ---------- */
.prose { max-width: 36rem; font-size: 1.05rem; line-height: 1.65; }
.prose p { margin: 0 0 1.1em; }
.prose a { border-bottom: 1px solid var(--faint); transition: border-color .15s; }
.prose a:hover { border-color: var(--fg); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* ---------- Archive ---------- */
.archives section { margin-bottom: 2.25rem; }
.archives h2 {
  position: sticky; top: 0; z-index: 1; margin: 0 0 .5rem; padding: .6rem 0;
  font-family: var(--mono); font-size: .75rem; font-weight: 400; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  background: linear-gradient(var(--bg) 70%, transparent);
}
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--gap); }
.archive-grid a { aspect-ratio: 1; overflow: hidden; border-radius: 2px; background: var(--skeleton); }
.archive-grid img, .post img { color: transparent; font-size: 0; }
.archive-grid img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease); }
.archive-grid a:hover img { transform: scale(1.06); }

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  :root { --row: 128px; --gap: 4px; --pad: 14px; }
  .site-nav {
    position: sticky; top: 0; width: auto; height: auto;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top)) var(--pad) 12px;
  }
  /* The blur lives on a pseudo-element: backdrop-filter on the header itself would trap the
     fixed full-screen menu inside the header's box. */
  .site-nav::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: var(--glass);
    -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
    border-bottom: 1px solid var(--line);
  }
  .menu-btn {
    display: block; position: relative; z-index: 2; cursor: pointer; user-select: none; -webkit-user-select: none;
    font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
    padding: .35rem .7rem; margin: -.35rem -.7rem;
  }
  .menu-btn .shut, .toggle:checked ~ .menu-btn .open { display: none; }
  .toggle:checked ~ .menu-btn .shut { display: inline; }
  .brand { position: relative; z-index: 2; }
  .site-menu {
    position: fixed; inset: 0; margin: 0; z-index: 1;
    padding: calc(76px + env(safe-area-inset-top)) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
    background: var(--bg);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .25s var(--ease), transform .35s var(--ease), visibility 0s .35s;
  }
  .toggle:checked ~ .site-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .site-menu .tags { gap: 0; }
  .tag { font-size: 1.45rem; letter-spacing: -.025em; padding: .18rem 0; }
  .tag .n { font-size: .75rem; }
  .menu-foot { font-size: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
  body:has(.toggle:checked) { overflow: hidden; }
  .feed { margin: 0; padding: var(--pad); }
  .feed-head { padding-top: .5rem; }
  .archives h2 { top: 57px; }
}

/* ---------- Photo viewer ---------- */
body.viewer {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
}
.viewer-bar {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) var(--pad) 10px;
}
.viewer-bar .brand { font-size: .95rem; }
.counter {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; font-variant-numeric: tabular-nums;
}
.counter span { color: var(--faint); }
.close, .zone .btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: border-color .2s, transform .25s var(--ease), opacity .25s;
}
.close { margin-right: -4px; }
.close:hover { border-color: var(--faint); transform: rotate(90deg); }
.viewer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.stage {
  position: relative; display: grid; place-items: center; min-height: 0;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding: 6px clamp(var(--pad), 7vw, 110px);
}
.stage img {
  grid-area: 1 / 1; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 2px;
}
.zone { position: absolute; top: 0; bottom: 0; width: 38%; display: flex; align-items: center; -webkit-tap-highlight-color: transparent; }
.zone.prev { left: 0; justify-content: flex-start; padding-left: var(--pad); cursor: w-resize; }
.zone.next { right: 0; justify-content: flex-end; padding-right: var(--pad); cursor: e-resize; }
.zone .btn { width: 46px; height: 46px; opacity: .55; }
.zone:hover .btn { opacity: 1; border-color: var(--faint); }
.zone.prev:hover .btn { transform: translateX(-3px); }
.zone.next:hover .btn { transform: translateX(3px); }
.zone:active .btn { transform: scale(.94); }

.viewer-foot {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  padding: 10px var(--pad) calc(18px + env(safe-area-inset-bottom));
}
.details { text-align: center; min-width: 0; }
.caption { margin: 0; }
.caption.exif { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: .15rem .9rem; }
.caption.exif time { font-weight: 500; }
.caption.exif .camera { color: var(--muted); }
.caption.exif .camera { display: inline-flex; align-items: center; gap: .45em; }
.viewer .caption .cam-icon { width: 21px; height: 14px; flex-shrink: 0; stroke-width: 1.15; opacity: .9; }
.caption.exif .settings { font-family: var(--mono); font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.caption.exif .settings > span + span::before { content: "/"; margin: 0 .5em; color: var(--faint); }
.caption.exif > * { white-space: nowrap; }
.photo-tags { margin-top: .4rem; display: flex; justify-content: center; gap: .4rem; flex-wrap: wrap; }
.photo-tags a {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: .15rem .55rem; border: 1px solid var(--line); border-radius: 99px; transition: color .15s, border-color .15s;
}
.photo-tags a:hover { color: var(--fg); border-color: var(--faint); }
.step {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  transition: color .15s;
}
.step:hover { color: var(--fg); }
.step.next { justify-self: end; }
.step svg { width: 14px; height: 14px; }
@media (min-width: 801px) { .step { visibility: hidden; } }

@media (max-width: 800px) {
  .counter { position: static; transform: none; }
  .viewer-bar .brand { display: none; }
  .stage { padding: 0; }
  .zone .btn { display: none; }
  .zone { cursor: pointer; }
  .viewer-foot { grid-template-columns: auto 1fr auto; gap: .75rem; }
  .caption.exif { flex-direction: column; align-items: center; gap: .1rem; }
  .caption.exif .camera { font-size: .85rem; }
  .step span { display: none; }
  .step { width: 40px; height: 40px; justify-content: center; border: 1px solid var(--line); border-radius: 50%; color: var(--fg); }
  .step svg { width: 16px; height: 16px; }
  span.step { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}
