/* ---------------------------------------------------------------
   Sid Ahimsa — Selected Works
   Everything is here in one file. Edit freely.
   The photos do the work; this stylesheet just gets out of the way.
   --------------------------------------------------------------- */

:root {
  --measure: 900px;   /* max width of the photo column */
  --gap: 80px;        /* vertical space between photos */
}

html[data-theme="dark"], :root {
  --bg: #0d0d0d;
  --fg: #eaeaea;
  --muted: #777777;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #888888;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* --- Photos aren't selectable or draggable ----------------------- */
/* Deters casual saving and stops the ghost-image drag. Text stays
   selectable so the email can still be copied. */
img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;   /* no iOS long-press "Save Image" sheet */
}

html { overflow-x: hidden; }   /* the view-morph transform can overhang */

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Header ------------------------------------------------------ */
header {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 80px 24px 60px;
  position: relative;
}
h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tagline {
  color: var(--muted);
  margin-top: 2px;
}
.contact {
  margin-top: 18px;
  font-size: 0.9rem;
}
a { color: inherit; }

/* --- Place filter row (built by script.js from data-place tags) --- */
.places {
  margin-top: 24px;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.places button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: .06em;
  cursor: pointer;
  padding: 4px 2px;
  font-family: inherit;
}
.places button:hover { color: var(--fg); }
.places button.on { color: var(--fg); border-bottom: 1px solid var(--fg); }

/* --- Theme toggle (desktop only) ---------------------------------- */
.theme-toggle,
.view-toggle {
  position: fixed;
  top: 28px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
  transition: opacity .6s ease, color .2s ease;
}
.theme-toggle { right: 24px; }
.view-toggle { left: 24px; }
.view-toggle.icon-single { font-size: 1.6rem; }
.theme-toggle:hover,
.view-toggle:hover { color: var(--fg); }

/* The controls recede when the page has been still for a while. */
html.controls-dim .theme-toggle,
html.controls-dim .view-toggle { opacity: .2; }
html.controls-dim .theme-toggle:hover,
html.controls-dim .view-toggle:hover { opacity: 1; }

/* --- Mobile hero -------------------------------------------------- */
.hero {
  display: none;            /* mobile-only; shown in the media query below */
  position: relative;
  height: 100vh;
  height: 100svh;
  background: #000;
}
.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.hero-text {
  position: relative;
  z-index: 1;
  transition: opacity .22s ease;   /* dissolves as the viewer opens */
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
}
.hero-name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hero-link {
  color: #fff;
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px;             /* comfortable tap target */
}
.hero.opening .hero-text { opacity: 0; }
.hero { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* --- Photo column ----------------------------------------------- */
main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
main img {
  width: 100%;
  height: auto;
  display: block;
}

/* --- Footer ------------------------------------------------------ */
footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 90px 24px 120px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Full-screen viewer (mobile) ---------------------------------- */
.viewer {
  position: fixed;
  inset: 0;
  height: 100dvh;             /* fills whatever the mobile toolbars leave */
  z-index: 10;
  background: #000;
  overscroll-behavior: none;  /* keep swipe-down-close from triggering pull-to-refresh */
}
/* The ✕ and the counter step aside once you settle on a photo; a tap
   anywhere brings them back (script.js). */
.viewer-close,
.viewer-counter,
.viewer-hint { transition: opacity .4s ease; }
.viewer.chrome-hidden .viewer-close,
.viewer.chrome-hidden .viewer-counter,
.viewer.chrome-hidden .viewer-hint {
  opacity: 0;
  pointer-events: none;       /* a tap on the hidden ✕ must not close */
}
.viewer[hidden] { display: none; }
.viewer-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.viewer-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));   /* clear of the notch */
  right: calc(12px + env(safe-area-inset-right));
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
}
.viewer-counter {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: #bbb;
  font-size: 0.85rem;
}
.viewer-hint { display: none; }
/* --- Page-half click zones (desktop single view only) ------------- */
.click-zone { display: none; }

body.viewer-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* --- Desktop (>= 768px): one photo per screen, nothing cropped ---- */
@media (min-width: 768px) {
  header {
    max-width: none;
    text-align: center;
    padding: 70px 40px 60px;
  }

  main {
    max-width: none;
    padding: 0 40px;
    align-items: center;
    gap: 14vh;
    transform-origin: 0 0;   /* anchor for the view-morph (script.js) */
  }
  main img {
    width: auto;
    max-width: min(100%, 1200px);
    max-height: 88vh;
  }

  /* Either half of the page steps a photo. Sits above the photos but
     below the header, so the header's links and toggles still work. */
  header { z-index: 2; }
  html[data-view="single"] .click-zone {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 50%;
    z-index: 1;
  }
  .zone-prev { left: 0; }
  .zone-next { right: 0; }
  .click-zone { cursor: pointer; }

  /* The pointer bows out when it hasn't moved for a while, so nothing
     sits on top of a photo you're looking at. Any movement brings it
     back (script.js toggles the class). */
  html.cursor-idle * { cursor: none; }

  footer {
    max-width: none;
    text-align: center;
    padding: 16vh 40px 12vh;
  }

  .photo-counter,
  .photo-hint {
    position: fixed;
    bottom: 22px;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: .03em;
    pointer-events: none;
  }
  .photo-counter { right: 26px; }
  .photo-hint { left: 26px; transition: opacity .5s ease; }

  .theme-toggle { top: 30px; right: 40px; }
  .view-toggle { top: 30px; left: 40px; }

  /* Grid view: same journey order as an overview; click opens the viewer */
  html[data-view="grid"] main {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 1500px;
    padding: 0 40px;
  }
  html[data-view="grid"] main img {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    cursor: zoom-in;
  }
  html[data-view="grid"] .photo-hint,
  html[data-view="grid"] .photo-counter { display: none; }

  /* Desktop viewer: slides stack and cross-slide (script.js softSlide)
     instead of scrolling, so paging is gentle rather than a full sweep. */
  .viewer-track {
    display: block;
    overflow: hidden;
    scroll-snap-type: none;
  }
  .viewer-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    will-change: opacity, transform;
  }
  .viewer-slide img { max-width: min(92vw, 1400px); }
  .viewer-hint {
    display: block;
    position: absolute;
    right: 24px;
    bottom: 20px;
    color: #777;
    font-size: 0.78rem;
  }
}

/* Two grid columns on narrower desktops so tiles stay generous */
@media (min-width: 768px) and (max-width: 1099px) {
  html[data-view="grid"] main { grid-template-columns: repeat(2, 1fr); }
}

/* --- Mobile (< 768px): black, hero, edge-to-edge feed ------------- */
@media (max-width: 767px) {
  .hero { display: block; }
  header { display: none; }
  body { background: #000; color: #fff; }
  footer { color: #999; padding: 60px 16px 80px; }
  main {
    max-width: none;
    padding: 0;
    gap: 4px;
  }
  main img {
    -webkit-tap-highlight-color: transparent;
  }
  /* The hero photo isn't repeated right below itself; script.js marks
     the first feed image with .hero-dup only when it matches the hero.
     It stays reachable inside the viewer. */
  main img.hero-dup { display: none; }
  :focus-visible { outline-color: #fff; }
  .photo-counter, .photo-hint { display: none; }
}

/* --- Respect reduced-motion & keep focus visible ---------------- */
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
