/* ==========================================================================
   Wrapper – Design-Tokens
   ========================================================================== */
:root {
  --canvas: #112250;
  --panel: rgba(245, 240, 233, 0.06);
  --panel-strong: rgba(245, 240, 233, 0.10);
  --border: rgba(224, 197, 143, 0.30);
  --border-soft: rgba(245, 240, 233, 0.13);
  --ink: #F5F0E9;
  --muted: #CDBFB5;
  --muted-2: #929AB4;

  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* Feste Marken-Akzentfarbe der Oberflaeche: Quicksand */
  --accent: #E0C58F;
  --accent-soft: rgba(224, 197, 143, 0.35);
  --on-accent: #112250;
  /* Vom Nutzer gewaehlte App-Farbe (wird von app.js gesetzt) */
  --app-color: #3C507D;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  overflow-x: hidden;
}

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

a, button, input {
  font-family: inherit;
  color: inherit;
}

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

/* ==========================================================================
   Rotierender Hintergrund (Marine- und Sand-Toene der Markenpalette)
   Zwei uebereinanderliegende Layer werden von app.js per Opacity
   uebergeblendet – so bleibt der Farbwechsel weich, ohne dass der Browser
   einzelne Farbwerte animieren muss.
   ========================================================================== */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0;
  transition: opacity 3.5s ease;
  background-repeat: no-repeat;
}
.bg-layer.is-active { opacity: 1; }

.bg-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (prefers-reduced-motion: reduce) {
  .bg-layer { transition: none; }
}

/* ==========================================================================
   Layout
   ========================================================================== */
.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, white));
  transition: background 1.2s ease;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding: 8px 0 44px;
  max-width: 640px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 5.4vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
}

.hero-sub {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
  max-width: 52ch;
}

/* ==========================================================================
   Glass-Panel (Generator) – der eigentliche Kern der Seite
   ========================================================================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

.generator {
  padding: 36px;
}

@media (max-width: 640px) {
  .generator { padding: 22px; }
}

.field { margin-bottom: 22px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

.field label, .field-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 9px;
}

.field-optional { color: var(--muted-2); font-weight: 400; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

input[type="text"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 0.98rem;
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease;
}

input[type="text"]::placeholder { color: var(--muted-2); }

input[type="text"]:focus {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.32);
}

input[type="text"]:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.mono-input { font-family: var(--font-mono); font-size: 0.92rem; letter-spacing: -0.01em; }

/* ---- Anzeigemodus (Phone-Mockups) ---- */
.mode-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 12px 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.mode-option:hover { transform: translateY(-1px); }

.mode-option.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, rgba(0,0,0,0.18));
}

.phone-mock { width: 56px; height: auto; }
.phone-frame { fill: rgba(255,255,255,0.06); stroke: rgba(255,255,255,0.28); stroke-width: 2; }
.phone-statusbar { fill: var(--app-color); stroke: rgba(245, 240, 233, 0.4); stroke-width: 1; transition: fill 0.4s ease; }
.phone-content { fill: rgba(255,255,255,0.14); }

.mode-label { font-weight: 600; font-size: 0.92rem; }
.mode-hint { font-size: 0.76rem; color: var(--muted-2); text-align: center; }

/* ---- Farbauswahl ---- */
.swatch-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.swatch-row-label {
  width: 76px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted-2);
}

.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.swatch:hover { transform: scale(1.1); }

.swatch.is-selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.16);
}

/* ---- Icon-Upload ---- */
.dropzone {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.03);
}

.dropzone-preview {
  width: 44px; height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.08);
  background-size: cover;
  background-position: center;
}

.dropzone-text { font-size: 0.85rem; color: var(--muted); }

/* ---- Submit ---- */
.submit-button {
  width: 100%;
  margin-top: 6px;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ffffff 15%));
  color: var(--on-accent);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 1.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.submit-button:hover { transform: translateY(-1px); }
.submit-button:disabled { opacity: 0.6; cursor: progress; transform: none; }

.submit-spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: var(--on-accent);
  display: none;
  animation: spin 0.7s linear infinite;
}

.submit-button.is-loading .submit-spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #FCA5A5;
  font-size: 0.88rem;
}

/* ---- Build-Status ---- */
.build-status {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
}

.build-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.build-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.build-status-dot.is-success { background: #34D399; animation: none; }
.build-status-dot.is-failed { background: #F87171; animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.build-progress-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.build-progress-bar {
  height: 100%;
  width: 8%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 1.1s ease, background 1.2s ease;
}

.download-card {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(52, 211, 153, 0.09);
  border: 1px solid rgba(52, 211, 153, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.download-meta { font-size: 0.82rem; color: var(--muted); font-family: var(--font-mono); }

.download-button {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: #34D399;
  color: #052e21;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
}

.build-log {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ==========================================================================
   Ablauf-Schritte (echte Sequenz -> Nummerierung gerechtfertigt)
   ========================================================================== */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 64px 0;
}

@media (max-width: 720px) {
  .steps { grid-template-columns: 1fr; }
}

.step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.step h3 { font-family: var(--font-display); font-size: 1.05rem; margin: 0 0 8px; }
.step p { color: var(--muted); font-size: 0.92rem; line-height: 1.55; margin: 0; }

/* ==========================================================================
   Feature-Zeilen (bewusst KEINE einheitlichen Karten mit gleichem Schatten)
   ========================================================================== */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 40px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 640px) {
  .features { grid-template-columns: 1fr; }
}

.feature {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.feature svg {
  width: 24px; height: 24px;
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--accent);
  transition: color 1.2s ease;
}

.feature h4 { margin: 0 0 6px; font-size: 0.98rem; font-weight: 600; }
.feature p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: 70px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted-2);
  font-size: 0.82rem;
  text-align: center;
}

/* ==========================================================================
   Build-Konsole (Plain-Text-Protokoll unter dem Fortschrittsbalken)
   ========================================================================== */
.build-console {
  margin-top: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(8, 16, 42, 0.72);
  overflow: hidden;
}

.build-console-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-soft);
}

.build-console-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.build-console-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.console-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.console-btn:hover { background: rgba(255, 255, 255, 0.1); }
.console-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }

.build-console-meter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 8px 12px;
  color: var(--ink);
  white-space: pre;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
}

.build-console-output {
  margin: 0;
  padding: 10px 12px;
  height: 340px;
  min-height: 140px;
  resize: vertical;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #E4DED6;
  tab-size: 4;
}

.build-console-output:focus-visible { outline-offset: -2px; }

.build-console-output .cl { display: block; }
.build-console-output .lvl-step   { color: var(--accent); font-weight: 500; }
.build-console-output .lvl-ok     { color: #34D399; }
.build-console-output .lvl-warn   { color: #FBBF24; }
.build-console-output .lvl-error  { color: #F87171; font-weight: 500; }
.build-console-output .lvl-gradle { color: #929AB4; }
.build-console-output .lvl-client { color: #AEBBE0; }
.build-console-output.hide-gradle .lvl-gradle { display: none; }

@media (max-width: 640px) {
  .build-console-output { height: 260px; font-size: 0.68rem; }
  .build-console-meter { font-size: 0.7rem; }
}
