/* 
 * SEW THE TASTE - Shared Stylesheet (Refactored)
 * Optimized for iPad Pro (Landscape) & Mobile (Vault)
 */

:root {
  /* Colors */
  --color-bg: #FAF9F6;          /* Linen off-white */
  --color-text: #1C1C1C;        /* Deep charcoal */
  --color-text-muted: #8E8D8A;  /* Soft warm grey */
  --color-border: rgba(28, 28, 28, 0.07);
  --color-border-active: rgba(28, 28, 28, 0.25);
  --color-card-bg: rgba(255, 255, 255, 0.65);
  
  /* Layer Colors */
  --color-layer1: #D95D39;      /* Terracotta */
  --color-layer2: #2E5B82;      /* Indigo */
  --color-layer3: #C08A3E;      /* Copper */
  
  /* Motif Gradients */
  --color-sunset: #D96A4E;      /* Target sunset amber */

  /* Fonts */
  --font-display: 'Jost', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Transitions */
  --transition-speed: 0.5s;
  --transition-bezier: cubic-bezier(0.25, 1, 0.5, 1);
}

/* Global resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

input {
  user-select: text;
  -webkit-user-select: text;
}

.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--color-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 12px 40px 0 rgba(28, 28, 28, 0.03);
}

/* Typography */
h1, h2, h3, h4, .logo-text, .btn, .axis-label, .timer-status-text {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border-radius: 30px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s var(--transition-bezier);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background-color: var(--color-text);
  color: var(--color-bg);
}

.btn-primary:hover:not(:disabled) {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-text);
}

.btn-primary:disabled {
  background-color: #E6E5E1;
  color: #B4B3AF;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border-active);
}

.btn-secondary:hover {
  background-color: rgba(28, 28, 28, 0.04);
}

.btn-large {
  padding: 18px 48px;
  font-size: 15px;
}

/* Auth overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) var(--transition-bezier);
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.auth-card {
  width: 90%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
}

.logo-text {
  font-size: 30px;
  margin-bottom: 8px;
}

.subtitle-text {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 40px;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input-group input {
  padding: 16px 20px;
  border-radius: 30px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  text-align: center;
  outline: none;
  font-family: var(--font-display);
  letter-spacing: 0.3em;
  transition: border-color 0.3s;
}

.auth-input-group input:focus {
  border-color: var(--color-text);
}

.error-text {
  color: var(--color-layer1);
  font-size: 12px;
  margin-top: 16px;
}

/* App container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  opacity: 0;
  transition: opacity var(--transition-speed) var(--transition-bezier);
}

#app-container.active {
  opacity: 1;
}

/* Header — slim 48px */
.app-header {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 36px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(250, 249, 246, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 50;
}

.header-step-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
  text-transform: uppercase;
  min-width: 80px;
}

.header-logo {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.16em;
  font-weight: 500;
}

/* Screens */
.screen {
  flex: 1;
  display: none;
  overflow: hidden;
  position: relative;
}

.screen.active {
  display: flex;
  animation: screenFadeIn 0.6s var(--transition-bezier) forwards;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.center-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 40px;
}

/* Welcome screen */
.welcome-title {
  font-size: 40px;
  font-weight: 300;
  margin-bottom: 24px;
  color: var(--color-text);
}

.welcome-desc {
  font-size: 14px;
  line-height: 1.8;
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 48px;
}

.input-panel {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-label {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

#nickname-input {
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  font-family: var(--font-display);
  outline: none;
  letter-spacing: 0.05em;
  text-align: center;
  transition: border-color 0.3s;
  margin-bottom: 12px;
}

#nickname-input:focus {
  border-color: var(--color-text);
}

/* Step screens — full-screen interaction layout */
.step-full-layout {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visualizer-full {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.15);
}

.interaction-area {
  position: relative;
  width: min(76vw, 76vh);
  height: min(76vw, 76vh);
  border: 1px dashed var(--color-border);
  border-radius: 50%;
  z-index: 3;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.45);
}

/* Floating icon-only nav buttons */
.nav-btn-floating {
  position: absolute;
  bottom: 36px;
  z-index: 200;
  background: transparent;
  border: none;
  color: var(--color-text);
  /* Generous invisible touch target */
  padding: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.25s var(--transition-bezier), transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn-floating:hover {
  opacity: 1;
}

.nav-btn-floating:active:not(:disabled) {
  transform: scale(0.88);
  opacity: 1;
}

.nav-btn-floating:disabled {
  opacity: 0.18;
  cursor: not-allowed;
}

.btn-reset {
  left: 8px;
}

.btn-next {
  right: 8px;
  opacity: 0.55;
}

@keyframes nextBtnPulse {
  0% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0.55; }
}

.nav-btn-floating.btn-next.completed-pulse {
  animation: nextBtnPulse 1.8s ease-in-out infinite;
  opacity: 1 !important;
}

/* Popup Overlay */
.instruction-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 460px;
  padding: 48px 40px;
  z-index: 100;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.instruction-popup.fade-out {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%);
  transition: all 0.4s var(--transition-bezier);
}

.popup-icon {
  margin-bottom: 8px;
}

.instruction-popup h3 {
  font-size: 18px;
  color: var(--color-text);
}

.instruction-popup p {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--color-text-muted);
}

.btn-close-popup {
  margin-top: 10px;
  padding: 10px 36px;
  font-size: 12px;
  background-color: var(--color-text);
  color: var(--color-bg);
}

/* Demo Animation Canvas overlay */
.demo-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  opacity: 1;
  transition: opacity 0.5s var(--transition-bezier);
}

.demo-canvas.fade-out {
  opacity: 0;
}

/* Step 1 Specific */
.seed-trail-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}
.drag-seed {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-layer1) 0%, rgba(217, 93, 57, 0.4) 60%, transparent 100%);
  box-shadow: 0 0 20px var(--color-layer1);
  cursor: grab;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  z-index: 5;
  transition: transform 0.1s;
}

.drag-seed:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.15);
}

.grid-helper-axes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grid-helper-axes::before, .grid-helper-axes::after {
  content: '';
  position: absolute;
  background-color: rgba(28, 28, 28, 0.04);
}

.grid-helper-axes::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
}

.grid-helper-axes::after {
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
}

.axis-label {
  position: absolute;
  font-size: 9px;
  color: var(--color-text-muted);
  opacity: 0.55;
}

.axis-top { top: 12px; left: 50%; transform: translateX(-50%); }
.axis-bottom { bottom: 12px; left: 50%; transform: translateX(-50%); }
.axis-left { left: 12px; top: 50%; transform: translateY(-50%) rotate(-90deg); transform-origin: left center; }
.axis-right { right: 12px; top: 50%; transform: translateY(-50%) rotate(90deg); transform-origin: right center; }

/* Step 2 Specific */
#balance-pad {
  background-color: rgba(255, 255, 255, 0.35);
}

.metaball-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.metaball-filter-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.taste-blob {
  /* Let SVG translation and scaling handle origins */
}

/* Step 3 Sunset Interaction Area */
#sunset-pad {
  border: 1px dashed var(--color-border);
  background-color: var(--color-bg);
  /* Background color is directly manipulated via JS for iPad compatibility */
}

#visualizer-container-3 {
  background-color: transparent;
}

.horizon-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 80%;
  height: 1px;
  background-color: var(--color-text);
  opacity: 0.12;
  pointer-events: none;
  z-index: 2;
}

.glowing-sun {
  position: absolute;
  left: 50%;
  top: 15%; /* Initial height at top */
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFAA33 0%, #D45D39 65%, rgba(217, 93, 57, 0.15) 100%);
  box-shadow: 0 0 16px rgba(217, 93, 57, 0.35), 0 0 32px rgba(217, 93, 57, 0.15);
  transform: translate(-50%, -50%);
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s;
}

.glowing-sun:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
}

.progress-arc-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#arc-progress {
  stroke-dasharray: 144.5;
  stroke-dashoffset: 144.5;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-status-text {
  position: absolute;
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-text-muted);
  opacity: 0.5;
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 2;
}

/* Loading Screen */
.loading-art-container {
  width: 250px;
  height: 250px;
  margin-bottom: 40px;
}

.loading-morph-svg {
  width: 100%;
  height: 100%;
}

.loading-text {
  font-size: 24px;
  font-weight: 300;
  margin-bottom: 12px;
  color: var(--color-text);
}

.loading-desc {
  font-size: 13.5px;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 440px;
  margin-bottom: 40px;
}

.loading-bar-wrapper {
  width: 240px;
  height: 2px;
  background-color: #E6E5E1;
  overflow: hidden;
  border-radius: 1px;
}

.loading-bar {
  width: 40%;
  height: 100%;
  background-color: var(--color-text);
  animation: loadingSlide 2.5s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-150%); }
  50% { transform: translateX(150%); }
  100% { transform: translateX(-150%); }
}

/* Final Result Screen — 70/30 asymmetric layout */
.final-layout {
  display: grid;
  grid-template-columns: 70fr 30fr;
  width: 100%;
  height: calc(100vh - 48px);
}

/* Left 70%: Art + Poem stacked */
.final-left-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 40px 32px 48px;
  gap: 28px;
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.final-art-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.final-master-svg {
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  background-color: var(--color-bg);
}

/* Poem — bottom-left poetic arrangement */
.result-poem {
  width: 100%;
  max-width: 480px;
  padding: 0 4px;
}

.result-poem p {
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 2.0;
  color: var(--color-text-muted);
  font-style: italic;
  letter-spacing: 0.04em;
}

/* Right 30%: Nickname + QR + Button */
.final-right-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 36px;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
}

.result-header {
  margin-bottom: 0;
}

.label-tag {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  display: block;
  margin-bottom: 6px;
}

.result-nickname {
  font-size: 28px;
  font-weight: 400;
  color: var(--color-text);
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.vault-promo {
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.vault-promo h4 {
  font-size: 13.5px;
  margin-bottom: 8px;
  color: var(--color-text);
}

.vault-promo p {
  font-size: 11.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto 16px auto;
}

.qr-code-container {
  display: inline-flex;
  padding: 12px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.vault-url {
  font-family: var(--font-display);
  font-size: 11.5px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.btn-end {
  width: 100%;
  margin-top: auto;
}

/* Common Animations */
@keyframes rot {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-animation {
  transform-origin: center;
  animation: rot 20s linear infinite;
}

.pulse-animation {
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 0.85; }
  100% { transform: scale(1); opacity: 0.6; }
}

/* ==========================================================================
   Vault Mobile Page (Smartphone Optimized)
   ========================================================================== */
.vault-body {
  overflow-y: auto;
  height: auto;
}

.vault-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.vault-loader-card {
  width: 80%;
  max-width: 300px;
  padding: 40px;
  text-align: center;
}

.loader-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(28, 28, 28, 0.08);
  border-top-color: var(--color-text);
  border-radius: 50%;
  margin: 0 auto 20px auto;
  animation: loaderSpin 0.8s linear infinite;
}

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

.loader-text {
  font-size: 12px;
  color: var(--color-text-muted);
}

.error-title {
  font-size: 17px;
  color: var(--color-layer1);
  margin-bottom: 12px;
}

.error-desc-text {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

#vault-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.vault-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.vault-logo {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.08em;
}

.vault-tag {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--color-text-muted);
}

.vault-art-wrapper {
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-bg);
}

.vault-master-svg {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(28, 28, 28, 0.02);
}

.vault-info-panel {
  padding: 30px 24px;
}

.vault-info-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.vault-label {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.vault-nickname {
  font-size: 22px;
  font-weight: 400;
}

.vault-date {
  font-size: 13px;
  color: var(--color-text-muted);
}

.vault-poem {
  padding: 20px;
  margin-bottom: 24px;
}

.vault-poem p {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--color-text-muted);
  font-style: italic;
}

.breakdown-title {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: flex;
  align-items: center;
  font-size: 11px;
}

.bar-name {
  width: 80px;
  color: var(--color-text-muted);
}

.bar-bg {
  flex: 1;
  height: 5px;
  background-color: rgba(28, 28, 28, 0.04);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 16px;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s var(--transition-bezier);
}

.bar-fill.color-sweet { background-color: var(--color-sweet); }
.bar-fill.color-acid { background-color: var(--color-acid); }
.bar-fill.color-bitter { background-color: var(--color-bitter); }

.bar-val {
  width: 36px;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 500;
}

.vault-footer {
  text-align: center;
  padding: 24px 0;
  font-size: 10px;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* Landscape / Tablet Responsive */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
    height: auto;
  }
  
  #app-container {
    height: auto;
  }
  
  .step-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .visualizer-container {
    aspect-ratio: 1.15;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 30px 0;
  }
  
  .control-panel {
    height: auto;
    padding: 32px 24px;
  }
  
  .final-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .final-art-container {
    aspect-ratio: 1.15;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  
  .final-right-col {
    height: auto;
    padding: 32px 24px;
    border-left: none;
  }
}

/* Persistent Subtle Guidance outside the circle pad */
.persistent-guidance-left {
  position: absolute;
  top: 24px;
  left: 36px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-muted);
  opacity: 0.85;
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 5;
}

.persistent-guidance-right {
  position: absolute;
  top: 24px;
  right: 36px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-muted);
  opacity: 0.85;
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 5;
  text-align: right;
}
