/* ==========================================================================
   zifong — styles. Colours + fonts are the tokens at the top.
   ========================================================================== */
:root {
  --paper: #FFFFFF;
  --ink: #2A2927;
  --soft: #8C8B85;       /* captions, nav */
  --rule: #DEDDD8;
  --tint: #F1F0EC;       /* active nav, placeholders */
  --biro: #1F1E1C;       /* handwritten bits (black) */
  --sans: "Josefin Sans", "Futura", "Century Gothic", system-ui, sans-serif;
  --hand: "Nothing You Could Do", "Bradley Hand", cursive;
  --max: 920px;
  color-scheme: light;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-weight: 300; font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--biro); outline-offset: 3px; }
body.gated { overflow: hidden; }

/* ---------- header ---------- */
.top { max-width: var(--max); margin: 0 auto; padding: 34px 22px 0; text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 6px; }
.brand a { display: block; }
.avatar { width: 66px; height: auto; transition: rotate .4s cubic-bezier(.3,1.6,.5,1); }
.redo:hover .avatar, .redo:focus-visible .avatar { rotate: -8deg; }
.wordmark { display: block; text-decoration: none; }
.wordmark svg { display: block; height: 58px; width: auto; overflow: visible; }
#wm-name { font-family: var(--hand); font-size: 58px; fill: #1F1E1C; }
.wm-by { font-size: 32px; }
#wm-art { font-family: var(--hand); font-size: 58px; fill: #1F1E1C; }

.nav { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 22px 0 0; }
.nav a {
  text-decoration: none; font-size: 13px; letter-spacing: .2em; text-transform: lowercase;
  color: var(--soft); padding: 8px 10px 6px; transition: color .2s, background .2s;
}
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); background: var(--tint); }
.has-sub { position: relative; }
.has-sub > a { display: block; }
.sub {
  position: absolute; left: 50%; top: 100%; translate: -50% 0; z-index: 20;
  background: var(--tint); padding: 10px 18px 12px; text-align: center;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s;
}
.has-sub:hover .sub, .has-sub:focus-within .sub { opacity: 1; visibility: visible; transition: opacity .2s; }
.nav .sub a { display: block; background: none; letter-spacing: .06em; text-transform: none; font-size: 13px; padding: 5px 0; color: var(--soft); white-space: nowrap; }
.nav .sub a:hover { color: var(--ink); background: none; }
@media (hover: none) { .sub { display: none; } }

/* ---------- pages ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 52px 22px 80px; outline: none; }
.page { animation: in .45s ease both; }
@keyframes in { from { opacity: 0; translate: 0 10px; } }
.intro { text-align: center; color: var(--soft); max-width: 46ch; margin: -12px auto 40px; font-size: 16px; }

/* square-crop grid, like the old site */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.tile { display: block; position: relative; aspect-ratio: 1; overflow: hidden; background: var(--tint); cursor: zoom-in; border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: scale .6s cubic-bezier(.2,.8,.2,1), filter .3s; }
.tile:hover img, .tile:focus-visible img { scale: 1.04; }
.tile .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; text-align: left;
  color: #fff; font-size: 13px; letter-spacing: .06em; line-height: 1.3;
  background: linear-gradient(transparent, rgba(0,0,0,.45));
  opacity: 0; translate: 0 6px; transition: opacity .3s, translate .3s;
}
.tile:hover .label, .tile:focus-visible .label { opacity: 1; translate: 0 0; }
@media (hover: none) { .tile .label { display: none; } }

/* ka-shik: series cards */
.series { display: grid; grid-template-columns: repeat(4, 1fr); gap: 34px 26px; }
.card { text-decoration: none; text-align: center; display: block; }
.card .cover { background: var(--tint); overflow: hidden; aspect-ratio: 1; }   /* same shape for every cover, so titles line up */
.card .cover img { width: 100%; height: 100%; object-fit: cover; transition: scale .6s cubic-bezier(.2,.8,.2,1); }
.card:hover .cover img { scale: 1.04; }
.card h2 { font-weight: 400; font-size: 16px; letter-spacing: .05em; margin: 16px 0 6px; line-height: 1.4; min-height: 2.8em; }   /* room for two lines so captions line up too */
.card p { margin: 0 auto; max-width: 24ch; color: var(--soft); font-size: 13px; letter-spacing: .04em; line-height: 1.5; }

/* one series */
.back { display: inline-block; font-size: 13px; letter-spacing: .12em; color: var(--soft); text-decoration: none; margin-bottom: 26px; }
.back:hover { color: var(--ink); }
.series-head { text-align: center; margin: 0 auto 40px; }
.series-head h1 { font-weight: 400; font-size: 19px; letter-spacing: .06em; margin: 0 0 6px; color: #6B6A65; }
.series-head p { color: var(--soft); margin: 0; font-size: 15px; }
.photos { columns: 3 240px; column-gap: 18px; }
.photos .ph { break-inside: avoid; margin: 0 0 18px; display: block; cursor: zoom-in; border: 0; padding: 0; background: var(--tint); width: 100%; }
.photos .ph img { width: 100%; height: auto; transition: opacity .3s; }
.photos .ph:hover img { opacity: .88; }

/* portraits — featured card section under Scratches */
.pl { margin: 64px 0 0; padding-top: 44px; border-top: 1px solid var(--rule); }
.pl-label {
  margin: 0 0 22px; font-size: 12px; letter-spacing: .18em; text-transform: lowercase;
  color: var(--soft); text-align: center;
}
.pl-cards { display: grid; grid-template-columns: 1fr; gap: 26px; max-width: 640px; margin: 0 auto; }
.pl-card {
  display: grid; grid-template-columns: 200px 1fr; gap: 0 28px; align-items: center;
  text-align: left;
}
.pl-cover {
  aspect-ratio: 1; background: var(--tint); overflow: hidden;
  display: grid; place-items: center; padding: 18px;
}
.pl-cover img { width: 100%; height: 100%; object-fit: cover; }
.pl-accent {
  font-family: var(--hand); color: var(--biro); font-size: 28px; line-height: 1.15;
  text-align: center; rotate: -2deg; user-select: none;
}
.pl-body h1 {
  font-weight: 400; font-size: 22px; letter-spacing: .05em; line-height: 1.3;
  margin: 0 0 12px;
}
.pl-body p { margin: 0 0 12px; max-width: 40ch; font-size: 16px; }
.pl-body .btns { margin-top: 18px; }
.pl > .ig { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 36px; }
.ig-post { display: block; aspect-ratio: 1; overflow: hidden; background: var(--tint); }
.ig-post img { width: 100%; height: 100%; object-fit: cover; transition: scale .5s cubic-bezier(.2,.8,.2,1), opacity .3s; }
.ig-post:hover img { scale: 1.05; opacity: .9; }
@media (max-width: 760px) {
  .pl > .ig { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .pl-card { grid-template-columns: 1fr; gap: 20px; text-align: center; justify-items: center; }
  .pl-cover { width: min(200px, 56vw); }
  .pl-body p { margin-left: auto; margin-right: auto; }
  .pl-body .btns { justify-content: center; }
}
.btns { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; margin-top: 22px; }
.btn { display: inline-block; background: var(--ink); color: var(--paper); text-decoration: none; padding: 12px 20px 10px; font-size: 14px; letter-spacing: .12em; transition: opacity .2s; }
.btn:hover { opacity: .82; }
.link { font-size: 14px; letter-spacing: .08em; text-underline-offset: 4px; }
.more-tile { display: grid; place-items: center; aspect-ratio: 1; background: var(--tint); text-decoration: none; text-align: center; padding: 16px; }
.more-tile span { font-family: var(--hand); color: var(--biro); font-size: 22px; line-height: 1.1; }

/* about */
.about { display: grid; grid-template-columns: 240px 1fr; gap: 48px; align-items: start; max-width: 760px; margin: 0 auto; }
.about img { width: 100%; height: auto; }
.about h1 { font-weight: 400; font-size: 1em; letter-spacing: 0; line-height: 1.6; margin: 0 0 14px; }
.about p { margin: 0 0 14px; }
.about .soft { color: var(--soft); }
.about dl { margin: 26px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 15px; }
.about dt { color: var(--soft); letter-spacing: .08em; }
.about dd { margin: 0; }
.about dd a { text-underline-offset: 4px; }

/* footer */
.foot { position: relative; max-width: var(--max); margin: 0 auto; padding: 22px 22px calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--soft); letter-spacing: .06em; }
.foot::before { content: ""; position: absolute; top: 0; left: 22px; right: 22px; height: 1px; background: var(--rule); }   /* line sits inside the margins */
.foot-links { display: flex; gap: 18px; align-items: center; }
.foot a { text-decoration: none; } .foot a:hover { color: var(--ink); }
.redo { position: relative; background: none; border: 0; padding: 0; cursor: pointer; display: block; }
.redo-tip {
  position: absolute; right: calc(100% + 4px); top: 50%; translate: 6px -50%; white-space: nowrap;
  font-family: var(--hand); font-size: 17px; color: var(--biro); line-height: 1; rotate: -4deg;
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .3s cubic-bezier(.2,.9,.3,1.3);
}
.redo:hover .redo-tip, .redo:focus-visible .redo-tip { opacity: 1; translate: 0 -50%; }
@media (hover: none) { .redo-tip { display: none; } }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--paper);
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 50px) 8px calc(env(safe-area-inset-bottom, 0px) + 24px); animation: fade .25s ease both; }
.viewer[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.v-fig { margin: 0; height: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; overflow-y: auto; overscroll-behavior: contain; }
.v-fig > .v-img { margin-top: auto; }
.v-fig > figcaption { margin-bottom: auto; }
.v-img { flex-shrink: 0; max-height: min(calc(100% - 90px), 78dvh); max-width: 100%; object-fit: contain; animation: pop .35s cubic-bezier(.2,.8,.2,1) both; }
@keyframes pop { from { opacity: 0; scale: .98; } }
.v-fig figcaption { text-align: center; max-width: 60ch; }
.v-title { display: block; font-size: 17px; letter-spacing: .05em; font-weight: 400; }
.v-meta { display: block; color: var(--soft); font-size: 14px; letter-spacing: .04em; }
.v-story { display: block; color: var(--soft); font-size: 14px; margin-top: 8px; line-height: 1.6; }
.v-story:empty { display: none; }
.v-prev, .v-next { background: none; border: 0; font-size: 40px; font-weight: 300; color: var(--soft); cursor: pointer; height: 100%; }
.v-prev:hover, .v-next:hover { color: var(--ink); }
.v-close { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 16px; background: none; border: 0; cursor: pointer; font-size: 14px; letter-spacing: .15em; color: var(--soft); padding: 8px; }
.v-close:hover { color: var(--ink); }

/* ---------- connect-the-dots gate ---------- */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background-color: #FCFCFA; background-image: radial-gradient(circle, #E6E4DE 1.1px, transparent 1.3px); background-size: 22px 22px; background-position: 11px 11px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px); transition: opacity .6s; }
.gate[hidden] { display: none; }
.gate.leaving { opacity: 0; pointer-events: none; }
.sheet { width: min(92vw, 600px); height: min(90vh, 760px); display: flex; flex-direction: column; background: none; color: #2A2927; }
.sheet-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 24px 0; text-align: center; }
.sheet-title { margin: 0; font-size: 15px; letter-spacing: .18em; color: #4A4945; }
.hint { margin: 0; font-family: var(--hand); color: #5E3B1F; font-size: 28px; line-height: 1.2; text-align: center; }
svg.draw { flex: 1; min-height: 0; width: 100%; touch-action: none; cursor: crosshair; }
.sheet-foot { display: flex; justify-content: center; padding: 20px 24px 10px; }
.skip {
  background: #FCFCFA; border: 1px solid #2A2927; color: #2A2927; border-radius: 999px;
  padding: 8px 16px 6px; cursor: pointer; font-size: 13px; letter-spacing: .14em; transition: background .2s, color .2s;
}
.skip:hover, .skip:focus-visible { background: #2A2927; color: #FCFCFA; }

.dot, .done-dot, .pulse { pointer-events: none; }
.dot { fill: #2A2927; } .dot.next { fill: #1F1E1C; } .done-dot { fill: #2A2927; opacity: .3; }
.dot-hit { fill: transparent; cursor: pointer; }
.num { font-family: "Helvetica Neue", Arial, sans-serif; font-size: 30px; fill: #2A2927; pointer-events: none; user-select: none; }
.pulse { fill: none; stroke: #1F1E1C; stroke-width: 2.5; animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { from { r: 9; opacity: .9; } to { r: 32; opacity: 0; } }
.wrong { animation: wrong .35s; }
@keyframes wrong { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.ink { fill: none; stroke: #2A2927; stroke-width: 6; stroke-linecap: round; }
.seg { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: ink .28s ease-out forwards; }
@keyframes ink { to { stroke-dashoffset: 0; } }
.rubber { fill: none; stroke: #8C8B85; stroke-width: 2.5; stroke-dasharray: 7 9; stroke-linecap: round; }
.reveal { opacity: 0; transform-origin: 388px 390px; scale: .97; transition: opacity .9s ease .25s, scale 1.2s cubic-bezier(.2,.9,.3,1.3) .25s; }
.cheer { font-family: var(--hand); fill: #1F1E1C; font-size: 42px; opacity: 0; transition: opacity .4s 1.1s; }
.complete .reveal { opacity: 1; scale: 1; }
.complete .cheer { opacity: 1; }
.complete .features { opacity: 0; transition: opacity .3s 1s; }
.complete .num, .complete .dot, .complete .done-dot, .complete .pulse { opacity: 0; transition: opacity .4s; }

/* the doodle flying up into the header */
.flyer { position: fixed; z-index: 120; pointer-events: none; transition: left .8s cubic-bezier(.6,0,.2,1), top .8s cubic-bezier(.6,0,.2,1), width .8s cubic-bezier(.6,0,.2,1), rotate .8s; }
body.gated .avatar { opacity: 0; }

/* ---------- big screens ---------- */
@media (min-width: 1600px) { :root { --max: 1120px; } }

/* ---------- short screens (phones in landscape) ---------- */
@media (max-height: 520px) {
  .v-img { max-height: 70dvh; }
  .viewer { padding-top: calc(env(safe-area-inset-top, 0px) + 40px); }
  .sheet { height: 94vh; width: min(94vw, 720px); }
  .sheet-head { padding-top: 10px; gap: 2px; }
  .sheet-title { font-size: 12px; }
  .hint { font-size: 20px; }
  .sheet-foot { padding: 4px 24px 6px; }
  .skip { padding: 6px 14px 4px; font-size: 12px; }
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .series { grid-template-columns: repeat(2, 1fr); gap: 30px 16px; }
  .about { grid-template-columns: 1fr; gap: 28px; }
  .about { text-align: center; justify-items: center; }
  .about img { max-width: 220px; margin: 0 auto; }
  .about p { margin-left: auto; margin-right: auto; }
  .about dl { grid-template-columns: auto auto; width: fit-content; margin-left: auto; margin-right: auto; text-align: left; }
}
@media (max-width: 560px) {
  .top { padding-top: 22px; }
  .avatar { width: 54px; } .wordmark svg { height: 42px; }
  .nav { flex-wrap: wrap; gap: 2px; }
  .nav a { font-size: 15px; letter-spacing: .06em; padding: 12px 9px 10px; min-height: 44px; }
  .v-img { max-height: 58dvh; }
  main { padding: 34px 16px 60px; }
  .photos { columns: 2; column-gap: 10px; }
  .photos .ph { margin-bottom: 10px; }
  .viewer { grid-template-columns: 36px 1fr 36px; }
  .sheet { width: 100%; height: 100%; }
  .hint { font-size: 22px; }
  .num { font-size: 34px; }
}
@media (max-width: 360px) {
  .nav a { font-size: 14px; letter-spacing: .02em; padding: 12px 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
