/* ════════════════════════════════════════════════════════════════════
   HAUSBAU SPA - MODERN STYLES
   ════════════════════════════════════════════════════════════════════ */


*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

:root {
  /* Color Palette */
  --sand: #f0e6d3;
  --clay: #c4956a;
  --brick: #a0522d;
  --mortar: #8c7b6b;
  --night: #110d0a;
  --warm: #1f1610;
  --accent: #e8b86d;
  --green: #688a56;
  --red: #d15f53;
  
  /* Glassmorphism */
  --glass-bg: rgba(31, 22, 16, 0.6);
  --glass-border: rgba(232, 184, 109, 0.15);
  
  /* Fonts */
  --font-mono: 'DM Mono', monospace;
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Inter', sans-serif;

  /* Layout */
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
}

body {
  background-color: var(--night);
  background-image: radial-gradient(circle at top right, rgba(232, 184, 109, 0.05), transparent 40%),
                    radial-gradient(circle at bottom left, rgba(232, 184, 109, 0.03), transparent 40%);
  color: var(--sand);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Grain Overlay */
.grain-overlay {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
  opacity: 0.6;
}

/* ── SPA VIEW LOGIC ── */
#app {
  position: relative;
  width: 100%;
  height: 100%;
}

.view {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
  overflow-y: auto;
  overflow-x: hidden;
}

.view.view-active {
  opacity: 1;
  visibility: visible;
  z-index: 10;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 30px calc(80px + var(--safe-area-inset-bottom));
  position: relative;
}

/* ── UTILITIES & COMPONENTS ── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--clay);
  margin-bottom: 12px;
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
  color: var(--sand);
  letter-spacing: -0.02em;
}

h1 span {
  color: var(--accent);
}

.subtitle {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--clay);
  opacity: 0.9;
  letter-spacing: 0.04em;
}

/* Typography */
.font-mono { font-family: var(--font-mono); }

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: linear-gradient(135deg, var(--brick), var(--accent));
  border: none;
  border-radius: 8px;
  padding: 16px;
  color: var(--night);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 15px rgba(232, 184, 109, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232, 184, 109, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.loading .btn-text {
  opacity: 0;
}

.btn-loader {
  display: none;
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(26, 20, 16, 0.3);
  border-top-color: var(--night);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary.loading .btn-loader {
  display: block;
}

.btn-outline {
  padding: 12px 24px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: transparent;
  color: var(--sand);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 184, 109, 0.05);
}

.btn-back-text {
  background: none;
  border: none;
  color: var(--mortar);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  cursor: pointer;
  margin-top: 24px;
  transition: color 0.2s;
}

.btn-back-text:hover {
  color: var(--clay);
}

.btn-biometric {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: rgba(232, 184, 109, 0.08);
  border: 1px solid rgba(232, 184, 109, 0.2);
  border-radius: 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-biometric:hover {
  background: rgba(232, 184, 109, 0.15);
  border-color: rgba(232, 184, 109, 0.4);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mortar);
  text-decoration: none;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-link:hover { color: var(--accent); }
.nav-link svg { width: 14px; height: 14px; }

/* ── DASHBOARD ── */
.house-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.percent-hero {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 50px 0 70px;
}

.percent-number {
  font-family: var(--font-serif);
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 900;
  line-height: 0.85;
  color: var(--accent);
  letter-spacing: -0.04em;
  text-shadow: 0 10px 30px rgba(232, 184, 109, 0.15);
}

.percent-sign {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  color: var(--clay);
  padding-bottom: 12px;
}

.percent-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mortar);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-bottom: 18px;
  margin-left: 10px;
}


.bricks-section { margin: 0 0 50px; }


.bricks-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.brick {
  width: 28px; height: 14px; border-radius: 3px; transition: all 0.4s ease;
}
.brick.filled {
  background: var(--brick);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -1px 0 rgba(0,0,0,0.3);
}
.brick.active {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(232, 184, 109, 0.6);
  animation: pulse-brick 2s infinite;
}
@keyframes pulse-brick {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.brick.empty {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 50px;
}
.stat-box {
  background: var(--glass-bg);
  padding: 24px 22px;
  backdrop-filter: blur(8px);
}
.stat-value {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--sand);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.stat-value.highlight { color: var(--accent); }
.stat-value.muted { color: var(--mortar); }
.stat-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--clay);
  opacity: 0.9;
}

.gallery-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 22px 28px;
  margin-bottom: 50px;
  background: linear-gradient(135deg, rgba(160, 82, 45, 0.8), rgba(232, 184, 109, 0.8));
  border: 1px solid rgba(232, 184, 109, 0.3);
  border-radius: 12px;
  color: var(--night);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(232, 184, 109, 0.2);
}
.gallery-btn:hover {
  background: linear-gradient(135deg, rgba(160, 82, 45, 0.9), rgba(232, 184, 109, 0.9));
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(232, 184, 109, 0.3);
}
.gallery-btn svg { width: 22px; height: 22px; color: var(--night); flex-shrink: 0; }
.gallery-btn-arrow { margin-left: auto; color: var(--night); font-size: 18px; transition: transform 0.3s; }
.gallery-btn:hover .gallery-btn-arrow { transform: translateX(5px); color: var(--night); }

.footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mortar);
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
}
.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 7px;
  animation: pulse-dot 2s infinite;
  vertical-align: middle;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(104,138,86,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 5px rgba(104,138,86,0); }
}

/* ── AUTH VIEWS ── */
.view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
}
.auth-icon { width: 56px; height: 56px; margin-bottom: 20px; }
.auth-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--clay); margin-bottom: 10px; }
.auth-title { font-family: var(--font-serif); font-size: 2.2rem; font-weight: 900; color: var(--sand); margin-bottom: 6px; }
.auth-sub { font-family: var(--font-mono); font-size: 13px; color: var(--clay); opacity: 0.9; margin-bottom: 32px; }

.input-wrap input {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 16px;
  color: var(--sand);
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.input-wrap input:focus { border-color: var(--accent); background: rgba(0,0,0,0.4); }
.auth-error { margin-top: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--red); min-height: 16px; }

/* ── GALLERY ── */
.gallery-page { max-width: 1200px; }
.header { margin-bottom: 50px; }
.header-nav { display: flex; justify-content: center; align-items: center; margin: 0 auto 40px; flex-wrap: wrap; gap: 24px; background: var(--glass-bg); padding: 12px 32px; border-radius: 40px; border: 1px solid var(--glass-border); box-shadow: 0 4px 15px rgba(0,0,0,0.2); width: fit-content; backdrop-filter: blur(12px); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.grid-item {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--warm);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.grid-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  z-index: 2;
}
.grid-item img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.grid-item:hover img { transform: scale(1.08); }

.grid-item .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(17,13,10,0.85) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}
.grid-item:hover .overlay { opacity: 1; }
.overlay-caption {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--sand);
}

.empty-state { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--mortar); background: var(--glass-bg); border-radius: 8px; border: 1px dashed var(--glass-border); }

/* ── UPLOAD ── */
.upload-container {
  padding: 40px;
  border-radius: 12px;
  margin-top: 30px;
}
.drop-zone {
  border: 2px dashed rgba(232, 184, 109, 0.3);
  border-radius: 8px;
  padding: 60px 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  background: rgba(0,0,0,0.1);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(232, 184, 109, 0.05);
}
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop-icon { width: 56px; height: 56px; color: var(--clay); margin: 0 auto 16px; }
.drop-title { font-family: var(--font-serif); font-size: 1.5rem; color: var(--sand); margin-bottom: 8px; }
.drop-sub { font-family: var(--font-mono); font-size: 12px; color: var(--mortar); }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 20px; }
.preview-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.remove-btn {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  background: rgba(17,13,10,0.8); border: none; border-radius: 50%; color: var(--sand); cursor: pointer;
}
.w-full { width: 100%; }

.progress-title { font-family: var(--font-mono); margin-bottom: 16px; color: var(--accent); text-align: center; }
.progress-item { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; background: rgba(0,0,0,0.2); padding: 12px; border-radius: 6px;}
.progress-name { font-family: var(--font-sans); font-size: 12px; color: var(--sand); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-bar-wrap { flex: 2; height: 6px; background: var(--warm); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brick), var(--accent)); width: 0%; transition: width 0.3s; }

#upload-success-section { text-align: center; padding: 20px 0; }
.success-icon { font-size: 48px; margin-bottom: 16px; }
.success-title { font-family: var(--font-serif); font-size: 2rem; color: var(--accent); margin-bottom: 8px; }
.success-sub { font-family: var(--font-sans); font-size: 14px; color: var(--mortar); margin-bottom: 30px; }
.success-actions { display: flex; gap: 16px; justify-content: center; }

/* ── PHOTO VIEWER ── */
.photo-app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--night);
}
.photo-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(17,13,10,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  z-index: 20;
}
.photo-title-wrap { text-align: center; flex: 1; margin: 0 20px; }
.photo-title { font-family: var(--font-sans); font-size: 15px; font-weight: 500; color: var(--sand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.photo-counter { font-family: var(--font-mono); font-size: 11px; color: var(--mortar); margin-top: 4px; }
.photo-actions { display: flex; gap: 8px; }

.viewer-btn {
  background: rgba(255,255,255,0.05); border: 1px solid transparent; border-radius: 8px;
  color: var(--sand); padding: 12px; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px;
}
.viewer-btn:hover { background: rgba(232, 184, 109, 0.15); color: var(--accent); }
.viewer-btn svg { width: 20px; height: 20px; }

.photo-stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.photo-stage {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  touch-action: none; overflow: hidden; cursor: grab;
}
.photo-stage:active { cursor: grabbing; }
#viewer-main-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  will-change: transform;
}

.photo-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px; border-radius: 50%; border: none;
  background: rgba(17,13,10,0.6); color: var(--sand); backdrop-filter: blur(8px);
  cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.photo-nav:hover { background: rgba(232, 184, 109, 0.2); color: var(--accent); scale: 1.1; }
.photo-prev { left: 20px; }
.photo-next { right: 20px; }

.photo-filmstrip {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 24px;
  background: rgba(17,13,10,0.9); border-top: 1px solid rgba(255,255,255,0.05);
}
.filmstrip-item {
  height: 60px; min-width: 90px; border-radius: 4px; overflow: hidden; cursor: pointer;
  opacity: 0.5; transition: opacity 0.2s, border-color 0.2s; border: 2px solid transparent;
}
.filmstrip-item img { width: 100%; height: 100%; object-fit: cover; }
.filmstrip-item.active { opacity: 1; border-color: var(--accent); }
.filmstrip-item:hover { opacity: 0.8; }

/* ── ANIMATIONS ── */
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .page { padding: 40px 20px calc(60px + var(--safe-area-inset-bottom)); }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .photo-topbar { flex-direction: column; padding: 12px; gap: 12px; }
  .photo-actions { width: 100%; justify-content: center; }
  .photo-prev { left: 10px; width: 40px; height: 40px; }
  .photo-next { right: 10px; width: 40px; height: 40px; }
  .upload-container { padding: 20px; }
  .success-actions { flex-direction: column; }
}
