/* QR – ein Blatt aus dem karierten Schulheft: blaue Kästchen, roter Rand,
   gelber Textmarker für das Wichtige und der QR-Code als eingeklebtes Foto. */

@font-face {
  font-family: 'Recursive';
  src: url(/fonts/recursive-latin.woff2) format('woff2-variations');
  font-weight: 300 1000; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Recursive';
  src: url(/fonts/recursive-latin-ext.woff2) format('woff2-variations');
  font-weight: 300 1000; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #FFFFFF;
  --grid: #DCE5F1;
  --margin: #E5483D;
  --ink: #16224A;
  --ink-soft: #4A5578;
  --line: #B9C6DA;
  --marker: #FFE45C;
  --marker-soft: #FFF6B8;
  --warn-bg: #FFF1EF;
  --warn-ink: #8A1C12;
  --casual: 'CASL' 1;
  --linear: 'CASL' 0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Recursive', system-ui, sans-serif;
  font-variation-settings: var(--linear);
  font-size: 1rem; line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
/* der rote Heftrand */
body::before {
  content: ''; position: fixed; top: 0; bottom: 0; left: clamp(10px, 4vw, 56px);
  width: 2px; background: var(--margin); opacity: .75; pointer-events: none; z-index: 0;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; font-variation-settings: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[lang=de] [data-only=en], html[lang=en] [data-only=de] { display: none; }

/* ─── Kopf ─── */
.top {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 1160px; margin: 0 auto;
  padding: 18px clamp(20px, 4vw, 40px) 0 clamp(26px, calc(4vw + 28px), 92px);
}
.wordmark {
  font-size: 2.5rem; font-weight: 1000; line-height: 1; letter-spacing: -.04em;
  font-variation-settings: var(--casual);
  color: var(--ink); text-decoration: none;
}
.wordmark span { color: var(--margin); }
.lang { font-weight: 650; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 4px; padding: 8px 2px; }

/* ─── Blatt ─── */
.sheet {
  position: relative; z-index: 1;
  flex: 1; width: 100%; max-width: 1160px; margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 40px) 48px clamp(26px, calc(4vw + 28px), 92px);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px;
}
@media (min-width: 940px) {
  .sheet {
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    grid-template-areas: "intro intro" "design stage";
    column-gap: 64px;
  }
  .intro { grid-area: intro; }
  .design { grid-area: design; }
  .stage { grid-area: stage; position: sticky; top: 24px; align-self: start; }
}
.intro h1 {
  font-size: clamp(2.1rem, 5.4vw, 3.9rem);
  font-weight: 900; line-height: 1.02; letter-spacing: -.03em;
  font-variation-settings: var(--casual);
  max-width: 15ch;
}
.sub { margin-top: 12px; font-size: 1.125rem; color: var(--ink-soft); max-width: 46ch; }

/* ─── Vorschau: eingeklebtes Foto ─── */
.stage { display: flex; flex-direction: column; gap: 18px; }
.photo {
  position: relative;
  background: #fff;
  padding: 18px;
  border: 1px solid #E3E8F0;
  box-shadow: 0 16px 30px -14px rgba(22, 34, 74, .45);
  transform: rotate(-1.2deg);
}
.photo img {
  display: block; width: 100%; height: auto;
  /* Schachbrett zeigt einen durchsichtigen Hintergrund */
  background: repeating-conic-gradient(#EEF1F6 0% 25%, #FFFFFF 0% 50%) 50% / 16px 16px;
  transition: opacity .15s;
}
.photo img.stale { opacity: .3; }
.tape {
  position: absolute; top: -14px; width: 96px; height: 30px;
  background: rgba(255, 228, 92, .72);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.tape-l { left: -18px; transform: rotate(-32deg); }
.tape-r { right: -18px; transform: rotate(28deg); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.size { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 650; flex: 1 1 100%; }
.size select {
  min-height: 46px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink);
}
.warnings { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.warnings li {
  background: var(--warn-bg); color: var(--warn-ink);
  border-left: 4px solid var(--margin); border-radius: 0 10px 10px 0;
  padding: 8px 12px; font-size: .9375rem; font-weight: 600; line-height: 1.4;
}
.hint { color: var(--ink-soft); font-size: .9375rem; }

/* ─── Knöpfe ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px; font-weight: 750; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.btn-mark { background: var(--marker); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-line { background: #fff; color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-mark:active:not(:disabled), .btn-line:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-quiet { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 4px; padding: 0 6px; font-weight: 650; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Gestalten ─── */
.design { display: flex; flex-direction: column; gap: 40px; max-width: 620px; }
.group { border: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.group legend {
  font-size: 1.75rem; font-weight: 900; line-height: 1.1; letter-spacing: -.02em;
  font-variation-settings: var(--casual);
  margin-bottom: 14px; padding: 0 4px;
  /* Textmarker */
  background: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 92%, transparent 92%);
}
.label, .field > span { font-weight: 700; font-size: .9375rem; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input[type=url], .field input[type=text] {
  min-height: 52px; padding: 0 14px;
  background: #fff; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 12px; outline: none;
  font-size: 1.0625rem;
}
.field input:focus { box-shadow: 0 0 0 4px var(--marker); }
.url-info { font-size: .875rem; color: var(--ink-soft); overflow-wrap: anywhere; min-height: 1.3em; }
.url-info.bad { color: var(--warn-ink); font-weight: 650; }

.presets { display: flex; flex-wrap: wrap; gap: 16px; padding: 6px; }
.preset {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 0 4px var(--swbg), 0 0 0 6px var(--line);
}
.preset[aria-pressed=true] { box-shadow: 0 0 0 4px var(--swbg), 0 0 0 7px var(--ink); }

.colors { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.color { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; cursor: pointer; }
.color.off { opacity: .45; }
.color input {
  -webkit-appearance: none; appearance: none;
  width: 44px; height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 50%;
  background: none; cursor: pointer; overflow: hidden;
}
.color input::-webkit-color-swatch-wrapper { padding: 0; }
.color input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color input::-moz-color-swatch { border: 0; border-radius: 50%; }

.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; align-self: flex-start; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  position: relative;
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 92px; padding: 10px 10px 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  font-size: .875rem; font-weight: 650; cursor: pointer;
}
.choices-text .choice { min-width: 0; flex-direction: row; padding: 10px 14px; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice svg { width: 34px; height: 34px; fill: var(--ink); }
.choice:has(input:checked) { border-color: var(--ink); background: var(--marker-soft); box-shadow: 2px 2px 0 var(--ink); }
.choice:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }

.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.logo-thumb { width: 52px; height: 52px; object-fit: contain; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 4px; }
.file { position: relative; cursor: pointer; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.range input { width: 100%; max-width: 320px; accent-color: var(--ink); }
.range output { font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.note { font-size: .875rem; color: var(--ink-soft); }
.error { color: var(--warn-ink); font-weight: 650; font-size: .9375rem; }
.error:empty { display: none; }
.frame-options { display: flex; flex-direction: column; gap: 14px; }
.reset { align-self: flex-start; }

/* ─── Handy: Vorschau bleibt oben sichtbar ─── */
@media (max-width: 939px) {
  .stage {
    position: sticky; top: 0; z-index: 5;
    display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 10px 16px; align-items: center;
    margin: 0 calc(-1 * clamp(20px, 4vw, 40px)) 0 calc(-1 * clamp(26px, calc(4vw + 28px), 92px));
    padding: 12px clamp(20px, 4vw, 40px) 12px clamp(26px, calc(4vw + 28px), 92px);
    background: #fff;
    border-bottom: 2px solid var(--grid);
  }
  .presets { gap: 12px; }
  .preset { width: 38px; height: 38px; }
  .choices:not(.choices-text) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices:not(.choices-text) .choice { flex-direction: row; justify-content: flex-start; gap: 10px; min-width: 0; padding: 10px 12px; }
  .choice svg { width: 28px; height: 28px; flex-shrink: 0; }
  .photo { padding: 7px; transform: rotate(-2deg); }
  .tape { width: 44px; height: 14px; top: -6px; }
  .tape-l { left: -10px; } .tape-r { right: -10px; }
  .actions { gap: 8px; }
  .actions .size { display: none; }
  .actions .btn { min-height: 42px; padding: 0 12px; font-size: .9375rem; flex: 1 1 auto; }
  .warnings, .hint { grid-column: 1 / -1; }
  .warnings li { font-size: .8125rem; padding: 6px 10px; }
  .hint { display: none; }
}

/* ─── Fuß ─── */
.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 22px;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}
.link { color: var(--ink-soft); font-weight: 650; text-decoration: underline; text-underline-offset: 4px; padding: 6px 2px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 650;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(22, 34, 74, .6); }
.doc { margin: auto; width: min(100% - 24px, 680px); max-height: min(100dvh - 24px, 900px); background: #fff; border-radius: 16px; padding: 0; }
.doc article { padding: 32px 24px 36px; }
.doc h2 { font-size: 2rem; font-weight: 900; line-height: 1.1; font-variation-settings: var(--casual); margin-bottom: 18px; padding-right: 44px; }
.doc h3 { font-size: 1.0625rem; font-weight: 800; margin: 20px 0 6px; }
.doc p { line-height: 1.6; max-width: 68ch; }
.doc a { color: var(--ink); }
.doc-close { position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 26px; line-height: 1; }
.noscript { padding: 40px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
}
