/* Fanfic Alchemy: parchment by day, midnight laboratory by night. */
@font-face { font-family: "Fell"; src: url("fonts/ui/fell.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Fell"; font-style: italic; src: url("fonts/ui/fell-italic.woff2") format("woff2"); font-display: swap; }

:root {
  --bg1: #f6eedb; --bg2: #e8d9b8; --ink: #3a2943; --soft: #7a6470;
  --card: rgba(255, 250, 238, .82); --line: #c9a45c; --line-soft: rgba(201, 164, 92, .45);
  --potion: #7b4fc0; --potion-deep: #5a3392; --teal: #2f8f83; --gold: #c9973a;
  --iron: #3d3450; --iron-hi: #5b4f72; --glow: rgba(123, 79, 192, .25);
}
@media (prefers-color-scheme: dark) { :root {
  --bg1: #221a3a; --bg2: #0f0b1c; --ink: #f1e7d2; --soft: #b9a9c9;
  --card: rgba(30, 24, 52, .86); --line: #d9b25e; --line-soft: rgba(217, 178, 94, .35);
  --potion: #a57ee8; --potion-deep: #8b5fd9; --teal: #5fd0c0; --gold: #e6bb62;
  --iron: #120e20; --iron-hi: #2b2342; --glow: rgba(165, 126, 232, .35);
} }

* { box-sizing: border-box; }
html {
  min-height: 100%;
  background: radial-gradient(ellipse at 50% -10%, var(--bg1), var(--bg2) 75%) fixed;
  background-color: var(--bg2);
}
body {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color: var(--ink); max-width: 32rem; margin: 0 auto; padding: 2rem 1.1rem 3rem; line-height: 1.55;
}
.svgdefs { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }

/* ---- the label / card: double gilt border like an apothecary label */
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 1.7rem 1.35rem 1.4rem; box-shadow: 0 12px 34px rgba(40, 20, 60, .22);
  backdrop-filter: blur(4px);
}
.card::before {
  content: ""; position: absolute; inset: 6px; border: 1px solid var(--line-soft);
  border-radius: 13px; pointer-events: none;
}
.emblem { display: block; width: 3.4rem; height: 3.4rem; margin: -.3rem auto .2rem; }
h1 {
  font-family: "Fell", Georgia, serif; font-weight: normal; font-size: 2.35rem; line-height: 1.1;
  text-align: center; margin: 0; letter-spacing: .01em;
}
h1 em { color: var(--potion); }
.sub { text-align: center; color: var(--soft); font-style: italic; margin: .35rem 0 0; }
.sigil { display: block; width: 11rem; height: 1.2rem; margin: .7rem auto 0; color: var(--line); }

/* ---- privacy note */
.promise {
  display: flex; gap: .6rem; align-items: flex-start; margin: 1.2rem 0 0; padding: .7rem .9rem;
  border-radius: 12px; border: 1px dashed var(--line-soft); font-size: .93rem; line-height: 1.45;
  background: rgba(47, 143, 131, .09);
}
.promise svg { flex: none; width: 1.3rem; height: 1.3rem; margin-top: .1rem; color: var(--teal); }

/* ---- the cauldron (drop zone) */
.drop {
  display: block; text-align: center; cursor: pointer; margin: 1.2rem 0; padding: 1rem 1rem 1.2rem;
  border: 2px dashed var(--line-soft); border-radius: 16px; transition: background .25s, border-color .25s;
}
.drop:hover, .drop.over { border-color: var(--potion); background: var(--glow); }
.drop input { display: none; }
.drop b { display: block; font-weight: normal; font-size: 1.2rem; overflow-wrap: anywhere; }  /* not Fell: its old-style digits make "AO3" read as "AO₃" */
.drop small { color: var(--soft); }
.cauldron { display: block; width: 8.5rem; height: 7rem; margin: 0 auto .3rem; overflow: visible; }
.cauldron .iron { fill: var(--iron); }
.cauldron .rim { fill: var(--iron-hi); stroke: var(--line); stroke-width: 1.2; }
.cauldron .liquid { fill: var(--potion); transition: fill .6s; }
.cauldron .shine { fill: #fff; opacity: .25; }
.cauldron .flame { fill: var(--gold); opacity: .85; transform-origin: 60px 100px; animation: flicker 1.2s ease-in-out infinite alternate; }
.cauldron .flame.f2 { fill: #e0743a; animation-duration: .9s; }
.cauldron .bub { fill: var(--potion); opacity: 0; animation: bubble 2.6s ease-in infinite; }
.cauldron .bub:nth-of-type(2) { animation-delay: .7s; }
.cauldron .bub:nth-of-type(3) { animation-delay: 1.4s; }
.cauldron .bub:nth-of-type(4) { animation-delay: 2s; }
.cauldron .steam { fill: none; stroke: var(--soft); stroke-width: 2; stroke-linecap: round; opacity: 0; }
.drop.filled .liquid, .drop.filled .bub { fill: var(--teal); }
.drop.brewing .bub { animation-duration: .9s; }
.drop.brewing .steam { animation: steam 1.6s ease-out infinite; }
.drop.brewing .steam.s2 { animation-delay: .5s; }
.drop.brewing .steam.s3 { animation-delay: 1s; }
.drop.done .liquid, .drop.done .bub { fill: var(--gold); }
.drop.done .cauldron { filter: drop-shadow(0 0 10px var(--gold)); }
@keyframes bubble {
  0% { opacity: 0; transform: translateY(0) scale(.6); }
  20% { opacity: .9; }
  100% { opacity: 0; transform: translateY(-30px) scale(1.15); }
}
@keyframes steam {
  0% { opacity: 0; transform: translateY(4px); }
  30% { opacity: .55; }
  100% { opacity: 0; transform: translateY(-22px); }
}
@keyframes flicker { from { transform: scaleY(.85); } to { transform: scaleY(1.12); } }

/* ---- option switch */
.opt { display: flex; align-items: center; gap: .75rem; margin: 0 0 1.1rem; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { flex: none; width: 2.9rem; height: 1.6rem; border-radius: 999px; background: var(--line-soft);
          position: relative; transition: background .2s; border: 1px solid var(--line); }
.switch::after { content: "✦"; position: absolute; top: .08rem; left: .1rem; width: 1.3rem; height: 1.3rem;
                 border-radius: 50%; background: var(--card); color: var(--gold); font-size: .85rem;
                 line-height: 1.3rem; text-align: center; transition: transform .2s; }
.opt input:checked + .switch { background: var(--potion-deep); }
.opt input:checked + .switch::after { transform: translateX(1.3rem); }
.opt input:focus-visible + .switch { outline: 2px solid var(--potion); outline-offset: 2px; }
.opt small { display: block; color: var(--soft); line-height: 1.35; }

/* ---- buttons */
button {
  width: 100%; font: inherit; font-family: "Fell", Georgia, serif; font-size: 1.3rem; padding: .7rem;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: #fff6e2;
  background: linear-gradient(160deg, var(--potion), var(--potion-deep));
  box-shadow: 0 4px 16px var(--glow), inset 0 1px 0 rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center; gap: .5rem; transition: transform .15s;
}
button svg { width: 1.3rem; height: 1.3rem; }
button:not(:disabled):hover { transform: translateY(-2px); }
button:disabled { opacity: .5; cursor: default; }
.actions { display: none; gap: .6rem; margin-top: .8rem; }
.actions.show { display: flex; }
.actions button { font-size: 1.05rem; padding: .6rem; }
.actions .secondary { background: transparent; color: var(--potion); box-shadow: none; }

#msg { text-align: center; min-height: 1.5em; margin: 1rem 0 0; }
.ok { background: rgba(201, 151, 58, .16); border: 1px solid var(--line-soft); border-radius: 12px; padding: .6rem .9rem; }
.err { background: rgba(192, 64, 80, .13); border: 1px solid rgba(192, 64, 80, .4); border-radius: 12px; padding: .6rem .9rem; }

details { margin-top: 1.3rem; color: var(--soft); }
summary { cursor: pointer; text-align: center; font-family: "Fell", Georgia, serif; font-size: 1.1rem; }
details ol { padding-left: 1.3rem; } details b { color: var(--ink); }

/* ---- rising bubbles and sparks behind everything */
.air { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.air i { position: absolute; bottom: -2rem; width: .7rem; height: .7rem; border-radius: 50%;
         border: 1.5px solid var(--potion); opacity: .35; animation: rise linear infinite; }
.air i:nth-child(1) { left: 7%;  animation-duration: 16s; }
.air i:nth-child(2) { left: 22%; animation-duration: 21s; animation-delay: -7s; width: .45rem; height: .45rem; border-color: var(--teal); }
.air i:nth-child(3) { left: 45%; animation-duration: 18s; animation-delay: -12s; }
.air i:nth-child(4) { left: 64%; animation-duration: 24s; animation-delay: -4s; width: 1rem; height: 1rem; }
.air i:nth-child(5) { left: 81%; animation-duration: 19s; animation-delay: -9s; border-color: var(--gold); }
.air i:nth-child(6) { left: 93%; animation-duration: 22s; animation-delay: -15s; width: .5rem; height: .5rem; border-color: var(--teal); }
@keyframes rise { to { transform: translate(-2rem, -112vh); } }

@media (prefers-reduced-motion: reduce) {
  .air { display: none; }
  .cauldron .bub, .cauldron .flame, .drop.brewing .steam { animation: none; }
  .cauldron .bub { opacity: .6; }
  button { transition: none; }
}

footer { text-align: center; color: var(--soft); font-size: .9rem; margin-top: 1.6rem;
         font-family: "Fell", Georgia, serif; font-style: italic; }
footer a { color: inherit; }
noscript p { text-align: center; }
.cauldron .legs { fill: none; stroke: var(--iron); stroke-width: 5; stroke-linecap: round; }
