/* cursed.boo — the Underworld Chancellery at night */
:root {
  color-scheme: dark;
  --night: #1d1230;
  --dusk: #2b1c44;
  --dusk-line: #4a3670;
  --sheet: #f3eefb;
  --moon: #b9a8dd;
  --pumpkin: #ff8a2b;
  --pumpkin-deep: #e56d0c;
  --seal: #e0443a;
  --error: #ff8a7a;
  --display: 'Rubik Wet Paint', 'Rubik', system-ui, sans-serif;
  --body: 'Rubik', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(60rem 30rem at 85% -10%, #3b2560 0%, transparent 60%),
    var(--night);
  color: var(--sheet);
  font: 17px/1.55 var(--body);
  overflow-x: hidden;
}

a { color: var(--moon); }
:focus-visible { outline: 3px solid var(--pumpkin); outline-offset: 3px; border-radius: 4px; }

.cobweb {
  position: absolute;
  top: 0;
  left: 0;
  width: clamp(120px, 22vw, 220px);
  pointer-events: none;
}

/* ---------- header ---------- */

.top {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px;
}
.logo { font: 700 22px/1 var(--body); color: var(--sheet); text-decoration: none; }
.logo span { margin-right: 6px; }
.langs { display: flex; gap: 10px; margin-left: auto; font-size: 15px; }
.langs a { color: var(--moon); text-decoration: none; }
.langs a:hover { color: var(--sheet); text-decoration: underline; }
.langs [aria-current] { color: var(--pumpkin); font-weight: 700; }
#account { font-size: 15px; color: var(--moon); }
@media (max-width: 479px) {
  .langs { order: 3; width: 100%; justify-content: flex-end; }
  #account { margin-left: auto; }
}

/* ---------- main ---------- */

main { position: relative; max-width: 640px; margin: 0 auto; padding: 8px 16px 64px; }

.hero { position: relative; padding: 24px 0 8px; }
.hero h1 {
  max-width: 11ch;
  margin: 0 0 16px;
  font: clamp(38px, 11vw, 84px)/0.98 var(--display);
  color: var(--sheet);
}
.hero .tagline { max-width: 30ch; margin: 0; padding-right: 110px; color: var(--moon); font-size: 18px; }
@media (min-width: 560px) { .hero .tagline { padding-right: 0; } }
.hero .ghost {
  position: absolute;
  right: -4px;
  bottom: -46px;
  width: clamp(96px, 24vw, 150px);
  filter: drop-shadow(0 12px 24px rgb(0 0 0 / .45));
  animation: float 4.5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}

/* The form is an application to the Underworld Chancellery */
.blank {
  position: relative;
  margin: 40px 0 12px;
  padding: 28px 22px 24px;
  background: var(--dusk);
  border: 2px dashed var(--dusk-line);
  border-radius: 6px;
}
.blank label { display: block; margin-bottom: 20px; font-weight: 500; }
.blank input, .blank select, dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 2px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--dusk-line);
  border-radius: 0;
  color: var(--sheet);
  font: 20px/1.3 var(--body);
}
.blank input::placeholder, dialog input::placeholder { color: #7d6aa3; }
.blank input:focus, .blank select:focus, dialog input:focus { outline: none; border-bottom-color: var(--pumpkin); }
.blank select { appearance: none; cursor: pointer; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23b9a8dd' stroke-width='2' fill='none'/%3E%3C/svg%3E") right 4px center no-repeat; padding-right: 28px; }
.blank select option { background: var(--dusk); color: var(--sheet); }

button { font: inherit; cursor: pointer; }
.cta {
  display: inline-block;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--pumpkin);
  box-shadow: 0 4px 0 var(--pumpkin-deep);
  color: var(--night);
  font: 26px/1 var(--display);
  text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.cta:hover { background: #ff9a45; }
.cta:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pumpkin-deep); }
.cta:disabled { opacity: .5; cursor: wait; }
.blank .cta { margin-top: 4px; }

button.secondary {
  padding: 12px 20px;
  border: 2px solid var(--dusk-line);
  border-radius: 999px;
  background: transparent;
  color: var(--sheet);
}
button.secondary:hover { border-color: var(--moon); }
button.link { padding: 0; border: 0; background: none; color: var(--moon); text-decoration: underline; }
button.link:hover { color: var(--sheet); }

.note { margin: 0 0 16px; color: var(--pumpkin); }
.error { color: var(--error); }
.note.error { color: var(--error); }
.muted { color: var(--moon); }
.counter { margin: 0; color: var(--moon); font-size: 15px; }

.result h2 { margin: 0 0 12px; font: 32px/1.1 var(--display); }
.result input { font-size: 18px; color: var(--pumpkin); }
.result .cta { font-size: 22px; margin-top: 16px; }
#result-img { display: block; width: 100%; margin-top: 20px; border-radius: 6px; }

#history { margin-top: 48px; }
#history h2 { margin: 0 0 6px; font: 32px/1.1 var(--display); }
#history-list { margin: 16px 0 0; padding: 0; list-style: none; }
#history-list li { padding: 12px 0; border-bottom: 1px dashed var(--dusk-line); }
#history-list li a { color: var(--sheet); }
#history-list li.muted { color: #85749f; }

/* ---------- login dialog ---------- */

dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 28px 22px 20px;
  background: var(--dusk);
  color: var(--sheet);
  border: 2px dashed var(--dusk-line);
  border-radius: 6px;
}
dialog::backdrop { background: rgb(12 6 22 / .75); }
dialog h2 { margin: 0 0 6px; font: 30px/1.1 var(--display); }
dialog form > * { margin: 0 0 16px; }
dialog input[name=code] { font-size: 32px; letter-spacing: 10px; }

/* ---------- loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  background: rgb(18 10 30 / .92);
  text-align: center;
}
.loader[hidden] { display: none; }
.loader .ghost { width: 110px; animation: float 1.6s ease-in-out infinite; }
.loader p { max-width: 22ch; margin: 0; font: 26px/1.2 var(--display); }

/* ---------- curse page: a decree from the Chancellery ---------- */

/* Centered on screen; the card grows with a long name instead of overflowing */
main.decree-page {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  min-height: 100vh;
  padding: 56px 16px;
}
.decree-wrap { position: relative; width: fit-content; min-width: min(560px, 100%); max-width: min(1100px, 100%); }
.decree {
  position: relative;
  padding: 36px 28px 28px;
  background: var(--dusk);
  border: 2px dashed var(--dusk-line);
  border-radius: 6px;
}
/* On narrow screens the longest word of the name must fit: ~0.66em per letter of the display face */
.decree h1 { margin: 0 0 24px; font: min(64px, max(20px, (100vw - 100px) / (var(--longest, 8) * 0.66)))/1 var(--display); overflow-wrap: anywhere; }
.decree h1 span { display: block; }
.decree dl { margin: 0 0 20px; }
.decree dt { color: var(--moon); font-size: 15px; font-weight: 500; }
.decree dd { margin: 2px 0 16px; font-size: 24px; line-height: 1.3; }
.decree .muted { margin: 0; font-size: 15px; }
.stamp {
  position: absolute;
  top: -18px;
  right: 14px;
  padding: 4px 12px;
  border: 3px solid var(--seal);
  border-radius: 6px;
  color: var(--seal);
  font: 22px/1 var(--display);
  transform: rotate(8deg);
  background: var(--night);
}

/* Both buttons share one height and sit centered under the card */
.actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 12px 16px; margin-top: 28px; }
.actions > * { flex: 1 1 auto; }
.actions form { display: flex; }
.actions .cta, .actions .secondary { display: inline-flex; flex: 1; align-items: center; justify-content: center; height: 56px; margin: 0; line-height: 1; white-space: nowrap; }
.actions .danger {
  display: inline-flex; flex: 1; align-items: center; justify-content: center; height: 56px; padding: 0 24px;
  border: 0; border-radius: 999px; background: var(--seal); color: var(--sheet); font-weight: 700; white-space: nowrap;
}
.actions .danger:hover { background: #ef5a50; }
dialog.confirm p { margin: 0; font-size: 20px; line-height: 1.4; }
dialog.confirm .actions { margin-top: 24px; }
.actions .cta { padding: 0 24px; font-size: clamp(17px, 5.5vw, 22px); }
.actions .secondary { padding: 0 24px; }

.decree-wrap .ghost { display: block; width: 64px; margin: 36px auto 0; opacity: .9; animation: float 4.5s ease-in-out infinite; }
@media (min-width: 760px) {
  .decree-wrap .ghost { position: absolute; top: 40%; right: -64px; width: 88px; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ghost { animation: none !important; }
  .cta { transition: none; }
}

/* ---------- share ---------- */

.share { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.share[hidden], .share li[hidden] { display: none; }
.pill {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--dusk-line);
  border-radius: 999px;
  background: transparent;
  color: var(--sheet);
  font-size: 15px;
  text-decoration: none;
}
.pill:hover { border-color: var(--moon); }
.share [data-native] .pill { border-color: var(--pumpkin); color: var(--pumpkin); }
.decree-wrap .share { justify-content: center; width: 0; min-width: 100%; } /* must not widen the card */

/* ---------- footer ---------- */

.footer { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; color: #85749f; font-size: 14px; }
.footer p { margin: 0 0 8px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer a { color: #85749f; }
.footer a:hover { color: var(--sheet); }
.decree-page ~ .footer { text-align: center; }
.decree-page ~ .footer nav { justify-content: center; }

/* ---------- legal pages ---------- */

/* Sized by the longest word so e.g. "Datenschutzerklärung" never breaks mid-word */
.legal h1 { margin: 16px 0 4px; font: min(40px, (100vw - 32px) / (var(--longest, 12) * 0.68))/1.1 var(--display); overflow-wrap: anywhere; }
.legal h2 { margin: 32px 0 8px; font-size: 20px; }
.legal p { max-width: 65ch; }
