@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #eef1f4;
  --field: #f9fafb;
  --ink: #18202b;
  --muted: #5a6573;
  --rule: #cdd4dc;
  --accent: #3440c9;
  --accent-hover: #2831a6;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --sans: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b23;
    --field: #1d2430;
    --ink: #e4e9ef;
    --muted: #9aa5b3;
    --rule: #2f3845;
    --accent: #9aa2ff;
    --accent-hover: #b6bcff;
    --accent-ink: #121634;
    --danger: #ff9b8f;
  }
}

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

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

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

code {
  font-family: var(--mono);
  font-size: .875em;
}

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding-inline: 1.25rem;
  padding-block: 3.5rem 4rem;
}

/* Kopf: Titel mit Spiegelung */

.masthead { margin-bottom: 2.5rem; }

.title {
  position: relative;
  margin: 0 0 .5em;
  font-size: clamp(2.75rem, 11vw, 6.5rem);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.045em;
}

.title a {
  color: inherit;
  text-decoration: none;
}

.title::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  transform: scaleY(-1);
  color: var(--accent);
  pointer-events: none;
  -webkit-mask: linear-gradient(to top, rgb(0 0 0 / .32), transparent 48%);
  mask: linear-gradient(to top, rgb(0 0 0 / .32), transparent 48%);
}

.title.ripple::after {
  animation: ripple 1.2s cubic-bezier(.2, .7, .2, 1);
}

@keyframes ripple {
  0%   { transform: scaleY(-1); }
  25%  { transform: scaleY(-1) skewX(-10deg) translateX(.06em); }
  55%  { transform: scaleY(-1) skewX(6deg) translateX(-.04em); }
  80%  { transform: scaleY(-1) skewX(-2deg); }
  100% { transform: scaleY(-1); }
}

.lede {
  margin: 0;
  font-size: 1.25rem;
  position: relative;
}

/* Pfad */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .5rem;
  margin-bottom: 1.25rem;
  font-size: 1.125rem;
}

.crumbs a {
  color: var(--accent);
  text-underline-offset: .2em;
}

.crumbs a:hover { color: var(--accent-hover); }
.crumbs .sep { color: var(--muted); }
.crumbs [aria-current] { font-weight: 700; }

/* Filter */

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .75rem 1rem;
  margin-bottom: 1rem;
}

.search input,
.sort select {
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  min-height: 2.75rem;
}

.search input {
  width: 100%;
  padding: .625rem .875rem;
}

.search input::placeholder { color: var(--muted); }

.sort {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
}

.sort select { padding: .5rem .625rem; }

.summary {
  margin: 0 0 .5rem;
  color: var(--muted);
}

/* Liste */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--rule);
}

.list:empty { display: none; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem 2rem;
  align-items: start;
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule);
}

.name {
  margin: 0;
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin: .25rem 0 0;
  color: var(--muted);
}

.folder {
  padding-block: 0;
}

.folder a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem 1.25rem;
  padding-block: 1rem;
  color: inherit;
  text-decoration: none;
  grid-column: 1 / -1;
}

.folder .name { color: var(--accent); }
.folder .name::after { content: "/"; color: var(--muted); font-weight: 400; margin-left: .1em; }
.folder a:hover .name { text-decoration: underline; text-underline-offset: .2em; }
.folder .meta { margin: 0; }

.hash {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  margin-top: .625rem;
  font-size: .875rem;
  color: var(--muted);
}

.hash code {
  color: var(--ink);
  font-size: .8125rem;
  overflow-wrap: anywhere;
  min-width: 0;
}

.linkish {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}

.linkish:hover { color: var(--accent-hover); }
.linkish:disabled { color: var(--muted); text-decoration: none; cursor: default; }

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .5rem 1.125rem;
  font: inherit;
  font-weight: 600;
  border-radius: .5rem;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

.btn-quiet:hover { border-color: var(--muted); }
.btn-quiet:disabled { color: var(--muted); cursor: default; }

/* Leer, Fehler */

.state {
  padding-block: 2.5rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.state p { margin: 0 0 1rem; font-size: 1.125rem; max-width: 36rem; }
.state p:last-child { margin-bottom: 0; }

.foot {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: .9375rem;
  max-width: 42rem;
}

.foot code { color: var(--ink); }
.foot a { color: var(--accent); text-underline-offset: .2em; }

/* Geschützte Downloads */

.notice {
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  max-width: 44rem;
  background: var(--field);
  border-left: 3px solid var(--accent);
}

.code-form {
  grid-column: 1 / -1;
  padding: 1rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: .5rem;
}

.code-form label,
.panel > label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.code-form input,
.panel input {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  min-height: 2.75rem;
  padding: .5rem .75rem;
}

.code-input {
  width: 12rem;
  font-family: var(--mono) !important;
  letter-spacing: .08em;
}

.form-msg {
  margin: .625rem 0 0;
  color: var(--danger);
}

.form-msg:empty { display: none; }

.form-done {
  margin: 0 0 .5rem;
  max-width: 40rem;
}

.signed {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .75rem;
  margin-bottom: .75rem;
}

.signed code {
  font-size: .8125rem;
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Code-Verwaltung */

.page-head { margin-bottom: 2rem; }

.wordmark {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}

.page-title {
  margin: .5rem 0;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.035em;
}

.panel {
  margin-bottom: 2.5rem;
  padding: 1.25rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: .75rem;
}

.panel h2,
.codes-head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -.01em;
}

.panel h2 { margin-bottom: 1rem; }

.form-grid {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto;
  align-items: end;
  gap: .75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  font-weight: 600;
}

.form-grid input { width: 100%; }

.form-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1rem;
  margin-top: 1rem;
}

.form-result:empty { display: none; }
.form-result p { margin: 0; }

.codes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1.25rem;
  margin-bottom: .75rem;
}

.codes-head .summary { margin: 0; }
.codes-head .spacer { flex: 1; }

.code {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.375rem;
  letter-spacing: .06em;
}

.is-spent .code {
  color: var(--muted);
  text-decoration: line-through;
}

.is-new .code { color: var(--accent); }

@media (max-width: 40rem) {
  .wrap { padding-block: 2rem 3rem; }
  .masthead { margin-bottom: 2rem; }
  .lede { font-size: 1.0625rem; }
  .controls { grid-template-columns: 1fr; }
  .item { grid-template-columns: minmax(0, 1fr); }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .code-input { flex: 1 1 10rem; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .title.ripple::after { animation: none; }
}
