/* uczine.net — standalone rebuild of the Readymag site.

   Layout: one 8-column grid runs through every page. The wordmark, the
   content, the navigation and the gallery boxes all sit on its columns, and
   two hairline rules (under the header, above the navigation) show where the
   page's fixed parts end and its content begins.

   Type: two sizes only. --fs for everything you read, --fs-meta for the
   numbers, labels and imprint that sit beside it. No headings in a third
   size — position on the grid does that work instead.

   Every size is written in --u, one unit of the original 1024px-wide canvas
   (320px-wide on phones), so the page scales with the window the way the
   Readymag viewer did. */

:root {
  --u: max(1px, calc(100vw / 1024));
  --bg: #131212;
  --text: #a8b6e7;
  --text-dim: #7887ac;
  --link: #0080ff;
  --faint: rgba(225, 222, 219, 0.5);
  --line: rgba(168, 182, 231, 0.3);
  --edge: calc(30 * var(--u));
  --cols: 8;
  --fs: calc(10 * var(--u));
  --fs-meta: calc(8 * var(--u));
  --lh: calc(14 * var(--u));
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 400;
  font-size: var(--fs);
  line-height: var(--lh);
  letter-spacing: calc(-0.2 * var(--u));
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; }
img { display: block; }

/* blue text links: 1px underline that disappears on hover */
.link {
  color: var(--link);
  text-decoration: none;
  padding-bottom: 1px;
  background: linear-gradient(var(--link), var(--link)) 0 100% / 1px 1px repeat-x;
}
.link:hover { background: none; }

/* quiet text links (links page, about page) */
.plain {
  color: var(--text);
  text-decoration: none;
}
.plain:hover { color: var(--text-dim); }

/* the page you are on: not a destination, so no link colour and no underline —
   a filled square under the word marks it instead */
[aria-current] {
  position: relative;
  color: var(--text);
  background: none;
  cursor: default;
}
[aria-current]::after {
  content: "";
  position: absolute;
  left: 0;
  top: calc(100% + 3 * var(--u));
  width: calc(5 * var(--u));
  height: calc(5 * var(--u));
  background: currentColor;
}

a:focus-visible, button:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: calc(3 * var(--u));
}

/* ---------- header: identical on every page ---------- */

.site-header {
  flex: none;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-items: start;
  padding: calc(21 * var(--u)) var(--edge) calc(14 * var(--u));
  border-bottom: 1px solid var(--line);
}
.site-name {
  grid-column: 1 / 5;
  letter-spacing: 0;
  color: var(--text);
  text-decoration: none;
}
.site-id {
  grid-column: 5 / -1;
  justify-self: end;
  text-align: right;
}

/* ---------- main: flush left on the same grid ---------- */

.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 var(--edge);
}

/* home is the spinning mac and nothing else */
.home-gif {
  width: calc(120 * var(--u));
  height: calc(120 * var(--u));
  margin: auto;
  object-fit: contain;
}

.bio {
  margin-top: calc(90 * var(--u));
  white-space: pre-wrap;
}
.coords { margin-top: var(--lh); }
.about-head { margin-top: calc(2 * var(--lh)); }
.about-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* links page: one cell of the grid per link */
.cell-grid {
  list-style: none;
  margin: calc(90 * var(--u)) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  row-gap: var(--lh);
}
.cell-grid li { grid-column: span 2; min-width: 0; }

/* ---------- gallery: a sheet of ruled boxes, one work per box ---------- */

.gallery { --min-rows: 2; }

.gallery-bar {
  margin-top: calc(26 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.tabs { display: flex; gap: calc(22 * var(--u)); }
.pager {
  display: flex;
  align-items: baseline;
  gap: calc(12 * var(--u));
  font-variant-numeric: tabular-nums;
}
.pager[hidden] { display: none; }
.pager button {
  padding: 0 calc(4 * var(--u));
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}
.pager button:disabled { color: var(--text-dim); opacity: 0.4; cursor: default; }

.grid-frame {
  flex: 1 1 auto;
  margin-top: calc(16 * var(--u));
}
.grid {
  list-style: none;
  margin: 0;
  padding: 0 1px 1px 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.grid li {
  min-width: 0;
  margin: 0 -1px -1px 0;      /* neighbouring boxes share one line */
  border: 1px solid var(--line);
}
.tile {
  display: block;
  width: 100%;
  padding: calc(7 * var(--u));
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.tile:hover { background: rgba(168, 182, 231, 0.06); }
.tile:focus-visible { outline-offset: calc(-3 * var(--u)); }
.tile .pic {
  display: block;
  aspect-ratio: 113 / 105;
  overflow: hidden;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile.contain img { object-fit: contain; }
/* number + name of the work; the line keeps its height while names are empty */
.tile .cap {
  display: flex;
  gap: calc(6 * var(--u));
  margin-top: calc(7 * var(--u));
  font-size: var(--fs-meta);
  line-height: calc(12 * var(--u));
  height: calc(12 * var(--u));
}
.tile .no { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tile .ttl {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- navigation: identical on every page, always above the footer ---------- */

.site-nav {
  flex: none;
  margin-top: calc(30 * var(--u));
  padding: calc(14 * var(--u)) var(--edge) 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-items: baseline;
  border-top: 1px solid var(--line);
}
.site-nav a { justify-self: start; }
.site-nav .mail { grid-column: 1 / 3; }
.site-nav .n-home { grid-column: 3; }
.site-nav .n-about { grid-column: 4; }
.site-nav .n-gallery { grid-column: 5; }
.site-nav .n-links { grid-column: 6; }

/* ---------- footer ---------- */

.site-footer {
  flex: none;
  padding: calc(26 * var(--u)) var(--edge) calc(18 * var(--u));
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  font-size: var(--fs-meta);
  line-height: calc(10 * var(--u));
  color: var(--faint);
}
/* all three on one line: mark, imprint, mark */
.site-footer > * { grid-row: 1; }
.site-footer .l { grid-column: 1 / 3; }
.site-footer .r { grid-column: -3 / -1; text-align: right; }
/* the imprint, warez-NFO style: centred on the page, very small, grey */
.webzero {
  grid-column: 3 / 7;
  justify-self: center;
  white-space: nowrap;
  letter-spacing: calc(0.4 * var(--u));
}

/* ---------- detail box: image on the left, name / medium / text / links on the right ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--edge);
  background: rgba(0, 0, 0, 0.6);
}
.lightbox[hidden] { display: none; }
.viewer {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) calc(250 * var(--u));
  background: var(--bg);
  border: 1px solid var(--line);
}
.viewer-pic {
  min-height: 0;
  padding: calc(16 * var(--u));
}
.viewer-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.viewer-info {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: calc(16 * var(--u));
  border-left: 1px solid var(--line);
}
.viewer-no {
  color: var(--text-dim);
  font-size: var(--fs-meta);
  margin-right: calc(30 * var(--u));
}
.viewer-info dl { margin: calc(22 * var(--u)) 0; }
.viewer-info dt { color: var(--text-dim); font-size: var(--fs-meta); }
.viewer-info dd { margin: 0 0 calc(14 * var(--u)); overflow-wrap: anywhere; }
.viewer-info dd.empty { color: var(--text-dim); }
.viewer-info dd a { display: block; width: fit-content; margin-top: calc(3 * var(--u)); }
.viewer-nav {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: calc(12 * var(--u));
  font-variant-numeric: tabular-nums;
}
.viewer-nav button, .viewer-close {
  padding: 0 calc(4 * var(--u));
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}
.viewer-close {
  position: absolute;
  top: calc(12 * var(--u));
  right: calc(12 * var(--u));
  padding: calc(4 * var(--u));
  color: var(--text);
  line-height: 1;
}
body.lightbox-open { overflow: hidden; }

.visually-hidden {
  font: inherit;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- phones: the same grid, three columns wide ---------- */

@media (max-width: 700px) {
  :root {
    --u: clamp(1px, calc(100vw / 320), 1.5px);
    --edge: calc(20 * var(--u));
    --cols: 3;
    --fs: calc(9 * var(--u));
    --fs-meta: calc(7.5 * var(--u));
    --lh: calc(13 * var(--u));
  }

  .site-header { padding-top: calc(15 * var(--u)); }
  .site-name { grid-column: 1 / 3; }
  .site-id { grid-column: 3; }

  .home-gif { width: calc(110 * var(--u)); height: calc(110 * var(--u)); }
  .bio { margin-top: calc(50 * var(--u)); }
  .cell-grid { margin-top: calc(50 * var(--u)); }
  .cell-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell-grid li { grid-column: span 1; }

  .gallery { --min-rows: 3; }
  .tile { padding: calc(5 * var(--u)); }
  .tile .cap { margin-top: calc(5 * var(--u)); }

  /* mail on its own row, then the four pages across the grid */
  .site-nav {
    margin-top: calc(24 * var(--u));
    grid-template-columns: repeat(4, minmax(0, 1fr));
    row-gap: calc(16 * var(--u));
  }
  .site-nav .mail { grid-column: 1 / -1; }
  .site-nav .n-home { grid-column: 1; }
  .site-nav .n-about { grid-column: 2; }
  .site-nav .n-gallery { grid-column: 3; }
  .site-nav .n-links { grid-column: 4; }

  .site-footer { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer .l { grid-column: 1; }
  .site-footer .r { grid-column: 3; }
  /* no letter-spacing here: the three footer items only just clear each other */
  .webzero { grid-column: 2; letter-spacing: 0; }

  .viewer {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .viewer-pic { padding: calc(30 * var(--u)) calc(10 * var(--u)) calc(10 * var(--u)); }
  .viewer-info {
    max-height: 45vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: calc(12 * var(--u));
  }
  .viewer-info dl { margin: calc(10 * var(--u)) 0; }
  .viewer-info dd { margin-bottom: calc(8 * var(--u)); }
  .viewer-nav { margin-top: calc(4 * var(--u)); }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
