/* Idunn — Stylesheet
 * Branding Q2: warmes Gold, cremiger Hintergrund, dunkle Tinte.
 * Mobile-first; für iPad optimiert (Touch-Targets mind. 44×44 px).
 */

:root {
  --gold: #e8b040;
  --gold-soft: #f5d485;
  --cream: #fdf6e3;
  --cream-deep: #f5ebc8;
  --leaf: #7ba05b;
  --ink: #2a1810;
  --ink-soft: #5a4a3a;
  --border: #d4c4a0;
  --error: #b04a3a;
  --shadow: 0 1px 2px rgba(42, 24, 16, 0.08), 0 4px 12px rgba(42, 24, 16, 0.06);
  --radius: 0.6rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: "Cinzel", "Cormorant Garamond", "Georgia", serif;
  color: var(--ink);
  margin: 0 0 0.6em;
  font-weight: 600;
}
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.3rem; }
p  { margin: 0 0 1em; }

a {
  color: var(--gold);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

code {
  font-family: "SF Mono", Consolas, monospace;
  background: var(--cream-deep);
  padding: 0.1em 0.3em;
  border-radius: 0.2em;
  font-size: 0.9em;
}

/* --- Topbar --------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.2rem;
  background: var(--cream-deep);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Cinzel", "Georgia", serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
}
.brand-icon { font-size: 1.4rem; }
.brand:hover { text-decoration: none; }

.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topnav a {
  color: var(--ink);
  font-weight: 500;
}
.user-chip {
  background: var(--gold-soft);
  color: var(--ink);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* --- Layout --------------------------------------------------------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.2rem 4rem;
}

.footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.footer-meta { font-size: 0.75rem; opacity: 0.7; }

/* --- Buttons -------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--gold-soft); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--cream-deep); text-decoration: none; }
.btn-lg { font-size: 1.1rem; padding: 0.9rem 1.6rem; }

/* --- Flash-Messages ------------------------------------------------- */

.flashes {
  margin-bottom: 1.5rem;
}
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  background: var(--cream-deep);
}
.flash-error {
  background: #f5d4c8;
  border-color: var(--error);
  color: var(--error);
}

/* --- Auth ----------------------------------------------------------- */

.auth-card {
  max-width: 420px;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--cream-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 {
  text-align: center;
  margin-bottom: 0.4em;
}
.auth-card .lede {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 500;
}
.auth-form input {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--cream);
}
.auth-meta {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 1.5rem;
}

/* --- Gallery -------------------------------------------------------- */

.gallery .lede {
  color: var(--ink-soft);
  margin-bottom: 2rem;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.template-card {
  background: var(--cream-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: block;
  color: var(--ink);
  transition: transform 0.15s, box-shadow 0.15s;
}
.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(42, 24, 16, 0.1), 0 8px 24px rgba(42, 24, 16, 0.1);
  text-decoration: none;
}
.template-preview {
  background: var(--cream);
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.template-preview svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.4rem;
}
.template-meta { padding: 1rem 1.2rem 1.2rem; }
.template-meta h2 { margin: 0 0 0.3em; }
.template-meta p { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 0.6em; }
.template-slot-count {
  display: inline-block;
  background: var(--gold);
  color: var(--ink);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.hint {
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: center;
}

/* --- Upload/Stage --------------------------------------------------- */

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.stage-form {
  background: var(--cream-deep);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stage-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 80px;
}
.stage-overlay {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stage-overlay label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 500;
  margin-bottom: 0.8rem;
}
.stage-overlay fieldset {
  border: none;
  padding: 0;
  margin: 0;
}
.stage-overlay legend {
  font-weight: 500;
  margin-bottom: 0.3rem;
  padding: 0;
}
.stage-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* --- Preview -------------------------------------------------------- */

.preview {
  text-align: center;
}
.preview-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.preview-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.preview-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.preview-meta {
  text-align: left;
  background: var(--cream-deep);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 500px;
  margin: 0 auto;
}
.preview-meta summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ink-soft);
}
.preview-meta ul { padding-left: 1.2em; margin: 0.8em 0 0; }
.preview-meta li { margin-bottom: 0.2em; }

/* --- Inputs --------------------------------------------------------- */

input[type="file"] {
  padding: 0.5rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
input[type="text"], input[type="password"] {
  font-family: inherit;
}
input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* --- Touch-Targets ------------------------------------------------- */

@media (pointer: coarse) {
  .btn { min-height: 48px; }
}

/* === Runde 1: Aspect-Ratio-Filter === */
.aspect-filter {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.5rem;
  padding: 0.6rem 0.8rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}
.aspect-pill {
  padding: 0.4rem 0.8rem;
  border-radius: 1rem;
  background: var(--cream);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
}
.aspect-pill:hover { border-color: var(--gold); }
.aspect-pill.active {
  background: var(--gold);
  border-color: var(--ink);
  font-weight: 600;
}
.template-meta .aspect-tag {
  background: var(--cream);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 0.3rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* === Runde 1: Filter- und Pattern-Pills im Upload-Form === */
.opt-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
}
.opt-row .opt-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
  white-space: nowrap;
}
.opt-row .opt-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.opt-row .opt-pill {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.4rem 0.7rem;
  background: #fff;
  font-size: 0.85rem;
  transition: all 0.15s;
  user-select: none;
}
.opt-row .opt-pill:hover { border-color: var(--gold); }
.opt-row .opt-pill input { display: none; }
.opt-row .opt-pill:has(input:checked) {
  background: var(--gold);
  border-color: var(--ink);
  font-weight: 600;
}
.opt-row .opt-pill.filter-bw { background: #e8e8e8; color: #444; }
.opt-row .opt-pill.filter-sepia { background: #d4a574; color: #fff; }
.opt-row .opt-pill.filter-warm { background: #f4c99a; }
.opt-row .opt-pill.filter-cool { background: #a8c8e0; }
.opt-row .opt-pill.filter-bright { background: #fff8dc; }
.opt-row .opt-pill.filter-dark { background: #4a3a2a; color: #f0e0c0; }
.opt-row .opt-pill.filter-contrast { background: linear-gradient(135deg, #fff 50%, #333 50%); color: #222; }

@media (max-width: 600px) {
  .opt-row { grid-template-columns: 1fr; }
}
