/* hamkke.us from build 4: a small publishing house's front page. Warm paper and ink with one seal
   red, a serif for names and titles, Plex for reading and Plex Mono for labels. The logo is the slim
   grey mark with no background (build 9).

   Light and dark (build 6, the user's word: "fade from black to white based on the back ground"): on
   the home page the site follows the photo behind it, light while a bright one holds and dark while a
   dark one does (by measured brightness, of the heroes behind the page since build 10, 2102, 0436
   and 0784 are dark). --dark carries the paper
   colours across during the photo's 2.5s crossfade; --text flips the words' colours at the point where
   both read equally, so they're never grey on grey. With reduced motion, on the 404 page and where
   :has isn't supported, light and dark follow the system as before. */
@property --dark { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --text { syntax: "<integer>"; inherits: true; initial-value: 0; }   /* an integer jumps rather than fades */

:root {
  --paper: color-mix(in srgb, #141311 calc(var(--dark) * 100%), #f5f2eb);
  --raised: color-mix(in srgb, #1e1c19 calc(var(--dark) * 100%), #ece7dc);
  --line: color-mix(in srgb, #34302a calc(var(--dark) * 100%), #d9d2c4);
  --cover: color-mix(in srgb, #264d30 calc(var(--dark) * 100%), #2f5d3a);   /* Written Bear's cover: green since build 8 (the user's word) */
  --cover-ink: #f7efe6;
  --veil: color-mix(in srgb, rgb(20 19 17 / .9) calc(var(--dark) * 100%), rgb(245 242 235 / .92));        /* paper over the photos, where the header's words sit */
  --veil-thin: color-mix(in srgb, rgb(20 19 17 / .7) calc(var(--dark) * 100%), rgb(245 242 235 / .6));    /* ...and thinner toward the logo */
  --ink: color-mix(in srgb, #ede8de calc(var(--text) * 100%), #1b1a17);
  --muted: color-mix(in srgb, #a8a194 calc(var(--text) * 100%), #625e56);
  --seal: color-mix(in srgb, #e46a5e calc(var(--text) * 100%), #a3302a);
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 1200px;
  --serif: "Noto Serif KR", Georgia, "Apple SD Gothic Neo", serif;
  --sans: "IBM Plex Sans KR", system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root { --dark: 1; --text: 1; }
}

/* The backdrop's 80s, from its first photo (measured brightness out of 255 in brackets): 1480 (115)
   light; 2102 (29) dark, in 7.5–10s and out 17.5–20s; 0463 (101) and 2048 (96) light; 0436 (71) dark,
   in 37.5–40s and out 47.5–50s; 1474 (84) and 2226 (95) light; 0784 (62) dark, in 67.5–70s and out
   77.5–80s. It runs at an even pace, so the words can flip at once, halfway between each pair of
   --text keyframes, just where the paper is 56% of the way to dark and both colours of words read
   equally (1.4s into a fade to dark, 1.1s into a fade back). */
@keyframes theme {
  0%, 9.38% { --dark: 0; --text: 0; }
  10.88% { --text: 0; }
  11.38% { --text: 1; }
  12.5%, 21.88% { --dark: 1; }
  23% { --text: 1; }
  23.5% { --text: 0; }
  25%, 46.88% { --dark: 0; --text: 0; }
  48.38% { --text: 0; }
  48.88% { --text: 1; }
  50%, 59.38% { --dark: 1; }
  60.5% { --text: 1; }
  61% { --text: 0; }
  62.5%, 84.38% { --dark: 0; --text: 0; }
  85.88% { --text: 0; }
  86.38% { --text: 1; }
  87.5%, 96.88% { --dark: 1; }
  98% { --text: 1; }
  98.5% { --text: 0; }
  100% { --dark: 0; --text: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  :root:has(.backdrop) { animation: theme 80s linear infinite; }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 19px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 600px) {
  body { font-size: 18px; }
}

a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, p, figure { margin: 0; }

:focus-visible { outline: 3px solid var(--seal); outline-offset: 3px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.wrap { width: min(100% - 2 * var(--gutter), var(--measure)); margin-inline: auto; }

/* Small type */
.label { font: 400 16px/1.4 var(--mono); letter-spacing: .02em; color: var(--muted); }
.label b { font-weight: 500; color: var(--ink); }
.lede { font-size: clamp(21px, 2.1vw, 25px); line-height: 1.45; text-wrap: pretty; }

/* The small mark: the slim logo at 2:3, no background */
.tile { display: block; flex: none; width: 20px; height: 30px; }

/* Top bar */
.nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-block: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font: 600 21px/1 var(--serif); text-decoration: none; }
.nav ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 -12px 0 0; padding: 0; list-style: none; }
.nav li a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 4px; font-size: 17px; text-decoration: none; }
.nav li a:hover { background: var(--raised); }
.nav li a.nav-main { padding: 0 16px; border: 1.5px solid var(--ink); font-weight: 600; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 24px;
  border: 1.5px solid var(--ink); border-radius: 4px;
  background: var(--ink); color: var(--paper);
  font: 600 17px/1.2 var(--sans); text-decoration: none;
  transition: background .15s, color .15s;
}
.button:hover { background: transparent; color: var(--ink); }
.button.ghost { background: transparent; color: var(--ink); }
.button.ghost:hover { background: var(--ink); color: var(--paper); }

@media (max-width: 600px) {
  .actions { flex-direction: column; }
  .actions .button, .footer-links, .footer-links .button { width: 100%; }
}

/* The heroes behind the page: fixed and full-screen, eight photos, each held 10s then crossfading over
   2.5s into the next, around an 80s loop. The first is up at once; with reduced motion it simply stays. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--raised); }
.backdrop > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; animation: backdrop 80s infinite; }
.backdrop > :nth-child(1) { animation-delay: -2.5s; }
.backdrop > :nth-child(2) { animation-delay: 7.5s; }
.backdrop > :nth-child(3) { animation-delay: 17.5s; }
.backdrop > :nth-child(4) { animation-delay: 27.5s; }
.backdrop > :nth-child(5) { animation-delay: 37.5s; }
.backdrop > :nth-child(6) { animation-delay: 47.5s; }
.backdrop > :nth-child(7) { animation-delay: 57.5s; }
.backdrop > :nth-child(8) { animation-delay: 67.5s; }
@keyframes backdrop {
  0% { opacity: 0; }
  3.13% { opacity: 1; }
  12.5% { opacity: 1; }
  15.63% { opacity: 0; }
  100% { opacity: 0; }
}

/* The header sits on a paper veil, thick behind the words and thinner toward the logo */
header { background: linear-gradient(100deg, var(--veil) 0%, var(--veil) 48%, var(--veil-thin) 100%); }

@media (max-width: 720px) {
  header { background: linear-gradient(180deg, var(--veil) 0%, var(--veil) 66%, var(--veil-thin) 100%); }
}

/* A window: nothing but the photos behind the page, sliding past as it scrolls */
.window { height: clamp(240px, 33vw, 420px); }

/* Masthead */
.mast { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: clamp(32px, 6vw, 96px); padding-block: clamp(40px, 8vw, 104px) clamp(56px, 9vw, 120px); }
.mast h1 { margin: 18px 0 22px; font: 600 clamp(68px, 12.5vw, 172px)/.88 var(--serif); letter-spacing: -.04em; }
.mast-logo { display: grid; justify-items: center; }
.mast-mark { display: block; width: clamp(120px, 14vw, 180px); height: auto; aspect-ratio: 2 / 3; filter: drop-shadow(0 18px 24px rgb(0 0 0 / .2)); }

/* Phones: the name, its line and the buttons come first; the logo follows, small */
@media (max-width: 720px) {
  .mast { grid-template-columns: 1fr; gap: 40px; }
  .mast-logo { justify-items: start; }
  .mast-mark { width: 80px; }
}

/* Sections: solid paper over the photos */
.section { padding-block: clamp(64px, 10vw, 128px); border-top: 1px solid var(--line); background: var(--paper); }
.window + main > .section:first-child { border-top: 0; }
.section h2, .fold-body h2 { margin: 14px 0 18px; font: 600 clamp(38px, 5.4vw, 66px)/1.02 var(--serif); letter-spacing: -.025em; text-wrap: balance; }

/* Written Bear: the cover and the wings */
.book { display: grid; grid-template-columns: minmax(220px, 360px) minmax(0, 1fr); align-items: center; gap: clamp(36px, 8vw, 120px); }
.cover {
  display: flex; flex-direction: column; justify-content: space-between;
  aspect-ratio: 2 / 3;
  padding: clamp(22px, 2.6vw, 32px) clamp(22px, 2.6vw, 32px) clamp(22px, 2.6vw, 32px) clamp(32px, 3.6vw, 44px);
  border-radius: 3px 8px 8px 3px;
  background: var(--cover); color: var(--cover-ink);
  text-decoration: none;
  box-shadow: inset 10px 0 0 rgb(0 0 0 / .18), inset 11px 0 0 rgb(255 255 255 / .08), 0 32px 48px -28px rgb(0 0 0 / .6);
}
.cover-title { display: block; font: 600 clamp(42px, 4.8vw, 60px)/.96 var(--serif); letter-spacing: -.025em; }
.cover-sub { display: block; margin-top: 16px; font: 400 clamp(18px, 1.8vw, 22px)/1.3 var(--serif); opacity: .9; }
.cover-imprint { display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / .28); font: 600 16px/1 var(--serif); }
.cover-imprint .tile { width: 16px; height: 24px; }
.cover-imprint span { font-weight: 400; opacity: .8; }

.wings { max-width: 560px; margin: 30px 0 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.wings li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.wings b { font: 600 23px/1.2 var(--serif); }
.wings span { color: var(--muted); font: 400 16px/1.3 var(--mono); }

@media (max-width: 760px) {
  .book { grid-template-columns: 1fr; }
  .cover { width: min(100%, 300px); }
}

/* Photos, mostly hidden: the label is a chip in a window onto the photos behind the page; it unfolds
   into the plates on paper */
.fold > summary { display: grid; place-items: center; min-height: clamp(220px, 30vw, 380px); padding: 24px var(--gutter); list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:focus-visible { outline: none; }
.fold > summary:focus-visible .fold-chip { outline: 3px solid var(--seal); outline-offset: 3px; }
.fold-chip { display: inline-flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 24px; border-radius: 999px; background: var(--paper); color: var(--muted); font: 400 16px/1.2 var(--mono); box-shadow: 0 12px 32px -14px rgb(0 0 0 / .5); transition: background .15s; }
.fold-chip b { color: var(--ink); font-weight: 500; }
.fold-chip::after { content: ""; width: 9px; height: 9px; margin-top: -5px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg); transition: transform .2s; }
.fold[open] .fold-chip::after { margin-top: 5px; transform: rotate(-135deg); }
.fold > summary:hover .fold-chip { background: var(--raised); }
.fold-body { padding-block: clamp(48px, 7vw, 96px) clamp(64px, 10vw, 128px); border-top: 1px solid var(--line); background: var(--paper); }
.fold-body h2 { margin-top: 0; }

/* Photos: the carousel. The 4:5 photo sits in the middle, as tall as the screen allows, its slides
   crossfading; under it only "hamkke · year" and a tick per set. A small arrow marks that pressing the
   photo moves to the next set. Nothing zooms. */
.deck { display: grid; grid-template-columns: min(100%, 480px, calc((100svh - 200px) * .8)); justify-content: center; }
.deck-cap { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; }
.deck-cap .label { flex: none; white-space: nowrap; }
.deck-ticks { display: flex; flex: 0 1 auto; gap: 2px; min-width: 0; }
.deck-ticks i { flex: 0 1 12px; min-width: 3px; height: 3px; border-radius: 2px; background: var(--line); transition: background .3s; }
.deck-ticks i.is-on { background: var(--ink); }
.deck-stage { position: relative; display: block; width: 100%; aspect-ratio: 4 / 5; padding: 0; border: 0; border-radius: 3px; overflow: hidden; background: var(--raised); cursor: pointer; }
.deck-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .9s ease; }
.deck-stage img.is-on { opacity: 1; }
.deck-stage::after { content: ""; position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%; background: rgb(12 11 10 / .5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / 22px no-repeat; transition: background-color .15s; }
.deck-stage:hover::after { background-color: rgb(12 11 10 / .75); }

/* About the name */
.about { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: clamp(32px, 7vw, 112px); }
.about-word { color: var(--seal); font: 600 clamp(110px, 17vw, 232px)/.9 var(--serif); }
.gloss { margin-bottom: 26px; color: var(--muted); font: 400 16px/1.5 var(--mono); }
.about .lede { max-width: 34em; }

@media (max-width: 760px) {
  .about { grid-template-columns: 1fr; gap: 8px; }
  .about-word { font-size: 104px; }
}

/* Footer */
.footer { padding-block: 40px 56px; border-top: 1px solid var(--line); background: var(--paper); }
.footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }
.footer .brand span[lang] { color: var(--muted); font-weight: 400; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.footer p { color: var(--muted); font: 400 15px/1.4 var(--mono); }

/* The 404 page */
.notfound { display: grid; align-content: center; min-height: 100svh; }

@media (prefers-reduced-motion: reduce) {
  .button, .deck-stage img, .deck-ticks i, .fold-chip, .fold-chip::after { transition: none; }
  .backdrop > * { animation: none; }
  .backdrop > :first-child { opacity: 1; }
}
