/* ==========================================================================
   Lensa Isa — demo by Rekarih Studio
   To re-skin for a client, change the tokens in section 1.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Brand colours */
  --paper: #FAFAF7;
  --ink: #17181A;
  --night: #0F0F10;
  --chalk: #EFEEE9;
  --yellow: #FFC42E;

  /* Semantic colours (flipped by the Lights switch, .on-dark and .on-accent) */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-soft: rgba(23, 24, 26, .68);
  --rule: rgba(23, 24, 26, .16);
  --accent: var(--yellow);      /* fills and marks */
  --on-accent: var(--ink);      /* text set on an accent fill */

  /* Type: two families, four sizes, two weights */
  --font-head: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --t-xs: .8125rem;
  --t-sm: 1rem;
  --t-md: 1.3125rem;
  --t-lg: clamp(2rem, 1.4rem + 2.2vw, 3rem);
  --w-regular: 400;
  --w-bold: 600;

  /* Layout */
  --side: 17.5rem;
  --gutter: clamp(1.25rem, 3.2vw, 2.5rem);
  --gap: clamp(.75rem, 1.5vw, 1.375rem);
  --section: clamp(4rem, 9vw, 7rem);

  color-scheme: light;
}

:root[data-lights="off"],
.on-dark {
  --bg: var(--night);
  --fg: var(--chalk);
  --fg-soft: rgba(239, 238, 233, .7);
  --rule: rgba(239, 238, 233, .2);
  color-scheme: dark;
}

.on-accent {
  --bg: var(--yellow);
  --fg: var(--ink);
  --fg-soft: rgba(23, 24, 26, .82);
  --rule: rgba(23, 24, 26, .3);
  --accent: var(--paper);
  --on-accent: var(--ink);
  color-scheme: light;
}

.on-dark,
.on-accent {
  background: var(--bg);
  color: var(--fg);
}

/* 2. Base ------------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--w-regular) var(--t-sm) / 1.55 var(--font-body);
}

h1, h2, h3, p, figure, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
svg, img { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3,
.logo__word,
.readout__title,
.viewer__title {
  font-family: var(--font-head);
  font-weight: var(--w-regular);
  text-wrap: balance;
}
h1, h2 { font-size: var(--t-lg); line-height: 1.06; letter-spacing: -.015em; }
h3 { font-size: var(--t-md); line-height: 1.25; }

.lead { font-size: var(--t-md); line-height: 1.45; }
.small { font-size: var(--t-xs); }
.soft { color: var(--fg-soft); }

/* The one link style: underlined, and marked with a highlighter on hover.
   .plain drops the underline (nav, logo). Buttons that read as links use .link. */
a,
.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
}
.link {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
a:hover,
.link:hover {
  background: var(--accent);
  box-shadow: 0 0 0 .15em var(--accent);
  color: var(--on-accent);
  text-decoration-color: transparent;
}
.plain a,
.plain { text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* The one button style. Controls are pills; photographs are square. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-weight: var(--w-bold);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn:hover {
  background: var(--accent);
  box-shadow: none;
  color: var(--on-accent);
}

.section {
  padding: var(--section) var(--gutter) 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 20;
}
.skip:focus { top: .5rem; }

/* A photograph frame: holds the file's shape and a tone until the image arrives. */
.frame {
  position: relative;
  display: block;
  aspect-ratio: var(--ratio);
  overflow: hidden;
  background: var(--tone, var(--rule));
}
.frame:hover {
  background: var(--tone, var(--rule));
  box-shadow: none;
}
.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* No file yet: show which one belongs here (set by main.js). */
.frame.is-empty img { display: none; }
.frame.is-empty::before {
  content: attr(data-file);
  position: absolute;
  inset: auto .75rem .6rem;
  color: rgba(255, 255, 255, .86);
  font-size: var(--t-xs);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* 3. Shell, demo strip, sidebar --------------------------------------------- */
.strip {
  padding: .55rem var(--gutter);
  text-align: center;
}

.side {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.side__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
  padding-inline: var(--gutter);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.logo:hover {
  background: none;
  box-shadow: none;
  color: inherit;
}
.logo svg { width: 2rem; height: 2rem; }
.logo__word { font-size: var(--t-md); line-height: 1; letter-spacing: -.01em; }

/* Lights switch */
.lights {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 2.75rem;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.lights__track {
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  border: 1px solid var(--fg);
  border-radius: 999px;
}
.lights__track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: .2rem;
  width: .75rem;
  height: .75rem;
  margin-top: -.375rem;
  border: 1px solid var(--fg);
  border-radius: 50%;
  transition: transform .2s, background-color .2s;
}
.lights[aria-checked="true"] .lights__track::after {
  transform: translateX(.95rem);
  background: var(--accent);
}

.nav-toggle { min-height: 2.75rem; }

.nav {
  display: none;
  flex-direction: column;
  padding: .25rem var(--gutter) 1rem;
}
.nav.is-open { display: flex; }
.nav a { padding: .6rem 0; align-self: flex-start; }
.nav a[aria-current="true"] { text-decoration: underline; }

.side__line,
.readout,
.side__foot { display: none; }

@media (max-width: 21.99rem) {
  .lights__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* Wide screens: the bar becomes a fixed sidebar beside the work. */
@media (min-width: 62rem) {
  html { scroll-padding-top: 1.5rem; }

  .shell {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .strip { grid-column: 2; grid-row: 1; }
  .main { grid-column: 2; grid-row: 2; }

  .side {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100dvh;
    padding: 2.25rem 2rem 1.5rem;
    overflow-y: auto;
    border-bottom: 0;
    border-right: 1px solid var(--rule);
  }
  .side__head { display: contents; }

  .logo {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .logo svg { width: 3.5rem; height: 3.5rem; }
  .logo__word { font-size: var(--t-lg); line-height: .95; }
  .logo__word em { display: block; }

  .nav-toggle { display: none; }
  .nav {
    display: flex;
    gap: .35rem;
    padding: 0;
  }
  .nav a { padding: .15rem 0; }

  .side__line { display: block; max-width: 24ch; }

  .lights {
    order: 2;
    margin-left: 0;
    align-self: flex-start;
  }
  .side__foot {
    order: 3;
    display: grid;
    gap: .6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
  }
  .side__links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
}

/* Short laptop screens: keep the sidebar from needing its own scrollbar. */
@media (min-width: 62rem) and (max-height: 50rem) {
  .side { gap: 1.1rem; padding-top: 1.5rem; }
  .logo { flex-direction: row; align-items: center; gap: .6rem; }
  .logo svg { width: 2.25rem; height: 2.25rem; }
  .logo__word { font-size: var(--t-md); line-height: 1; }
  .logo__word em { display: inline; }
  .side__line { display: none; }
}

/* 4. The readout (pointer devices on wide screens) --------------------------- */
@media (hover: hover) and (min-width: 62rem) {
  .readout {
    display: block;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
  }
}
.readout__title { font-size: var(--t-md); line-height: 1.2; }
.readout__title + p { margin-top: .25rem; }

.readout__exif {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem 1rem;
  margin-block: 1rem;
  font-variant-numeric: tabular-nums;
}
.readout__exif dt { line-height: 1.3; }

/* Light meter: the needle swings to each photograph's exposure. */
.meter {
  position: relative;
  margin-inline: .6rem;
  padding-top: .7rem;
}
.meter__needle {
  position: absolute;
  top: 0;
  left: calc(50% + var(--ev, 0) * 25%);
  width: .6rem;
  height: .45rem;
  margin-left: -.3rem;
  background: var(--fg);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: left .5s cubic-bezier(.3, 1.6, .5, 1);
}
.meter__ticks {
  height: .6rem;
  background:
    linear-gradient(90deg, var(--fg) 1px, transparent 1px) 0 0 / calc((100% - 1px) / 4) 100% repeat-x,
    linear-gradient(90deg, var(--fg-soft) 1px, transparent 1px) 0 100% / calc((100% - 1px) / 12) 50% repeat-x;
}
.meter__scale {
  display: flex;
  justify-content: space-between;
  margin-top: .2rem;
}
.meter__scale span {
  display: flex;
  justify-content: center;
  width: 0;
  white-space: nowrap;
}

/* 5. Work ------------------------------------------------------------------- */
.main {
  min-width: 0;
  container-type: inline-size;
}

.work { padding: clamp(1.5rem, 3vw, 2.5rem) var(--gutter) 0; }

.work__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}
.work__title {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.pill {
  min-height: 2.5rem;
  padding: .4rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  color: var(--fg-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pill:hover {
  border-color: var(--fg);
  color: var(--fg);
}
.pill[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

/* Masonry: each photograph keeps its own shape. */
.grid {
  columns: 2;
  column-gap: var(--gap);
}
@container (min-width: 40rem) { .grid { columns: 3; } }
@container (min-width: 60rem) { .grid { columns: 4; } }

.shot {
  position: relative;
  break-inside: avoid;
  margin-bottom: var(--gap);
}
.shot__cap {
  display: flex;
  flex-direction: column;
  padding-top: .5rem;
  line-height: 1.35;
}

/* Focus lock: autofocus brackets snap onto the photograph being pointed at… */
.shot .frame::after {
  content: "";
  position: absolute;
  inset: .7rem;
  --l: 1.1rem;
  --t: 2px;
  --c: linear-gradient(var(--yellow) 0 0);
  background:
    var(--c) left top / var(--l) var(--t),
    var(--c) left top / var(--t) var(--l),
    var(--c) right top / var(--l) var(--t),
    var(--c) right top / var(--t) var(--l),
    var(--c) left bottom / var(--l) var(--t),
    var(--c) left bottom / var(--t) var(--l),
    var(--c) right bottom / var(--l) var(--t),
    var(--c) right bottom / var(--t) var(--l);
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1.07);
  transition: opacity .15s, transform .28s cubic-bezier(.2, .9, .3, 1.25);
  pointer-events: none;
}
.shot .frame:hover::after,
.shot .frame:focus-visible::after {
  opacity: 1;
  transform: none;
}

/* …and the rest fall out of focus. The short delay on the way back stops the
   grid flickering as the pointer crosses the gaps between photographs. */
.shot .frame,
.shot .frame img {
  transition: opacity .35s .12s, filter .35s .12s;
}
@media (hover: hover) {
  .grid:has(.frame:is(:hover, :focus-visible)) .frame:not(:hover, :focus-visible) {
    opacity: .72;
    transition-delay: 0s;
  }
  .grid:has(.frame:is(:hover, :focus-visible)) .frame:not(:hover, :focus-visible) img {
    filter: blur(2.5px) saturate(.75);
    transition-delay: 0s;
  }
}

/* With a pointer and the sidebar in view, captions live in the readout instead. */
@media (hover: hover) and (min-width: 62rem) {
  .shot__cap {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* 6. About + enquiries ------------------------------------------------------- */
.about,
.enquiries {
  display: grid;
  gap: 2rem clamp(2rem, 6cqw, 4.5rem);
  align-items: start;
}
@container (min-width: 46rem) {
  .about { grid-template-columns: minmax(0, .75fr) minmax(0, 1fr); }
  .enquiries { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.about__text h2 { max-width: 18ch; }
.about__text p { max-width: 52ch; margin-top: 1.25rem; }
.about__text h3 { margin-top: 2.5rem; }

.rates { margin-top: .75rem; border-bottom: 1px solid var(--rule); }
.rates div {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: .75rem;
  border-top: 1px solid var(--rule);
}
.rates dd {
  flex: none;
  font-weight: var(--w-bold);
}

.enquiries__text h2 { max-width: 14ch; }
.enquiries__text p { max-width: 40ch; margin-top: 1.25rem; }

.contact { margin-top: 1.5rem; }
.contact li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: baseline;
  padding-block: .6rem;
  border-top: 1px solid var(--rule);
}
.contact a { justify-self: start; }

.form { display: grid; }
.form label {
  margin-bottom: .3rem;
  font-size: var(--t-xs);
  color: var(--fg-soft);
}
.form input,
.form select,
.form textarea {
  width: 100%;
  min-height: 2.75rem;
  margin-bottom: 1rem;
  padding: .6rem .75rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
}
.form textarea { resize: vertical; }
.form input:focus,
.form select:focus,
.form textarea:focus { border-color: var(--fg); }
.form__send {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
}

/* 7. Footer + studio credit --------------------------------------------------- */
.footer {
  margin-top: var(--section);
  padding: 1.25rem var(--gutter) 2rem;
  border-top: 1px solid var(--rule);
}

.credit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 3rem;
  padding: clamp(2.5rem, 5vw, 4rem) var(--gutter);
}
.credit p { margin-top: .5rem; }

/* 8. Viewer ------------------------------------------------------------------- */
.viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
}
.viewer[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
.viewer::backdrop { background: var(--night); }

.viewer__stage {
  display: grid;
  place-items: center;
  margin: var(--gutter) var(--gutter) 0;
  container-type: size;
  cursor: zoom-out;
}
.viewer__frame {
  width: min(100cqw, calc(100cqh * var(--ratio)));
  cursor: default;
}

.viewer__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: .75rem 2rem;
  padding: 1rem var(--gutter) 1.25rem;
}
.viewer__title { font-size: var(--t-md); line-height: 1.2; }
.viewer__nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.viewer__nav .link { min-height: 2.75rem; }
#viewer-close { margin-left: 1rem; }

/* 9. Motion preferences ------------------------------------------------------ */
::view-transition-group(*) { animation-duration: .4s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
  .grid .frame img { filter: none !important; }
}
