/*
  Amal Chandaria / Photography
  Recreated from the Cargo site. The original uses ABC Dinamo's "Diatype" and
  "Diatype Mono" (licensed through Cargo). If you own a web licence, drop the
  .woff2 files in /public/fonts and uncomment the @font-face rules below —
  everything else picks them up through the --font-* variables.
*/

/*
@font-face { font-family: "Diatype"; src: url("/fonts/ABCDiatypeVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Diatype Mono"; src: url("/fonts/ABCDiatypeMonoVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
*/

:root {
  --font-body: "Diatype Mono", "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: "Diatype Mono", "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ink: rgba(0, 0, 0, 0.85);
  --ink-2: rgba(0, 0, 0, 0.75);
  --ink-muted: rgba(0, 0, 0, 0.4);
  --rule: rgba(0, 0, 0, 0.75);
  --accent: #f2b540;
  --spaghetti: #ea381b;
  --bg: #ffffff;
  --placeholder: #f4f4f4;
  --field-line: rgba(0, 0, 0, 0.2);
  color-scheme: light;

  /* ── Layout grid ──────────────────────────────────────────────────────────
     Everything is built from one unit, u = 13px.
       margin   2u  — page edges on all four sides
       gutter   1u  — between photos, columns, and image ↔ caption
       band     8u  — header band; the first year in the sidebar, the top of
                      every grid / about / contact sit on this line (2u + 8u)
     Horizontal lines: A = 2u (logo, captions, slideshow top)
                       B = 10u (album list, photo grid, page content)
                       Z = bottom − 2u (theme toggle, copyright)
     Columns: sidebar (22vw) │ 2u │ content (3 equal columns, 1u gutters) │ 2u */
  --u: 13px;
  --pad: calc(var(--u) * 2);
  --gutter: var(--u);
  --top: calc(var(--u) * 8);
  --sidebar: 22vw;
  --caption-h: 12px;      /* one line of 10px caption text */
  /* Type scale — two sizes site-wide (plus the logo):
       --text   body: sidebar, album names, links, about copy
       --small  captions: album details, labels, Previous / Next, copyright */
  --text: 11px;
  --small: 10px;
  --leading: 1.4;
}

/* Dark mode: light is the default; dark only when the visitor picks it. */
:root[data-theme="dark"] {
  --ink: rgba(255, 255, 255, 0.86);
  --ink-2: rgba(255, 255, 255, 0.75);
  --ink-muted: rgba(255, 255, 255, 0.42);
  --rule: rgba(255, 255, 255, 0.6);
  --bg: #0f0f0f;
  --placeholder: #1a1a1a;
  --field-line: rgba(255, 255, 255, 0.22);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); min-height: 100lvh; }   /* page colour runs under phone toolbars */
/* A fixed full-screen backdrop in the current theme colour. iOS Safari keeps
   the colour it sampled at load for the strip behind its floating toolbar;
   this layer paints that strip itself, so switching light → dark has no
   white band left over. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 100vh;
  height: 100lvh;
  background: var(--bg);
  z-index: -1;
  pointer-events: none;
}
/* Text colour eases between themes; backgrounds switch instantly. iOS Safari
   reads the colour of full-screen layers (like the open menu) the moment it
   changes to tint the strip under its toolbar — a fade would leave it holding
   the old colour. */
body { transition: color 0.25s ease; }

/* Theme toggle — a small half-filled circle in the sidebar, a little below
   the links (above the copyright). Scrolls with the menu, so nothing overlaps. */
.theme-toggle {
  display: block;
  width: 14px;
  height: 14px;
  margin-top: calc(var(--text) * var(--leading) * 2);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.4s ease;
}
.theme-toggle svg { display: block; width: 100%; height: 100%; opacity: 0.7; transition: opacity 0.2s ease; }
.theme-toggle:hover svg { opacity: 1; }
.theme-toggle circle { fill: none; stroke: currentColor; stroke-width: 1.2; }
.theme-toggle path { fill: currentColor; }
:root[data-theme="dark"] .theme-toggle { transform: rotate(180deg); }

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

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text);
  font-weight: 400;
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-transform: uppercase;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
a:active { opacity: 0.7; }

hr { height: 1px; border: 0; background: var(--rule); margin: 0; }

.caption {
  display: block;
  font-family: var(--font-display);
  font-size: var(--small);
  line-height: 1.2;
  color: var(--ink-muted);
  font-weight: 400;
  margin: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: var(--pad) 0 var(--pad) var(--pad);
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 10;
}
.sidebar::-webkit-scrollbar { display: none; }
/* When the album list runs past the bottom of the screen, its last few lines
   fade out as a hint that it scrolls; the fade lifts once you reach the end. */
@media (min-width: 768px) {
  .sidebar.has-more {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 96px), transparent calc(100% - 8px));
    mask-image: linear-gradient(to bottom, #000 calc(100% - 96px), transparent calc(100% - 8px));
  }
}

.logo { height: var(--top); }

.logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--ink);
  max-width: 7.5ch;            /* "AMAL / CHANDARIA" on two lines */
}
.logo h1 a { color: var(--ink); display: inline-block; }
.logo h1 a:hover { color: var(--ink); }

.site-nav { display: flex; flex-direction: column; }

.nav-year { display: flex; flex-direction: column; margin-bottom: calc(var(--text) * var(--leading)); }
.nav-year b { font-weight: 500; }
.nav-year a, .nav-links a { align-self: flex-start; }

.site-nav a.active { font-weight: 500; color: var(--accent); }

.site-nav hr { margin-bottom: calc(var(--text) * var(--leading) * 2); }

.nav-links { display: flex; flex-direction: column; align-items: flex-start; }
.nav-links .arrow { font-size: 0.9em; }

.spaghetti-link:hover { color: var(--spaghetti); }
.instagram-link:hover {
  color: transparent;
  background-image: linear-gradient(90deg, #833ab4, #e1306c, #f77737, #fcaf45);
  -webkit-background-clip: text;
  background-clip: text;
}

.menu-toggle { display: none; }

/* ── Main column ──────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  padding: var(--pad) var(--pad) 0 calc(var(--sidebar) + var(--pad));
}

.footer {
  padding: var(--pad);
  padding-left: calc(var(--sidebar) + var(--pad));
  text-align: right;
}

/* Desktop: the copyright is the quiet last line of the sidebar, under the
   links — the theme toggle keeps the bottom corner to itself, and the whole
   content column is free for photographs. */
.nav-copyright { margin: calc(var(--text) * var(--leading) * 2) 0 0; }   /* under the toggle */
@media (min-width: 768px) {
  .main { padding-bottom: var(--pad); }
  .footer { display: none; }
}

/* ── Album page ───────────────────────────────────────────────────────────── */

.album-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--gutter);   /* same columns as the photo grid, so captions centre over them */
  text-align: center;
}

.album-location {
  margin: 0;
  height: calc(var(--top) - var(--caption-h));   /* grid top lands on line B */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gutter);
  align-items: start;
}
/* main.js upgrades this to a true masonry (shortest-column) layout */
.gallery.is-masonry { display: flex; align-items: flex-start; }

/* Justified rows for mixed portrait / landscape albums (built by main.js).
   Every photo in a row shares one height; widths follow each photo's shape. */
.gallery.is-rows { display: flex; flex-direction: column; gap: var(--gutter); }
.gallery .row { display: flex; gap: var(--gutter); width: 100%; margin: 0; }   /* a short last row sits flush left */
.gallery .row .photo { flex: var(--r) 1 0; min-width: 0; }
.gallery .col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--gutter); }

.photo {
  display: block;
  position: relative;
  background: var(--placeholder);
  cursor: zoom-in;
  overflow: hidden;
}
.photo img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.photo.is-loaded { background: transparent; }
.photo.is-loaded img { opacity: 1; transform: none; }
.photo:active { opacity: 1; }

/* ── Home slideshow ───────────────────────────────────────────────────────── */

/* Fills the whole content column, line A (logo top) to line Z (bottom margin,
   shared with the toggle + copyright in the sidebar corner). Photos sit on
   line Z, centred across the column: landscapes span the full width, squares
   and verticals the full height. */
.slideshow {
  position: relative;
  height: calc(100svh - var(--pad) * 2);   /* line A → line Z */
  min-height: 420px;
}
.slideshow a {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--fade, 0.7s) ease-in-out;
  pointer-events: none;
}
.slideshow a.is-active { opacity: 1; pointer-events: auto; }
/* Landscapes hug the bottom-right corner, so the gap to the right edge always
   equals the gap to the bottom (2u each), whatever the window shape. */
.slideshow a.is-landscape { justify-content: flex-end; }
.slideshow img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--u) * 4);   /* 4u: leaves room for the 1u-inset buttons */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.lightbox.is-open { opacity: 1; visibility: visible; transition: opacity 0.2s ease; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-out;
  user-select: none;
}
.lightbox button {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(87, 87, 87, 0.35);
  color: rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.lightbox button:active { opacity: 0.7; }
.lightbox:focus, .lightbox button:focus { outline: none; }
.lightbox button:focus-visible { outline: 1px solid var(--ink-muted); outline-offset: 3px; }
.lightbox button svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.lightbox .lb-close { top: var(--u); right: var(--u); }
.lightbox .lb-prev { left: var(--u); top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: var(--u); top: 50%; transform: translateY(-50%); }
.lightbox .lb-count {
  position: absolute;
  bottom: calc(var(--u) * 2 - var(--caption-h) / 2);
  left: 0;
  right: 0;
  text-align: center;
}
body.lightbox-open { overflow: hidden; }

/* ── About ────────────────────────────────────────────────────────────────── */

/* Three grid columns from line B — portrait │ text │ details. */
.about {
  margin-top: var(--top);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--gutter);
  align-items: start;
}
.about-portrait { width: 100%; height: auto; display: block; }
.about-text {
  font-size: var(--text);
  line-height: 1.6;
  text-transform: none;
  padding-right: calc(var(--gutter) * 5);   /* shorter lines + room before the details column */
  margin-top: -0.3em;              /* first line's cap height sits on line B */
}
.about-text p { margin: 0 0 1.6em; }
.about-text a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.about-text u { text-decoration: none; }
.about-details { display: flex; flex-direction: column; gap: calc(var(--gutter) * 2); }
.about-group .caption { margin-bottom: 6px; }
.about-group ul { list-style: none; margin: 0; padding: 0; line-height: var(--leading); }

/* ── Contact ────────────────────────────────────────────────────────────────
   From line B, on a 6-column split of the 3-column grid: the form fills the
   first column (Name, Email, Message stacked, Send flush right); the links
   start halfway across the second column, near the centre of the page. */

.contact {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  column-gap: var(--gutter);
  align-items: start;
  margin-top: var(--top);
}
.contact-form {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: calc(var(--gutter) * 2);
}
.contact-details { grid-column: 4 / 7; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input,
.field textarea {
  font: inherit;
  font-size: var(--text);
  line-height: var(--leading);
  text-transform: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--field-line);
  border-radius: 0;
  padding: 0 0 6px;
  outline: none;
  resize: none;
  transition: border-color 0.2s ease;
}
.field textarea { border: 1px solid var(--field-line); padding: 8px; }
.field input:focus,
.field textarea:focus { border-color: var(--rule); }
.field:focus-within .caption { color: var(--ink); }
.contact-form .hp { position: absolute; left: -9999px; }
.contact-actions { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gutter); margin-top: calc(var(--gutter) * -1); }
.contact-status { margin: 0; }
.contact-form button {
  font: inherit;
  font-size: var(--text);
  text-transform: uppercase;
  border: 0;
  background: none;
  color: var(--ink);
  padding: 0;
  cursor: pointer;
}
.contact-form button:hover { color: var(--accent); }
.contact-form button:hover .pager-arrow { transform: translateX(4px); }
.contact-form button:disabled { opacity: 0.4; cursor: default; }

.not-found { margin-top: var(--top); }

/* ── Intro: the name develops like a print in the tray ───────────────────────
   First visit per session only (see the head script + main.js). Each letter
   comes up from a soft, warm, faint smudge to sharp black at its own pace;
   the rest of the page fades in once the name has "developed". */
:root { --developer: #9a7b5c; }
.intro:not(.developing) .logo h1 { opacity: 0; }
.dev-word { white-space: nowrap; }
.dev { display: inline-block; }
.developing .dev {
  animation: develop 1700ms cubic-bezier(0.3, 0, 0.2, 1) both;
}
@keyframes develop {
  0%   { opacity: 0;    filter: blur(6px);   color: var(--developer); }
  45%  { opacity: 0.5;  filter: blur(1.5px); color: var(--developer); }
  100% { opacity: 1;    filter: blur(0);     color: var(--ink); }
}
.intro .sidebar-nav,
.intro .main,
.intro .footer,
.intro .menu-toggle { opacity: 0; }
.intro.developing .sidebar-nav,
.intro.developing .main,
.intro.developing .footer,
.intro.developing .menu-toggle { opacity: 1; transition: opacity 0.9s ease 1.6s; }

/* ── Page transitions ─────────────────────────────────────────────────────────
   Cross-document View Transitions: the sidebar holds still while the photos
   dissolve into the next page. Browsers without support just navigate. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
::view-transition-group(sidebar) { animation: none; }
::view-transition-old(sidebar),
::view-transition-new(sidebar) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { animation: vt-out 180ms ease-in both; }
::view-transition-new(root) { animation: vt-in 380ms cubic-bezier(0.2, 0, 0, 1) 120ms both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ── Previous / next album ───────────────────────────────────────────────────
   Sits on the content column's outer edges: previous flush left, next flush
   right, so both line up with the photo grid above. */

.album-pager {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gutter);
  margin: calc(var(--top) * 1.2) 0 calc(var(--top) * 0.4);
}
.album-pager a { display: flex; flex-direction: column; gap: 6px; }
.album-pager .pager-prev { align-items: flex-start; text-align: left; }
.album-pager .pager-next { align-items: flex-end; text-align: right; }
.pager-title { font-size: var(--small); line-height: 1.2; }
.pager-arrow { display: inline-block; transition: transform 0.35s cubic-bezier(0.2, 0, 0, 1); }
.pager-prev:hover .pager-arrow { transform: translateX(-4px); }
.pager-next:hover .pager-arrow { transform: translateX(4px); }
.album-pager a:hover .caption { color: inherit; }

/* ── Viewer: click left/right half to move ────────────────────────────────── */

.lightbox img { cursor: e-resize; touch-action: pinch-zoom; }
.lightbox img.is-prev { cursor: w-resize; }
.lightbox .lb-anim { position: fixed; z-index: 101; object-fit: cover; pointer-events: none; transform-origin: 0 0; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  /* phone grid: u = 8px; margins and gutters are both 2u */
  :root { --u: 8px; --pad: calc(var(--u) * 2); --gutter: calc(var(--u) * 2); --text: 13px; --top: 0px; }

  .sidebar {
    position: absolute;
    inset: 0 0 auto 0;
    width: auto;
    padding: 18px var(--pad) 0;
    overflow: visible;
  }
  .logo { height: auto; }
  .logo h1 { font-size: 40px; }

  .menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    position: absolute;
    top: 18px;
    right: var(--pad);
    width: 34px;
    height: 34px;
    padding: 4px;
    background: none;
    border: 0;
    cursor: pointer;
    z-index: 30;
  }
  .menu-toggle span {
    display: block;
    height: 1.5px;
    background: var(--ink);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .menu-open .menu-toggle span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
  .menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

  .sidebar-nav {
    display: none;
    position: fixed;
    inset: 0 0 auto 0;
    /* 100lvh = the full screen, including the strip behind Safari's floating
       toolbar, so no white band shows beneath the open menu */
    height: 100vh;
    height: 100lvh;
    background: var(--bg);
    padding: 124px var(--pad) calc(120px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 20;
  }
  .menu-open .sidebar-nav { display: block; }
  .menu-open { overflow: hidden; }
  .menu-open .logo { position: relative; z-index: 30; }
  /* solid band behind the header so the scrolling menu passes under it */
  .menu-open .sidebar::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: 112px;
    background: var(--bg);
    z-index: 25;
  }

  .main { padding: calc(18px + 34px * 2 + 30px) var(--pad) 0; }
  .footer { padding: 40px var(--pad) var(--pad); }

  /* Phone: a left-aligned label block, like writing on a film sleeve —
     TITLE · YEAR on one line, camera + stock beneath, then the places. */
  /* Title large, year set apart on the right, a hairline (like the sidebar's),
     then camera and places as small quiet captions. */
  .album-meta {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    row-gap: 0;
    text-align: left;
  }
  .album-meta .caption:nth-child(1) {
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--ink);
  }
  .album-meta .caption:nth-child(2) { font-size: 11px; text-align: right; }
  .album-meta .caption:nth-child(3) {
    grid-column: 1 / -1;
    margin-top: calc(var(--u) * 1.5);
    padding-top: calc(var(--u) * 1.5);
    border-top: 1px solid var(--rule);
    font-size: var(--small);
  }
  .album-meta .caption:empty { display: none; }
  .album-location {
    height: auto;
    justify-content: flex-start;
    text-align: left;
    padding: calc(var(--u) * 0.5) 0 calc(var(--u) * 3);
    color: var(--ink-muted);
    font-size: var(--small);
    line-height: 1.2;
  }
  .gallery { grid-template-columns: 1fr; gap: var(--pad); }
  .gallery .col { gap: var(--pad); }

  /* phones: fill the space between header and copyright; photo centred in it */
  .slideshow { height: calc(100svh - 116px - 44px); min-height: 320px; }
  .slideshow a, .slideshow a.is-landscape { align-items: center; justify-content: center; }
  .nav-copyright { display: none; }   /* phones keep it at the foot of the page */
  .home .footer { padding-top: 16px; }

  .about { grid-template-columns: 1fr; row-gap: calc(var(--u) * 3); }
  .about-image, .about-text, .about-details { grid-column: 1; padding-right: 0; }
  .about-text { margin-top: 0; }
  .about { margin-top: 0; }
  .contact { grid-template-columns: 1fr; row-gap: calc(var(--u) * 5); }
  .contact-form, .contact-details { grid-column: 1; }
  .contact-form { grid-template-columns: 1fr; }
  .about-portrait { width: 100%; height: auto; }


  .lightbox { padding: 10px; }
  .album-pager { margin: 56px 0 8px; }

  /* toggle sits beside the menu button on phones */
}

/* ── Notches / rounded corners ────────────────────────────────────────────────
   The page extends edge to edge (viewport-fit=cover) so its colour runs under
   phone toolbars; keep content clear of the notch when a phone is sideways. */
.sidebar { padding-left: max(var(--pad), env(safe-area-inset-left)); }
.main { padding-right: max(var(--pad), env(safe-area-inset-right)); }
