/* ---------------------------------------------------------------
   mihirparekh.com
   Aileron by Sora Sagano (CC0) — self-hosted, see /fonts
--------------------------------------------------------------- */

@font-face {
  font-family: 'Aileron';
  src: url('/fonts/aileron-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('/fonts/aileron-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Aileron';
  src: url('/fonts/aileron-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}

/* ---------------------------------------------------------------
   tokens
--------------------------------------------------------------- */

:root {
  --bg:       #fdfdfc;
  --sunk:     #f1f0ec;   /* unselected pill */
  --sunk-hi:  #e7e5e0;   /* unselected pill, hover */
  --ink:      #14130f;   /* selected pill */
  --gray:     #6e6b64;
  --gray-dim: #a09c94;
  --rule:     #e8e5de;
  --orange:   #e2551b;

  --font: 'Aileron', ui-sans-serif, -apple-system, BlinkMacSystemFont,
          'Helvetica Neue', Arial, sans-serif;

  --measure: 38rem;
  --row: 250px;
  --rail: 13rem;        /* space reserved for the nav rail */
  --lb-panel-w: 15rem;  /* lightbox side columns */
  --lb-pair-gap: 2.25rem;
  --lb-pad-x: 3rem;
  --lb-pad-y: 3.5rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection { background: var(--orange); color: #fff; }

img { max-width: 100%; }

/* ---------------------------------------------------------------
   layout
--------------------------------------------------------------- */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 5rem 1.5rem 6rem;
}

/* the wide gallery column never slides under the rail */
.wrap--wide {
  max-width: min(78rem, calc(100vw - 2 * var(--rail)));
}

/* ---------------------------------------------------------------
   links
--------------------------------------------------------------- */

a { color: inherit; text-decoration: none; transition: color .13s ease; }

.prose a {
  box-shadow: inset 0 -1px 0 var(--rule);
  transition: color .13s ease, box-shadow .13s ease;
}

.prose a:hover {
  color: var(--orange);
  box-shadow: inset 0 -1px 0 var(--orange);
}

a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------------------------------------------------------------
   nav rail — floats in the left margin, pills like a segmented control
--------------------------------------------------------------- */

.rail {
  position: fixed;
  top: 5rem;
  left: 2.25rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;      /* matches the rhythm of the filter rows */
}

.pill {
  display: inline-block;
  font-size: .8125rem;
  line-height: 1.35;
  color: var(--gray);
  background: var(--sunk);
  padding: .38rem .8rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: background-color .14s ease, color .14s ease;
}

.pill:hover { background: var(--sunk-hi); color: var(--ink); }

.pill[aria-current='page'] {
  background: var(--ink);
  color: var(--bg);
}

.pill[aria-current='page']:hover { background: var(--ink); }

/* ---------------------------------------------------------------
   home
--------------------------------------------------------------- */

/* name, date and body all set at the same size — only weight and colour differ */
.name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.6;
  margin: 0;
  letter-spacing: -0.003em;
}

.stamp {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray-dim);
  margin: 0 0 2.25rem;
}

.prose p { margin: 0 0 1.15rem; }
.prose p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------
   gallery page head
--------------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
}

.page-head p {
  margin: 0;
  color: var(--gray);
  font-size: .875rem;
}

/* ---------------------------------------------------------------
   filters
--------------------------------------------------------------- */

.filters {
  border-top: 1px solid var(--rule);
  padding-top: 1.1rem;
  margin-bottom: 1.75rem;
}

/* the same rule, for a gallery with nothing to filter by */
.page-line {
  border-top: 1px solid var(--rule);
  margin-bottom: 1.75rem;
}

/* one rule, not two, if a filter bar is present */
.filters:not([hidden]) + .page-line,
.page-line + .filters:not([hidden]) { border-top: 0; }

/* [hidden] loses to a later display:flex on .filters (mobile). */
.filters[hidden] { display: none; }

/* label in a fixed gutter, chips in their own column — wrapped rows stay
   flush with the first chip instead of sliding back under the label */
.facet {
  display: flex;
  align-items: baseline;
  margin-bottom: .55rem;
}

.facet__label {
  font-size: .6875rem;
  line-height: 1.9;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-dim);
  width: 5.25rem;
  flex: none;
}

.facet__track {
  flex: 1 1 auto;
  min-width: 0;
}

.facet__chips {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .45rem;

  /* one line deep until opened — the row height is chip + a hair */
  max-height: 1.95rem;
  overflow: hidden;
}

.facet__veil { display: none; }

.facet__chips.is-open {
  max-height: none;
  overflow: visible;
}

.facet__more {
  flex: none;
  align-self: flex-start;
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.35;
  padding: .34rem .6rem;
  margin-left: .4rem;
  background: var(--sunk);
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: .06em;
  transition: color .13s ease, background-color .13s ease;
}

.facet__more:hover { color: var(--bg); background: var(--ink); }
.facet__more[hidden] { display: none; }

.chip {
  font: inherit;
  font-size: .8125rem;
  line-height: 1.35;
  color: var(--gray);
  background: var(--sunk);
  border: 0;
  border-radius: 999px;
  padding: .34rem .75rem;
  cursor: pointer;
  transition: color .13s ease, background-color .13s ease;
}

.chip:hover { color: var(--ink); background: var(--sunk-hi); }

.chip[aria-pressed='true'] {
  color: var(--bg);
  background: var(--ink);
}

.chip[aria-pressed='true']:hover { background: var(--ink); }

.chip__n { color: var(--gray-dim); font-size: .75rem; margin-left: .3rem; }
.chip[aria-pressed='true'] .chip__n { color: rgba(255,255,255,.6); }

.filters__foot {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-top: .85rem;
  font-size: .8125rem;
  color: var(--gray-dim);
}

.filters__toggle { display: none; }
.filters__picked { display: none; }

.clear {
  font: inherit;
  font-size: .8125rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--orange);
  cursor: pointer;
}

.clear:hover { text-decoration: underline; }
.clear[hidden] { display: none; }

/* ---------------------------------------------------------------
   justified grid
--------------------------------------------------------------- */

.grid { display: flex; flex-wrap: wrap; gap: 6px; }

.grid::after { content: ''; flex-grow: 999999; }

.grid figure {
  margin: 0;
  position: relative;
  height: var(--row);
  flex-grow: 1;
}

.grid button.shot {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--sunk);
  cursor: zoom-in;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .18s ease;
}

.grid button.shot:hover img { opacity: .8; }

.grid button.shot:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.grid figure[hidden] { display: none; }

.meta-peek {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.5rem .6rem .45rem;
  font-size: .75rem;
  color: #fff;
  text-align: left;
  background: linear-gradient(to top, rgba(0,0,0,.58), transparent);
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}

.grid figure:hover .meta-peek { opacity: 1; }

.empty { color: var(--gray); font-size: .875rem; padding: 2rem 0; }

/* Illustration is a 3-across board, not a justified photo strip.
   Each cell shows the whole drawing and the crushed series lands
   as two full rows: Part 1, then Part 2. */
.grid--illustration {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.grid--illustration::after { display: none; }

.grid--illustration figure {
  height: auto;
  flex-grow: 0;
}

.grid--illustration button.shot { height: auto; }

.grid--illustration img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ---------------------------------------------------------------
   lightbox
--------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg);
  padding: 3.5rem 1.25rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  /* vertical scroll only — pinch is handled in JS and snaps back */
  touch-action: pan-y;
}

.lightbox.is-open { display: flex; }

.lb-stage {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
}

.lb-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  width: 100%;
  min-width: 0;
}

.lb-frame {
  display: block;
  width: 100%;
  min-width: 0;
  line-height: 0;
  text-align: center;
}

.lightbox img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 9.5rem);
  max-height: calc(100svh - 9.5rem);
  margin-inline: auto;
  object-fit: contain;
  transition: filter .22s ease, transform .22s ease;
  touch-action: pan-y;
  transform-origin: center center;
}

/* the cached thumbnail standing in until the full file lands */
.lightbox img.is-loading { filter: blur(1.5px); }
.lightbox img.is-error { opacity: .45; }

.lb-miss {
  margin: .35rem 0 0;
  color: var(--gray-dim);
  font-weight: 400;
}

/* --- the settings panel, set like the about page --- */

.lb-panel {
  width: min(100%, var(--lb-media-w, 100%));
  padding-top: 0;
  padding-bottom: 1.5rem;
  min-width: 0;
  overflow: visible;
  font-size: .8125rem;        /* the site's UI size, as on the chips and rail */
  line-height: 1.75;
  color: var(--ink);
}

.lb-head { margin-bottom: 1.1rem; }

.lb-head h2 {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0;
}

.lb-medium {
  display: block;
  margin: .15rem 0 0;
  font-weight: 400;
  color: var(--gray);
}

.lb-place { margin: 0; color: var(--ink); }
.lb-when  { margin: 0; color: var(--gray-dim); }

.lb-list { margin: 0; }

.lb-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.lb-row dt {
  color: var(--gray);
  flex: none;
}

.lb-row dd {
  margin: 0;
  color: var(--ink);
  text-align: right;
  flex: 1 1 auto;
  min-width: 4rem;
  overflow-wrap: break-word;
}

.lb-rule {
  border-top: 1px solid var(--rule);
  margin: 1.1rem 0;
}

.lightbox button {
  position: absolute;
  background: none;
  border: 0;
  color: var(--gray-dim);
  font-family: var(--font);
  cursor: pointer;
  line-height: 1;
  transition: color .13s ease;
  min-width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  /* Safari paints a default cyan focus rectangle on the 44×44 hit area
     when the dialog opens. Kill every outline; keyboard users still get
     the colour change below. */
  outline: none;
}

.lightbox button:hover { color: var(--orange); }

.lightbox:focus,
.lightbox button:focus,
.lightbox button:focus-visible {
  outline: none;
}

.lightbox button:focus-visible { color: var(--orange); }

.lb-close { top: .45rem; right: .85rem; font-size: 1.75rem; }
.lb-prev  { display: none; left: .4rem;  top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-next  { display: none; right: .4rem; top: 50%; transform: translateY(-50%); font-size: 2rem; }

/* Desktop: image stays in the middle of the window. An empty
   left column matches the caption so landscapes can't run under it. */
@media (min-width: 1024px) {
  .lightbox {
    align-items: center;
    padding: var(--lb-pad-y) var(--lb-pad-x);
    overflow: hidden;
  }

  .lb-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
  }

  .lb-pair {
    display: grid;
    grid-template-columns: var(--lb-panel-w) auto var(--lb-panel-w);
    column-gap: var(--lb-pair-gap);
    align-items: start;
    justify-content: center;
    width: max-content;
    max-width: 100%;
  }

  .lb-pair::before { content: ''; }

  .lb-frame { width: auto; }

  .lightbox img {
    max-width: calc(100vw - 2 * var(--lb-panel-w) - 2 * var(--lb-pair-gap) - 2 * var(--lb-pad-x));
    max-height: calc(100vh - 2 * var(--lb-pad-y));
    max-height: calc(100dvh - 2 * var(--lb-pad-y));
  }

  .lb-panel {
    width: var(--lb-panel-w);
    padding-bottom: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .lb-close { top: .9rem; right: 1rem; }
  .lb-prev, .lb-next { display: block; }
}

/* ---------------------------------------------------------------
   narrow — rail becomes a scrollable pill row above the content
--------------------------------------------------------------- */

@media (max-width: 1200px) {
  :root {
    --lb-panel-w: 12.5rem;
    --lb-pair-gap: 1.5rem;
    --lb-pad-x: 1.5rem;
  }
}

@media (max-width: 1023px) {
  .wrap--wide { max-width: 100%; }

  .rail {
    position: sticky;
    top: 0;
    left: auto;
    flex-direction: row;
    gap: .3rem;
    padding: .75rem 1.25rem;
    margin: 0;
    background: var(--bg);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .rail::-webkit-scrollbar { display: none; }

  .pill { padding: .45rem .9rem; }

  .wrap { padding-top: 1.5rem; }
}

@media (max-width: 700px) {
  body { font-size: 15.5px; }

  .wrap { padding: 1.25rem 1.25rem 4rem; }

  /* One line: count + Filter. The four facet rows stay in a drawer
     until you ask for them; selected chips sit under the title. */
  .filters {
    display: flex;
    flex-direction: column;
    padding-top: .85rem;
    margin-bottom: 1.25rem;
  }

  .filters__picked {
    display: flex;
    order: 0;
    flex-wrap: nowrap;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 .75rem;
    padding-right: 1.5rem;
  }

  .filters__picked::-webkit-scrollbar { display: none; }
  .filters__picked[hidden] { display: none; }
  .filters__picked .chip { flex: none; }

  .filters__foot {
    order: 1;
    justify-content: space-between;
    margin-top: 0;
    margin-bottom: 0;
  }

  .filters__toggle {
    display: inline;
    font: inherit;
    font-size: .8125rem;
    background: none;
    border: 0;
    padding: 0;
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .filters__toggle[aria-expanded='true'] { color: var(--orange); }

  .clear { display: none; }

  .filters__body {
    display: none;
    order: 2;
    padding-top: 1rem;
  }

  .filters.is-open .filters__body { display: block; }

  /* Label above, chips below. The old rule gave the label width:100% inside a
     flex row, which squeezed the chip column to nothing — and since the column
     clips its overflow, the chips vanished entirely. */
  .facet {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 1rem;
  }

  .facet__label {
    width: auto;
    line-height: 1.4;
    margin-bottom: .4rem;
  }

  /* one swipeable row rather than a stack of them. Bleed to the screen
     edge so a cut-off chip reads as overflow, not as page padding. */
  .facet__track {
    position: relative;
    min-width: 0;
    margin-right: -1.25rem;
  }

  .facet__chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-height: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .1rem;
    padding-right: 2rem;
    position: relative;
    z-index: 0;
  }

  .facet__chips::-webkit-scrollbar { display: none; }
  .facet__chips > .chip { flex: none; }
  .facet__more { display: none; }     /* scrolling replaces it */

  /* Veil sits on the visible edge of the track, not on the scroll
     strip — a mask on the scroller only fades the far end of the
     content, which you never see until you're already there. */
  .facet__veil {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity .18s ease;
    transform: translateZ(0);
  }

  .facet__veil--right {
    right: 0;
    width: 30%;
    background: linear-gradient(
      to right,
      rgb(253 253 252 / 0) 0%,
      rgb(253 253 252 / .72) 32%,
      var(--bg) 70%,
      var(--bg) 100%
    );
  }

  .facet__veil--left {
    left: 0;
    width: 16%;
    background: linear-gradient(to right, var(--bg), rgb(253 253 252 / 0));
  }

  .facet.fade-right .facet__veil--right { opacity: 1; }
  .facet.fade-left  .facet__veil--left  { opacity: 1; }

  .chip { padding: .38rem .75rem; }   /* comfortable tap target */

  .page-head { display: block; }
  .page-head p { margin-top: .3rem; }

  /* Two columns of whole pictures instead of justified rows. A justified row
     keeps a fixed height and crops to fit; with only one or two frames per row
     that crop is severe, which is what was slicing the portraits and squaring
     off the illustrations. */
  .grid {
    display: block;
    columns: 2;
    column-gap: 6px;
  }

  .grid::after { display: none; }

  .grid figure {
    display: inline-block;
    width: 100%;
    height: auto;
    margin: 0 0 6px;
    break-inside: avoid;
  }

  .grid button.shot { height: auto; }

  .grid img {
    height: auto;
    object-fit: contain;   /* nothing cropped */
  }

  .grid--illustration {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .grid--illustration figure {
    display: block;
    width: auto;
    margin: 0;
  }

  .meta-peek { opacity: 1; font-size: .7rem; }   /* no hover on touch */

  /* Illustrations: the name is in the lightbox. Don't cover the tile. */
  .grid--illustration .meta-peek { display: none; }
}


@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
