@import url("/fonts/fonts.css");

:root {
  --ink: #000;
  --paper: #ebe3d0;
  --paper-deep: #d9cfb6;
  --blood: #a01212;
  --corona: #ff3b1f;
  --ash: #7d766a;
  --bubble: #fbf8f0;

  --display: "Rubik Dirt", "Literata", serif;
  --text: "Literata", Georgia, serif;

  --gutter: clamp(8px, 1.6vw, 14px);
  --line: 4px;
  color-scheme: light;
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: .35s ease-in both page-out; }
  ::view-transition-new(root) { animation: .45s ease-out both page-in; }
}
@keyframes page-out { to { opacity: 0; transform: translateX(-6%); } }
@keyframes page-in { from { opacity: 0; transform: translateX(8%); } }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font: 400 1.0625rem/1.6 var(--text);
  color: var(--ink);
  background-color: var(--paper);
  /* aged paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }

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

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  font: 600 1.05rem/1.2 var(--text);
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  border: var(--line) solid var(--ink);
  padding: .8em 1.4em;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--blood);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--blood); }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--blood); }
.btn[disabled] { cursor: default; opacity: .55; transform: none; box-shadow: none; }

.btn-quiet {
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}
.btn-quiet:hover { box-shadow: 4px 4px 0 var(--ink); }

/* ---------- splash (page 1) ---------- */

.splash {
  min-height: 100dvh;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  padding: 32px 16px 48px;
  overflow: hidden;
  position: relative;
}

.splash-inner {
  width: min(100%, 34rem);
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 1.25rem;
  position: relative;
}

/* The eclipse: red sun swallowed by a black moon */
.eclipse {
  width: min(62vw, 300px);
  aspect-ratio: 1;
  position: relative;
  margin-bottom: .5rem;
}
.eclipse .sun, .eclipse .moon, .eclipse .corona {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.eclipse .corona {
  inset: -38%;
  background:
    repeating-conic-gradient(from 0deg, rgb(255 59 31 / .55) 0 1.2deg, transparent 1.2deg 7deg);
  mask: radial-gradient(circle, transparent 36%, #000 37%, transparent 70%);
}
.eclipse .sun {
  background: radial-gradient(circle, #ff6a3d 0%, var(--corona) 45%, var(--blood) 70%);
  box-shadow: 0 0 60px 18px rgb(255 59 31 / .55), 0 0 160px 60px rgb(160 18 18 / .45);
}
.eclipse .moon {
  inset: 3%;
  background: var(--ink);
  box-shadow: inset -6px -4px 18px rgb(255 59 31 / .25);
}

@media (prefers-reduced-motion: no-preference) {
  .eclipse .moon { animation: swallow 2.6s cubic-bezier(.6, 0, .2, 1) .3s both; }
  .eclipse .corona { animation: flare 2.6s ease-out .3s both, turn 90s linear 2.9s infinite; }
  .eclipse .sun { animation: flare-sun 2.6s ease-out .3s both; }
  .splash .reveal { animation: rise .9s ease-out 2.4s both; }
}
@keyframes swallow { from { transform: translate(-85%, 30%); } }
@keyframes flare { from { opacity: 0; transform: scale(.7); } 70% { opacity: 1; } }
@keyframes flare-sun { from { box-shadow: 0 0 20px 4px rgb(255 59 31 / .3); } }
@keyframes turn { to { rotate: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.splash h1 {
  font: 400 clamp(3.4rem, 17vw, 6.5rem)/.9 var(--display);
  margin: 0;
  color: var(--paper);
  text-shadow: 0 0 24px rgb(160 18 18 / .8);
}

.when {
  font-size: clamp(1.2rem, 5vw, 1.5rem);
  line-height: 1.35;
  margin: 0;
}
.when strong { font-weight: 600; }
.when a {
  color: var(--paper);
  text-decoration-color: var(--corona);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
.when a:hover { color: var(--corona); }

.plus-one {
  margin: 0;
  max-width: 22rem;
  font-style: italic;
  font-size: 1.05rem;
  color: #c9bfa9;
  text-wrap: balance;
}
.plus-one::before, .plus-one::after {
  content: "";
  display: block;
  width: 3rem;
  height: 2px;
  margin: 0 auto .9rem;
  background: var(--blood);
}
.plus-one::after { margin: .9rem auto 0; }

.splash .btn {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--paper);
  margin-top: .75rem;
}

/* ---------- manga pages ---------- */

.page {
  width: min(100% - 32px, 60rem);
  margin: 0 auto;
  padding: 24px 0 48px;
}

.panels {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: repeat(6, 1fr);
}

.panel {
  border: var(--line) solid var(--ink);
  background: var(--paper);
  padding: clamp(18px, 4vw, 36px);
  position: relative;
  min-height: 11rem;
  display: grid;
  align-content: center;
  grid-column: span 6;
}
.panel.w4 { grid-column: span 4; }
.panel.w3 { grid-column: span 3; }
.panel.w2 { grid-column: span 2; }
@media (max-width: 640px) {
  .panel.w4, .panel.w3, .panel.w2 { grid-column: span 6; }
  .panel.filler { display: none; }
}

/* ink drawings: Dragonslayer, Behelit */
.art { display: grid; place-items: center; overflow: hidden; }
.art svg { width: 100%; height: 100%; max-height: 20rem; }
.art .narration {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: 17rem;
  margin: 0;
  background: var(--bubble);
  border: 2px solid var(--ink);
  padding: .6em .8em;
  font: italic .95rem/1.4 var(--text);
}

.panel.ink { background: var(--ink); color: var(--paper); }
.panel.ink .btn { color: var(--ink); background: var(--paper); border-color: var(--paper); }

/* screentone */
.tone {
  background-image: radial-gradient(circle, rgb(0 0 0 / .28) 1.1px, transparent 1.4px);
  background-size: 7px 7px;
}
/* emphasis speed lines */
.speed {
  background:
    radial-gradient(circle, var(--paper) 24%, transparent 60%),
    repeating-conic-gradient(from 3deg, var(--ink) 0 .6deg, transparent .6deg 4.5deg),
    var(--paper);
}

.bubble {
  background: var(--bubble);
  border: 3px solid var(--ink);
  border-radius: 50% / 46%;
  padding: 1.6em 2em;
  font: 600 clamp(1.15rem, 3.6vw, 1.55rem)/1.35 var(--text);
  text-align: center;
  margin: 0 auto;
  max-width: 26rem;
  position: relative;
  text-wrap: balance;
}
.bubble::after {
  content: "";
  position: absolute;
  top: calc(100% - 4px);
  left: 40%;
  width: 30px;
  height: 30px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M1.5 0 L6 28 L28.5 0' fill='%23fbf8f0' stroke='%23000' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
}
.bubble.right::after { left: auto; right: 40%; transform: scaleX(-1); }

.caption {
  font: 400 italic clamp(1.1rem, 3.2vw, 1.35rem)/1.45 var(--text);
  margin: 0 0 1.2rem;
  max-width: 32rem;
  text-wrap: pretty;
}

.chapter {
  font: 400 clamp(2.2rem, 8vw, 3.8rem)/1 var(--display);
  margin: 0 0 1rem;
}

.back {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: .95rem;
  color: var(--ash);
}

/* ---------- wishlist ---------- */

.intro { overflow: hidden; }
.intro p { margin: 0; max-width: 34rem; position: relative; }
.intro .chapter { position: relative; }
.intro .brand-big {
  position: absolute;
  right: -10px;
  bottom: -30px;
  width: clamp(120px, 26vw, 220px);
  color: var(--blood);
  opacity: .9;
}
@media (max-width: 640px) { .intro .brand-big { opacity: .35; } }

.gift {
  align-content: start;
  gap: .75rem;
  min-height: 0;
  overflow: hidden;
}
.gift h2 {
  font: 400 1.45rem/1.15 var(--display);
  padding-right: 56px;
  margin: 0;
  text-wrap: balance;
}
.gift .note { margin: 0; font-style: italic; color: #3b362e; }
.gift .actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-top: auto; padding-top: .5rem; }
.gift .shop { font-size: .95rem; text-underline-offset: 4px; }
.gift .status { font-size: .95rem; margin: 0; }

.gift.taken { background-color: var(--paper-deep); }
.gift.taken h2, .gift.taken .note { opacity: .55; }
.gift.taken .status { color: var(--blood); font-weight: 600; }

/* the Brand of Sacrifice, stamped on reserved gifts */
.brand {
  position: absolute;
  right: 10px;
  top: 8px;
  width: 64px;
  height: 77px;
  color: var(--blood);
  rotate: 12deg;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .gift.just-taken .brand { animation: stamp .35s cubic-bezier(.3, 1.6, .5, 1) both; }
}
@keyframes stamp { from { opacity: 0; scale: 2.2; } }

.gift .btn { font-size: .95rem; padding: .6em 1.1em; }

.loading, .error { grid-column: span 6; margin: 0; }
.error { color: var(--blood); font-weight: 600; }

dialog {
  border: var(--line) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 28px 24px 24px;
  width: min(100% - 32px, 26rem);
  box-shadow: 8px 8px 0 var(--blood);
}
dialog::backdrop { background: rgb(0 0 0 / .7); }
dialog h2 { font: 600 1.3rem/1.3 var(--text); margin: 0 0 .5rem; }
dialog p { margin: 0 0 1.4rem; }
dialog .row { display: flex; gap: 1rem; flex-wrap: wrap; }

.footnote {
  margin-top: 2rem;
  color: var(--ash);
  font-size: .95rem;
}

.nowrap { white-space: nowrap; }
