/* ============================================================
   STYLE.CSS  —  how everything looks.
   The numbers come from the desktop mockups (1403 px wide).
   1vw = 1% of the window width, so the layout scales as a whole.
   ============================================================ */

@font-face {
  font-family: "Kosugi";
  src: url("font/Kosugi-latin.woff") format("woff");
  unicode-range: U+0000-04FF, U+2000-22FF;
  font-display: swap;
}
/* everything else (such as Japanese): only downloaded if the page uses it */
@font-face {
  font-family: "Kosugi";
  src: url("font/Kosugi-full.woff") format("woff");
  unicode-range: U+0500-1FFF, U+2300-FFFF;
  font-display: swap;
}

/* ---------- Measurements: change these to adjust the whole site ---------- */
:root {
  --veil: rgba(255, 255, 255, 0.93);       /* 93% opaque overlays */
  --gap: 0.75vw;                           /* outer margin AND space between columns */
  --left: calc(25vw + var(--gap));         /* where column 1 starts */
  --col: calc((75vw - 7 * var(--gap)) / 6);/* width of one of the 6 columns */
  --three: calc(3 * var(--col) + 2 * var(--gap));
  --five: calc(5 * var(--col) + 4 * var(--gap));
  --six: calc(6 * var(--col) + 5 * var(--gap));
  --col4: calc(var(--left) + var(--three) + var(--gap)); /* where column 4 starts */
  --top: 1.45vw;                           /* top of the first row of images */
  --bottom: 1.7vw;                         /* bottom of quick view images */
  --body: max(11px, 0.8vw);
  --caption: max(8.5px, 0.571vw);
  --lift: max(2.05vw, 2.6 * var(--body));  /* buttons to thumbnails; "email copied" fits between */
  /* room kept under a series image so its text always fits on one screen */
  --reserve: max(13.6vw, 190px);
  /* THE shared line: series text and quick view thumbnails/about start here */
  --slot: min(calc(var(--top) + var(--six) / 2.0066 + var(--gap)), calc(100vh - var(--reserve)));
}

/* ---------- Basics ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-y: scroll; }
html.locked { overflow: hidden; }
body { font: var(--body)/1.2 "Kosugi", monospace; color: #111; background: #fff; }
h1, h2 { font: inherit; }
ul { list-style: none; }
img { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
/* underline: only under the pointer, or in the menu while that overlay is open */
a, button { text-underline-offset: 0.2em; }
.menu a.active { text-decoration: underline; }
@media (hover: hover) {
  a:hover, button:hover, .card:hover i { text-decoration: underline; }
  .card:hover { text-decoration: none; }
}
:focus-visible { outline: 1px solid #111; outline-offset: 2px; }

/* ---------- Name, menu, close ---------- */
.top { position: fixed; z-index: 50; top: 0; left: 0; right: 0; height: 0; }
.top > * { position: absolute; top: 0.75vw; }
.name { left: var(--gap); }
.close { right: var(--gap); }
.menu-button { display: none; }
.menu { position: fixed; z-index: 30; top: calc(0.75vw + 2.4em); left: var(--gap); }
.menu-info { margin-top: 4.8em; }
.rights { position: fixed; z-index: 25; bottom: var(--gap); left: var(--gap); }

/* ---------- Work index ---------- */
.index {
  display: grid;
  grid-template-columns: repeat(6, var(--col));
  gap: 2.6vw var(--gap);
  padding: var(--top) var(--gap) calc(2 * 1.2 * var(--caption)) var(--left); /* bottom: two empty caption lines */
}
/* each card: picture sits on the bottom of a 5:4 (height:width) space */
.card { display: block; cursor: pointer; }
/* taller pictures are trimmed evenly, so all captions in a row start on one line */
.card-image { display: block; position: relative; overflow: hidden; aspect-ratio: 4 / 5; }
.card-image img { position: absolute; left: 0; bottom: 0; width: 100%; max-height: 100%; object-fit: cover; }
.card-caption { display: block; margin-top: 0.75vw; font-size: var(--caption); overflow-wrap: anywhere; }
/* fade up while scrolling */
.card { transition: opacity 0.6s, transform 0.6s; }
.card.waiting { opacity: 0; transform: translateY(16px); }

/* ---------- Layers ---------- */
.layer { position: fixed; inset: 0; background: var(--veil); animation: fade 0.3s; }
@keyframes fade { from { opacity: 0; } }
.layer-series { z-index: 20; }
.layer-work { z-index: 21; }
.layer-information, .layer-cv { z-index: 40; overflow-y: auto; }

/* ---------- Series introductions ---------- */
.series-image {
  position: absolute; left: var(--left); top: var(--top);
  width: var(--six); height: calc(var(--slot) - var(--top) - var(--gap)); object-fit: cover;
}
.series-pictured { position: absolute; left: var(--left); top: var(--slot); width: var(--three); }
.series-text { position: absolute; left: var(--col4); top: var(--slot); width: var(--three); }
.series-select { display: inline-block; margin-top: 2.4em; }

/* ---------- Quick view ---------- */
.work-image {
  position: absolute; left: var(--left); bottom: var(--bottom); width: var(--three);
  cursor: zoom-in;
}
/* never taller than 5:4 or than the window; anything extra is trimmed evenly */
.work-image.playing { cursor: pointer; }
.work-image video { aspect-ratio: 4 / 5; } /* holds its space while loading */
.work-image img, .work-image video {
  display: block;
  width: 100%; object-fit: cover;
  max-height: min(calc(var(--three) * 1.25), calc(100vh - var(--bottom) - 2.6vw));
}
.work-text > * { position: absolute; left: var(--col4); }
.work-caption { top: calc(var(--slot) - max(7.9vw, var(--lift) + 6 * 1.2 * var(--body))); width: var(--three); }
.work-buttons { top: calc(var(--slot) - var(--lift)); display: flex; gap: var(--gap); white-space: nowrap; }
/* arrows: side by side at the right margin; the space between them is the
   same as the margin. Padding only makes them easier to click. */
.work-arrows { top: calc(var(--slot) - var(--lift) - 0.45vw); left: auto !important; right: 0; display: flex; --edge: var(--gap); }
.work-arrows button { padding: 0.4vw calc(var(--edge) / 2); }
.work-arrows .arrow-prev { padding-left: var(--edge); }
.work-arrows .arrow-next { padding-right: var(--edge); }
.work-arrows svg { display: block; height: 1.4vw; fill: none; stroke: #111; stroke-width: 1.2; overflow: visible; }
.work-strip, .work-about { top: var(--slot); width: var(--three); }
.work-about p + p { margin-top: 1.2em; }
/* one line of 9 thumbnails; with more than 9 the line slides between its start and its end */
.work-strip { display: flex; gap: var(--gap); overflow-x: auto; scrollbar-width: none; }
.work-strip::-webkit-scrollbar { display: none; }
.work-strip button { flex: 0 0 calc((100% - 8 * var(--gap)) / 9); }
/* a see-through white layer marks the picture that is showing (0.6 = 60%) */
.work-strip button { position: relative; }
.work-strip button.active::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.6); }
.work-strip img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }

/* ---------- Introduction ---------- */
.information-text { position: absolute; left: var(--gap); top: calc(0.75vw + 2.4em); width: calc(25vw - 2 * var(--gap)); padding-bottom: 2em; }
.information-text p + p { margin-top: 1.2em; }
.copy-email { display: block; height: 1.2em; } /* a line of its own, evenly spaced */
.information-links { position: absolute; left: var(--left); top: calc(0.75vw + 2.4em); }

/* ---------- CV ---------- */
.cv {
  display: grid; grid-template-columns: calc(25vw - var(--gap)) 1fr; row-gap: 3.6em; column-gap: var(--gap);
  padding: calc(0.75vw + 2.4em) var(--gap) 4em;
}
.cv p + p { margin-top: 1.2em; }
.cv-link { overflow-wrap: anywhere; }

/* ---------- Zoom ---------- */
/* desktop: from the left of column 1 to the right of column 5 */
.zoom {
  position: fixed; z-index: 60; left: var(--left); top: 0; bottom: 0; width: var(--five);
  overflow: auto; scrollbar-width: none; cursor: grab; animation: fade 0.2s;
}
.zoom:active { cursor: grabbing; }
.zoom::-webkit-scrollbar { display: none; }
.zoom { display: flex; flex-direction: column; }
.zoom img { flex-shrink: 0; align-self: flex-start; margin-top: auto; user-select: none; -webkit-user-select: none; } /* short images sit at the bottom */

/* ---------- "email copied" (script.js places it beside the link) ---------- */
.message { position: fixed; z-index: 70; opacity: 0; white-space: nowrap; pointer-events: none; }
.message.show { animation: pulse 0.99s ease-in-out; } /* same time as PULSE in script.js */
@keyframes pulse { 0%, 100% { opacity: 0; } 21%, 51.5% { opacity: 1; } }

/* ---------- Smaller desktops: more text lines, so keep more room ---------- */
@media (min-width: 1000px) and (max-width: 1250px) {
  :root { --reserve: 225px; }
}

/* ============================================================
   TABLET AND PHONE: menu becomes a drop-down.
   Tablet: 4 columns. Phone: 3 columns.
   ============================================================ */
@media (max-width: 999px) {
  :root {
    --n: 4;
    --gap: 10px; --left: 14px; --body: 13px; --caption: 8.5px;
    --col: calc((100vw - 2 * var(--left) - (var(--n) - 1) * var(--gap)) / var(--n));
    --three: calc(3 * var(--col) + 2 * var(--gap));
    --head: calc(14px + 2.4 * var(--body)); /* name, then one empty line, as on desktop */
  }
  .top { height: var(--head); background: #fff; }
  .top > * { top: 0; padding: 14px 0; }
  .name { left: var(--left); }
  .close, .menu-button { display: block; right: var(--left); }
  /* on a layer the header lets the layer show through */
  body.layered .top { background: none; }

  .menu { display: none; z-index: 45; top: var(--head); left: 0; right: 0; padding: 0 var(--left); }
  body.menu-open .menu { display: grid; grid-template-columns: 1fr 1fr; }
  body.menu-open::before { content: ""; position: fixed; inset: 0; z-index: 15; background: var(--veil); }
  .menu-info { margin: 0; }
  .rights { display: none; }

  .index { grid-template-columns: repeat(var(--n), var(--col)); gap: 22px var(--gap); padding: var(--head) var(--left) calc(2 * 1.2 * var(--caption)); }
  .card-caption { margin-top: 6px; }

  .layer { overflow-y: auto; padding: var(--head) var(--left) 32px; }

  .layer-series { padding-top: calc(var(--head) + 7.2 * var(--body)); } /* 5 menu lines + 1 empty */
  .series > *, .work-text > *, .work-image, .information-text, .information-links { position: static; width: auto; }
  .series-image { width: 100%; height: auto; }
  .series-pictured { margin-top: 10px; }
  .series-text { margin-top: 2.4em; }

  /* quick view: image on top, text directly under it */
  /* the picture is as large as it can be while the caption, buttons and line of
     thumbnails still fit on the screen. script.js measures --text-room (the space
     they need) and --ratio (the picture's height / width, at most 1.25).
     The space for the picture (--tall) is the same for every picture of a work, so
     the text never moves; the picture sits in the middle of it. */
  .work-image { display: flex; align-items: center; justify-content: center; width: 100%; height: var(--tall);
    --tall: min((100vw - 2 * var(--left)) * 1.25, var(--room));
    pointer-events: none; /* the empty space around the picture closes the quick view */
    --room: max(120px, calc(100vh - var(--head) - 14px - var(--text-room, 220px) - var(--left))); }
  .work-image img, .work-image video { pointer-events: auto; max-height: none; flex: none;
    width: min(100%, var(--tall) / var(--ratio, 1.25)); aspect-ratio: 1 / var(--ratio, 1.25); }
  @supports (height: 100dvh) { /* phones: without the part under the browser bar */
    .work-image { --room: max(120px, calc(100dvh - var(--head) - 14px - var(--text-room, 220px) - var(--left))); }
  }
  .work-text { position: relative; width: 100%; margin-top: 14px; }
  .work-caption { padding-right: 110px; min-height: 3.6em; }
  .work-arrows { position: absolute; top: -8px; right: calc(-1 * var(--left)); --edge: var(--left); }
  .work-arrows button { padding-top: 11px; padding-bottom: 11px; }
  .work-arrows svg { height: 22px; }
  .work-buttons { display: flex; gap: var(--left); margin-top: 14px; }
  .work-strip, .work-about { margin-top: 14px; }
  .layer-work { padding-bottom: var(--left); }
  .work-buttons > * { padding: 8px 0; }
  .work-text, .work-strip, .work-about { width: 100%; }
  .work-strip { --gap: 6px; }

  .information-text { padding: 0 0 2em; }
  .layer-cv { padding: 0; }
  .cv { grid-template-columns: 22% 1fr; column-gap: 10px; padding: var(--head) var(--left) 40px; }
  body.cv-open .top { background: #fff; }

  /* zoom fills the screen; pinch and drag are handled in script.js */
  .zoom { left: 0; width: 100%; background: #fff; overflow: hidden; touch-action: none; align-items: center; justify-content: center; }
  .zoom img { align-self: center; margin: 0; max-width: 100%; max-height: 100%; transform-origin: center; }
}
/* tablet introduction: easier line length */
@media (min-width: 700px) and (max-width: 999px) {
  .information-text { max-width: var(--three); }
  .work-text { max-width: var(--three); }
  .series-text { max-width: var(--three); }
}
@media (max-width: 699px) {
  :root { --n: 3; --body: 12px; --caption: 8.5px; }
}

/* ---------- 404 page ---------- */
.not-found .rights { display: block; }
.not-found .layer { animation: none; }
@media (max-width: 999px) {
  .not-found .rights { left: var(--left); bottom: var(--left); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .message.show { opacity: 1; }
}
