:root {
  --black: #221a13;
  --white: #f1f1ec;
  --yellow: #ffc700;
  --red: #be1200;
  --blue: #2c2c5e;
  --blue-rgb: 44 44 94;

  --alpha-header: .94;
  --alpha-side: .9;
  --alpha-footer: 1;

  --f-heading: Impact, "Arial Black", sans-serif;
  --f-body: "Arial Narrow", Arial, sans-serif;

  --flip-duration: .9s;
  --flip-ease: cubic-bezier(.4, .1, .2, 1);
  --tilt: 2.2deg;

  --scale: .8;
}

@supports not (zoom: 1) {
  :root { --scale: 1; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --flip-duration: .01s; }
}

*, *::before, *::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background: var(--black);
  color: var(--white);
  font-family: var(--f-body);
  letter-spacing: -0.01em;
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

a { color: inherit; }

button { font: inherit; }

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

.scan { position: relative; }
.scan::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgb(255 255 255 / .05) 0 1px, transparent 1px 3px);
}

.gloss {
  --c: var(--red);
  color: var(--white);
  cursor: pointer;
  background:
    linear-gradient(180deg, rgb(255 255 255 / .6) 0, rgb(255 255 255 / .16) 50%, rgb(255 255 255 / 0) 51%, rgb(0 0 0 / .24) 100%),
    var(--c);
  border: 1px solid rgb(0 0 0 / .75);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .75),
    inset 0 -3px 5px rgb(0 0 0 / .32),
    0 3px 0 rgb(0 0 0 / .5);
  transition: transform .08s ease, box-shadow .08s ease;
}
.gloss:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .6),
    inset 0 -2px 4px rgb(0 0 0 / .32),
    0 1px 0 rgb(0 0 0 / .5);
}

.nav-btn {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}

.nav-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.back-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.full-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav-btn:disabled {
  cursor: default;
  filter: grayscale(1) brightness(.75);
  opacity: .45;
  transform: none;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), 0 3px 0 rgb(0 0 0 / .5);
}

.lcd {
  display: block;
  min-width: 9em;
  padding: 6px 16px 4px;
  background: var(--black);
  color: var(--yellow);
  font-family: var(--f-heading);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: .03em;
  text-align: center;
  border: 2px solid rgb(0 0 0 / .8);
  box-shadow: inset 0 3px 8px rgb(0 0 0 / .9), 0 1px 0 rgb(255 255 255 / .3);
}

.page-main {
  display: grid;
  place-items: center;
}

.site {
  zoom: var(--scale);
  width: min(calc((100vw - 32px) / var(--scale)), 1180px);
  height: min(calc((100dvh - 32px) / var(--scale)), 880px);
  display: grid;
  grid-template-columns: 26% 1fr;
  grid-template-rows: 48px 1fr 46px;
  grid-template-areas:
    "head head"
    "side stage"
    "foot foot";
  background: var(--white);
  color: var(--white);
  overflow: hidden;
}

.site-header {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgb(var(--blue-rgb) / var(--alpha-header));
  border-bottom: 2px solid var(--black);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .25);
}
.brand img { height: 30px; width: auto; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-body);
  font-size: 14px;
  font-weight: 400;
}
.crumb-item { color: var(--white); text-decoration: underline; }
.crumb-item.active { color: var(--yellow); }

.powered {
  margin-left: auto;
  display: block;
}
.powered img { height: 36px; width: auto; }

.sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4vh;
  padding: 4vh 16px 16px;
  min-height: 0;
  background:
    linear-gradient(180deg, rgb(255 255 255 / .14), rgb(255 255 255 / 0) 45%),
    rgb(var(--blue-rgb) / var(--alpha-side));
  box-shadow: inset -2px 0 0 rgb(0 0 0 / .35), inset -3px 0 0 rgb(255 255 255 / .12);
}

.title-logo { margin: 0; width: min(100%, 220px); }
.title-logo img { width: 100%; height: auto; }

.objects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(10px, 2.4vh, 24px);
  justify-items: center;
}
.object {
  display: grid;
  justify-items: center;
  gap: 6px;
  font-family: var(--f-body);
  font-size: 15px;
  font-weight: 700;
}
.object .thumb {
  display: block;
  width: clamp(64px, 12vh, 100px);
  aspect-ratio: 1;
  background: var(--black);
  border: 2px solid rgb(255 255 255 / .35);
  box-shadow: 0 3px 0 rgb(0 0 0 / .45);
  overflow: hidden;
}
.object .thumb img { width: 100%; height: 100%; object-fit: cover; }
.object .thumb img[hidden] { display: none; }

.stage {
  grid-area: stage;
  display: grid;
  grid-template-columns: 1fr clamp(84px, 9vw, 104px);
  grid-template-rows: clamp(72px, 8vw, 88px) minmax(0, 1fr);
  gap: 16px 12px;
  padding: 24px 22px 16px 40px;
  min-height: 0;
  background: var(--white);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  min-width: 0;
  background:
    linear-gradient(180deg, rgb(255 255 255 / .16), rgb(255 255 255 / 0) 55%),
    rgb(var(--blue-rgb) / var(--alpha-side));
  border: 2px solid rgb(0 0 0 / .55);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), inset 0 -3px 6px rgb(0 0 0 / .25);
}

.readout {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
}
.hint {
  margin: 0;
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--white);
}

.fullview {
  --c: var(--yellow);
  color: var(--black);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--f-heading);
  font-size: 16px;
  line-height: 1;
  border-radius: 10px;
  padding: 6px;
}

.zine-frame {
  grid-column: 1 / -1;
  position: relative;
  z-index: 2;
  min-height: 0;
  container-type: size;
  border: 12px solid rgb(var(--blue-rgb) / var(--alpha-side));
  background: var(--white);
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / .35), inset 0 8px 16px rgb(0 0 0 / .16);
  margin-top: 4px;
}

.site-footer {
  grid-area: foot;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgb(0 0 0 / .28), rgb(0 0 0 / .28)),
    rgb(var(--blue-rgb) / var(--alpha-footer));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .18);
}
.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}
.site-footer a:hover { color: var(--yellow); }
.site-footer img { height: 26px; width: auto; pointer-events: auto; }

.zine-clip {
  position: absolute;
  inset: 0;
  clip-path: inset(-100vh -100vw 0 -100vw);
}

.zine {
  position: relative;
  width: calc(var(--pw) * 2);
  height: calc(var(--pw) * 210 / 99);
  outline: none;
  touch-action: pan-y;
}
.zine:focus-visible .zine-spread { outline: 3px solid var(--yellow); outline-offset: 6px; }

.zine-frame .zine {
  --pop: 24px;
  --pw: min(calc((100cqh + var(--pop)) * 99 / 210), 100cqw);
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%) rotate(var(--tilt));
  transform-origin: 50% 100%;
}

.zine-spread {
  position: absolute;
  inset: 0;
  perspective: 2400px;
  filter: drop-shadow(0 18px 22px rgb(0 0 0 / .45));
  transition: transform var(--flip-duration) var(--flip-ease);
}

.zine[data-state="front"] .zine-spread { transform: translateX(calc(var(--pw) * -.5)); }
.zine[data-state="back"]  .zine-spread { transform: translateX(calc(var(--pw) *  .5)); }

.zine-book {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--pw);
  height: 100%;
  transform-style: preserve-3d;
}

.leaf {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform var(--flip-duration) var(--flip-ease);
  will-change: transform;
}
.leaf.flipped { transform: rotateY(-180deg); }

@media (hover: hover) {
  .zine[data-state="front"] .zine-spread:hover .leaf:first-child { transform: rotateY(-7deg); }
}

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--white);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face.back { transform: rotateY(180deg); }

.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgb(0 0 0 / .2), rgb(0 0 0 / 0) 7%);
}
.face.back::after {
  background: linear-gradient(270deg, rgb(0 0 0 / .2), rgb(0 0 0 / 0) 7%);
}

.page-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.ph {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12%;
  text-align: center;
  font-family: var(--f-heading);
}
.ph.tone-0 { background: var(--white); color: var(--blue); }
.ph.tone-1 { background: var(--yellow); color: var(--black); }
.ph.tone-2 { background: var(--blue); color: var(--white); }
.ph-num { font-size: clamp(30px, 4vw, 52px); line-height: 1; }
.ph-label { margin: 0; font-size: clamp(13px, 1.4vw, 18px); opacity: .75; font-family: var(--f-body); }

.page-viewer {
  height: 100dvh;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 84px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 20%, var(--blue), var(--black) 75%);
}

.viewer-bar,
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 clamp(12px, 3vw, 32px);
  background: rgb(var(--blue-rgb) / var(--alpha-header));
}
.viewer-bar {
  border-bottom: 2px solid var(--black);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .25);
}
.viewer-controls {
  justify-content: center;
  border-top: 2px solid var(--black);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .18);
}

.viewer-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-body);
  font-size: 14px;
  text-decoration: none;
}
.viewer-back:hover { color: var(--yellow); }

.viewer-logo { height: 28px; width: auto; margin-inline: auto; }

.viewer-fs {
  padding: 6px 12px;
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--white);
  background: transparent;
  border: transparent;
  cursor: pointer;
  
}
.viewer-fs:hover { 
  color: var(--yellow); 
  /* text-decoration: underline; */
}

.viewer-fs[hidden] { display: none; }

.viewer-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px;
}

.page-viewer .zine {
  --pw: min(calc((100dvh - 48px - 84px - 48px) * 99 / 210), 46vw);
  --tilt: 0deg;
}

@media (max-width: 820px) {
  .page-main { display: block; }

  .site {
    --scale: 1;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "head" "side" "stage" "foot";
    overflow: visible;
  }

  .site-header { padding-left: 14px; flex-wrap: wrap; row-gap: 4px; min-height: 48px; }
  .brand img { height: 26px; }
  .powered img { height: 30px; }

  .sidebar {
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    box-shadow: inset 0 -2px 0 rgb(0 0 0 / .35);
  }
  .title-logo { width: 38%; }
  .objects { grid-auto-flow: column; gap: 10px; }
  .object { font-size: 12px; }
  .object .thumb { width: 56px; }

  .stage {
    grid-template-columns: 1fr 84px;
    grid-template-rows: 84px auto;
    padding: 14px 12px 18px;
  }
  .zine-frame { height: min(112vw, 78dvh); }

  .nav-btn { width: 46px; height: 46px; }
  .lcd { font-size: 22px; min-width: 6em; padding: 4px 10px 2px; }
  .hint { font-size: 12px; }
  .toolbar { gap: 8px; padding-inline: 12px; }

  .site-footer { padding: 10px 12px; }
  .site-footer a { font-size: 14px; flex-wrap: wrap; justify-content: center; }
  .site-footer img { height: 22px; }
}

.leaf.split-leaf {
  transform: none !important;
}

.leaf-slice {
  position: absolute;
  left: 0;
  width: 100%;
  height: 33.3333%;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform var(--flip-duration) var(--flip-ease);
  will-change: transform;
}

.leaf-slice:nth-child(1) { top: 0%; transition-delay: 0s; }
.leaf-slice:nth-child(2) { top: 33.3333%; transition-delay: 0.12s; }
.leaf-slice:nth-child(3) { top: 66.6666%; transition-delay: 0.24s; }

.leaf.split-leaf.flipped .leaf-slice {
  transform: rotateY(-180deg);
}

.leaf-slice .face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--white);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.leaf-slice .face.back {
  transform: rotateY(180deg);
}

.leaf-slice .page-img {
  position: absolute;
  left: 0;
  width: 100%;
  height: 300% !important;
  max-width: none;
  object-fit: cover;
}

.leaf-slice .slice-part-0 .page-img { top: 0%; }
.leaf-slice .slice-part-1 .page-img { top: -100%; }
.leaf-slice .slice-part-2 .page-img { top: -200%; }