/* ==========================================================================
   Jorvik-Dämmerung — Star Stable Online Code-Board
   Dunkle, atmosphärische Palette; alles selbst gehostet, keine externen
   Requests. Mobile-first: die Buttons und der Code selbst sind die
   Hauptaktion, nicht Deko.
   ========================================================================== */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces-italic500.woff2') format('woff2');
}
@font-face {
  font-family: 'Karla';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/karla-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Karla';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url('/assets/fonts/karla-italic400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/dmmono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/dmmono-500.woff2') format('woff2');
}

:root {
  --night: #0b1119;
  --night-deep: #070b11;
  --forest: #15221c;
  --forest-line: #24382f;
  --gold: #e8b96c;
  --gold-dim: #a98950;
  --aurora: #6fbfa8;
  --aurora-dim: #3f7568;
  --ember: #c4614f;
  --ember-dim: #7a3c32;
  --parchment: #ede4d3;
  --dusk: #8a95a3;
  --radius: 18px;
  --wrap: 640px;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scrollbar-color: var(--gold-dim) var(--night);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  color: var(--parchment);
  font-family: 'Karla', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ---- Atmosphäre: Sternenfeld + Aurora-Schleier + Korn ---- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: var(--night);
  background-image:
    radial-gradient(1.5px 1.5px at 8% 12%, rgba(237,228,211,.55) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 34%, rgba(237,228,211,.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 39% 8%, rgba(237,228,211,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 61% 22%, rgba(237,228,211,.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 45%, rgba(237,228,211,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 14%, rgba(237,228,211,.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 15% 62%, rgba(237,228,211,.35) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 71%, rgba(237,228,211,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 84%, rgba(237,228,211,.3) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 93% 66%, rgba(237,228,211,.4) 50%, transparent 51%),
    linear-gradient(180deg, var(--night-deep) 0%, var(--night) 40%, #0a1512 100%);
  background-repeat: no-repeat;
  background-size: cover;
}
.sky::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -20%;
  width: 140%;
  height: 60%;
  background: conic-gradient(from 200deg at 50% 50%,
    rgba(111,191,168,.14), rgba(232,185,108,.10), rgba(111,191,168,.0) 40%, transparent 70%);
  filter: blur(60px);
  animation: aurora-drift 26s ease-in-out infinite alternate;
}
.sky::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes aurora-drift {
  from { transform: translateX(-4%) translateY(0); }
  to   { transform: translateX(4%) translateY(3%); }
}
@media (prefers-reduced-motion: reduce) {
  .sky::before { animation: none; }
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Kopf ---- */
.site-head {
  padding: 56px 0 28px;
  text-align: center;
}
.eyebrow {
  margin: 0 0 6px;
  font-family: 'Karla', sans-serif;
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.site-head h1 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-optical-sizing: auto;
  font-weight: 560;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  letter-spacing: -0.01em;
  color: var(--parchment);
}
.site-head h1 .dot { color: var(--gold); }
.lede {
  max-width: 34ch;
  margin: 10px auto 0;
  color: var(--dusk);
  font-size: .98rem;
}
.meta {
  margin: 18px 0 0;
  font-size: .85rem;
  color: var(--dusk);
}
.meta strong {
  color: var(--gold);
  font-family: 'DM Mono', monospace;
  font-weight: 500;
}

/* ---- Leerer Zustand ---- */
.empty {
  text-align: center;
  padding: 60px 20px 40px;
  color: var(--dusk);
}
.empty-glyph { font-size: 2.4rem; margin: 0 0 6px; }
.empty-sub { font-size: .9rem; margin-top: 4px; }

/* ---- Karten ---- */
.code-list {
  list-style: none;
  margin: 0 0 36px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(21,34,28,.92), rgba(15,24,20,.88));
  border: 1px solid var(--forest-line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  backdrop-filter: blur(6px);
  overflow: hidden;
  transition: max-height .38s ease, opacity .3s ease, transform .3s ease, margin .38s ease, padding .38s ease;
  max-height: 400px;
  animation: card-in .5s cubic-bezier(.2,.8,.3,1) backwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 14px; right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .55;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}
.card.is-leaving {
  max-height: 0;
  opacity: 0;
  transform: scale(.97);
  margin-bottom: -14px;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  pointer-events: none;
}
.card.is-flagged {
  border-color: var(--ember-dim);
}
.card.is-flagged::before {
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.code-copy {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 8px;
}
.code-copy:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}
.code-text {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: .04em;
  color: var(--gold);
  transition: color .2s ease;
}
.code-copy.copied .code-text { color: var(--aurora); }
.copy-hint {
  font-size: .72rem;
  color: var(--dusk);
  letter-spacing: .02em;
}
.code-copy.copied .copy-hint::before { content: 'Kopiert ✓ · '; color: var(--aurora); }

.reward {
  font-size: .82rem;
  color: var(--parchment);
  background: rgba(232,185,108,.1);
  border: 1px solid rgba(232,185,108,.25);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.desc {
  margin: 10px 0 0;
  color: #cdd6d1;
  font-size: .92rem;
}

.flag-badge {
  margin: 10px 0 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(196,97,79,.12);
  border: 1px solid rgba(196,97,79,.3);
  color: #e08a7a;
  font-size: .8rem;
}

.card-meta {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: .78rem;
  color: var(--dusk);
}
.source {
  color: var(--aurora);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.source:hover, .source:focus-visible { border-bottom-color: var(--aurora); }

.actions {
  display: flex;
  gap: 10px;
  margin: 16px 0 0;
}
.btn {
  flex: 1;
  appearance: none;
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 12px;
  font-family: 'Karla', sans-serif;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-ok {
  background: rgba(111,191,168,.14);
  border-color: var(--aurora-dim);
  color: var(--aurora);
}
.btn-ok:hover { background: rgba(111,191,168,.22); }
.btn-no {
  background: rgba(196,97,79,.12);
  border-color: var(--ember-dim);
  color: #e08a7a;
}
.btn-no:hover { background: rgba(196,97,79,.2); }

/* ---- Zuletzt erledigt ---- */
.resolved-box {
  margin: 0 0 40px;
  border: 1px solid var(--forest-line);
  border-radius: var(--radius);
  padding: 4px 18px;
  background: rgba(21,34,28,.5);
}
.resolved-box summary {
  cursor: pointer;
  padding: 14px 0;
  font-size: .88rem;
  color: var(--dusk);
  list-style: none;
}
.resolved-box summary::-webkit-details-marker { display: none; }
.resolved-box summary::before { content: '▸ '; color: var(--gold-dim); }
.resolved-box[open] summary::before { content: '▾ '; }
.resolved-list {
  list-style: none;
  margin: 0;
  padding: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.resolved-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
}
.resolved-code {
  font-family: 'DM Mono', monospace;
  color: var(--parchment);
}
.resolved-status { font-size: .74rem; color: var(--dusk); }
.resolved-status.is-dead { color: #e08a7a; }
.resolved-status.is-done { color: var(--aurora); }
.undo-form { margin-left: auto; }
.btn-undo {
  appearance: none;
  background: none;
  border: 1px solid var(--forest-line);
  color: var(--dusk);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: .76rem;
  cursor: pointer;
}
.btn-undo:hover { color: var(--gold); border-color: var(--gold-dim); }

/* ---- Footer ---- */
.site-foot {
  padding: 20px 0 60px;
  text-align: center;
}
.site-foot p {
  max-width: 40ch;
  margin: 0 auto;
  font-size: .76rem;
  color: var(--dusk);
  opacity: .8;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #1a2b23;
  border: 1px solid var(--forest-line);
  color: var(--parchment);
  padding: 12px 14px 12px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  font-size: .88rem;
  z-index: 20;
  animation: toast-in .25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast .toast-undo {
  appearance: none;
  background: none;
  border: none;
  color: var(--gold);
  font-weight: 700;
  cursor: pointer;
  padding: 4px;
}

@media (min-width: 600px) {
  .card { padding: 22px 24px 20px; }
  .code-text { font-size: 1.7rem; }
}
