/* Sometype Mono Regular, hosted in /fonts (SIL Open Font License) */
@font-face {
  font-family: "Sometype Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/sometype-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Sometype Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/sometype-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Fonts. Change either line to restyle the site name or the other text. */
  --font-name: "Sometype Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-text: "Sometype Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Background. Swap in any of these, or your own:
       warm grey, quiet   #e9e6e0
       warm grey, richer  #e2ddd4
       sand               #ddd5c8
       soft clay          #d9cfc4
       sage grey          #dcdfd7
       pale blue grey     #dde1e4
     Keep it light and low in colour so your photos stay accurate. */
  --bg: #e9e6e0;
  --ink: #1d1b18;
  --muted: #67625a;
  --select: #c9b79f; /* colour of highlighted text, a few shades darker than the background */
  --header: 3.5rem;
  --gutter: 1.25rem;
  --side: 15rem;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.8125rem/1.55 var(--font-text);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a { color: inherit; text-decoration: none; }
a:hover, .link:hover { opacity: 0.55; }

a:focus-visible, .link:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.site-name {
  font-family: var(--font-name);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Mobile header and index overlay */
.site-header {
  flex: none;
  height: var(--header);
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-header nav { display: flex; gap: 1.5rem; }
.site-header nav [aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

.index-panel {
  position: fixed;
  z-index: 10;
  inset: calc(var(--header) + env(safe-area-inset-top)) 0 0 0;
  background: var(--bg);
  padding: 2rem var(--gutter);
  overflow: auto;
}
.index-panel[hidden] { display: none; }
.index-panel ul { list-style: none; margin: 0; padding: 0; max-width: 40rem; }
.index-panel li { display: flex; align-items: baseline; gap: 1rem; padding: 0.3rem 0; }
.index-panel a { font-size: 1.125rem; }
.index-panel [aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }
.index-panel .meta { color: var(--muted); font-size: 0.75rem; }

/* Desktop sidebar (hidden on small screens) */
.sidebar { display: none; }

/* Main area and viewer */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.viewer-top {
  flex: none;
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--gutter);
  font-size: 0.75rem;
}
.top-left { display: flex; align-items: center; min-width: 0; }
.controls { display: flex; align-items: center; gap: 0.5rem; }
.controls .slash { color: var(--muted); }
.count { margin-left: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.grid-title { display: none; color: var(--muted); }

.grid-toggle { display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; }
.grid-toggle[hidden] { display: none; }

.stage { flex: 1; min-height: 0; position: relative; }

.frame {
  position: absolute;
  inset: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.frame img {
  display: block;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.frame.spread img { max-width: calc(50% - 0.5rem); }

.zone { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 2; }
.zone-prev { left: 0; cursor: url("../cursors/prev.svg") 18 18, w-resize; }
.zone-next { right: 0; cursor: url("../cursors/next.svg") 18 18, e-resize; }

.caption {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  padding: 0.875rem var(--gutter);
  font-size: 0.75rem;
  color: var(--muted);
}
.caption a { color: var(--ink); }

/* Grid of all images */
.grid { display: none; }

.is-grid .controls { display: none; }
.is-grid .grid-title { display: block; }
.is-grid .stage, .is-grid .caption { display: none; }
.is-grid .grid {
  display: grid;
  flex: 1;
  min-height: 0;
  overflow: auto;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  grid-auto-rows: max-content; /* rows keep their full height and the grid scrolls, instead of squashing */
  gap: 0.75rem;
  align-content: start;
  padding: 0.5rem var(--gutter) 2rem;
}

.tile {
  display: block;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
  cursor: pointer;
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile:hover { opacity: 0.7; }
.tile:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

/* Text pages */
.text-page { padding: 3rem var(--gutter) 2rem; max-width: 36rem; }
.text-page p { margin: 0 0 1.5rem; line-height: 1.65; }
.text-page a { text-decoration: underline; text-underline-offset: 0.25em; }

.notice { padding: 2rem var(--gutter); }

@media (min-width: 600px) {
  .is-grid .grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1.25rem; }
}

/* Desktop: index always visible on the left */
@media (min-width: 900px) {
  body {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .site-header, .index-panel { display: none !important; }

  .sidebar {
    display: flex;
    flex-direction: column;
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 var(--gutter) 1.25rem;
    font-size: 0.75rem;
    color: var(--muted);
  }
  .sidebar .site-name { display: flex; align-items: center; flex: none; height: var(--header); color: var(--ink); }
  .side-heading { margin: 1.25rem 0 0.6rem; color: var(--ink); text-decoration: underline; text-underline-offset: 0.35em; }
  .sidebar ul { list-style: none; margin: 0; padding: 0; }
  .sidebar li a { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.2rem 0; }
  .sidebar li a::before { content: ""; flex: none; width: 0.5rem; height: 1px; background: currentColor; transform: translateY(-0.25em); }
  .sidebar [aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 0.3em; }
  .side-info { display: inline-block; margin-top: 0.9rem; }
  .copyright { margin: auto 0 0; padding-top: 2rem; }

  main { grid-column: 2; grid-row: 1; }
  .text-page { padding-top: calc(var(--header) + 1.25rem); }
}

/* Highlighted text */
::selection { background: var(--select); color: var(--ink); }

/* Pointer: the classic arrow, drawn larger over anything clickable */
a, .link, .tile, .grid-toggle { cursor: url("../cursors/arrow-large.svg") 1 1, pointer; }

/* All cursors share one dark grey. The default arrow and the text cursor are drawn here too. */
body { cursor: url("../cursors/arrow.svg") 1 1, default; }
.text-page p, .caption { cursor: url("../cursors/ibeam.svg") 8 12, text; }
