/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #ffffff;
  --color-text: #000000;
  --color-text-secondary: #666666;
  --color-border: #e5e5e5;
  --color-input-bg: #f5f5f5;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Steps */
.step {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.step.active {
  display: flex;
}

/* Step 1: Landing */
#step-landing {
  position: relative;
  overflow: hidden;
}

.landing-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 10;
}

/* Floating Cards */
.floating-cards {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

@media (min-width: 900px) {
  .floating-cards {
    display: block;
  }
}

.floating-card {
  position: absolute;
  width: 120px;
  height: 180px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  animation: float 6s ease-in-out infinite;
  opacity: 0.9;
  cursor: pointer;
  pointer-events: auto;
  transition: z-index 0s, transform 0.3s ease, box-shadow 0.3s ease;
}

.floating-card:hover {
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
}

.floating-card.front {
  z-index: 100 !important;
  animation-play-state: paused;
}

.floating-card .card-inner {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  padding: 16px;
}

.floating-card .card-days {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.floating-card .card-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.9;
  margin-top: 4px;
}

.floating-card .card-title {
  font-size: 11px;
  font-weight: 600;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Card positions - relative to center (pushes away on resize) */
/* Left cards: calc(50% - safe_zone - offset) */
/* Safe zone = 280px (half of form ~480px + padding) */

.card-left-1 {
  top: 3%;
  left: calc(50% - 280px - 220px);
  transform: rotate(-15deg);
  animation-delay: 0s;
  z-index: 5;
}

.card-left-2 {
  top: 18%;
  left: calc(50% - 280px - 140px);
  transform: rotate(8deg);
  animation-delay: 0.7s;
  z-index: 4;
}

.card-left-3 {
  top: 38%;
  left: calc(50% - 280px - 200px);
  transform: rotate(-4deg);
  animation-delay: 1.4s;
  z-index: 6;
}

.card-left-4 {
  top: 55%;
  left: calc(50% - 280px - 120px);
  transform: rotate(12deg);
  animation-delay: 2.1s;
  z-index: 2;
}

.card-left-5 {
  top: 75%;
  left: calc(50% - 280px - 180px);
  transform: rotate(-18deg);
  animation-delay: 2.8s;
  z-index: 3;
}

/* Right cards: calc(50% - safe_zone - offset) from right */
.card-right-1 {
  top: 6%;
  right: calc(50% - 280px - 160px);
  transform: rotate(14deg);
  animation-delay: 0.35s;
  z-index: 4;
}

.card-right-2 {
  top: 24%;
  right: calc(50% - 280px - 220px);
  transform: rotate(-10deg);
  animation-delay: 1.05s;
  z-index: 6;
}

.card-right-3 {
  top: 42%;
  right: calc(50% - 280px - 130px);
  transform: rotate(6deg);
  animation-delay: 1.75s;
  z-index: 3;
}

.card-right-4 {
  top: 62%;
  right: calc(50% - 280px - 200px);
  transform: rotate(-14deg);
  animation-delay: 2.45s;
  z-index: 5;
}

.card-right-5 {
  top: 82%;
  right: calc(50% - 280px - 150px);
  transform: rotate(20deg);
  animation-delay: 3.15s;
  z-index: 2;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(var(--rotation, 0deg));
  }
  50% {
    transform: translateY(-15px) rotate(var(--rotation, 0deg));
  }
}

.card-left-1 { --rotation: -15deg; }
.card-left-2 { --rotation: 8deg; }
.card-left-3 { --rotation: -4deg; }
.card-left-4 { --rotation: 12deg; }
.card-left-5 { --rotation: -18deg; }
.card-right-1 { --rotation: 14deg; }
.card-right-2 { --rotation: -10deg; }
.card-right-3 { --rotation: 6deg; }
.card-right-4 { --rotation: -14deg; }
.card-right-5 { --rotation: 20deg; }

.floating-card.dragging {
  animation: none !important;
  cursor: grabbing;
  opacity: 1;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@media (min-width: 1024px) {
  .floating-card {
    width: 140px;
    height: 200px;
  }

  .floating-card .card-days {
    font-size: 40px;
  }

  .floating-card .card-label {
    font-size: 9px;
  }

  .floating-card .card-title {
    font-size: 11px;
  }
}

@media (min-width: 1400px) {
  .floating-card {
    width: 160px;
    height: 220px;
  }

  .floating-card .card-days {
    font-size: 44px;
  }

  .floating-card .card-title {
    font-size: 12px;
  }
}

.logo {
  margin-bottom: 48px;
}

.logo svg {
  width: 56px;
  height: 56px;
  color: var(--color-text);
}

.headline {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.subheadline {
  font-size: 18px;
  color: var(--color-text-secondary);
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
  margin-bottom: 48px;
}

/* Form */
.create-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  position: relative;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
}

.input-group input {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-family: var(--font-family);
  border: none;
  border-radius: 12px;
  background: var(--color-input-bg);
  color: var(--color-text);
  outline: none;
  transition: box-shadow 0.2s ease;
}

.input-group input:focus {
  box-shadow: 0 0 0 2px var(--color-text);
}

.input-group input::placeholder {
  color: #999;
}

.char-count {
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-size: 12px;
  color: #999;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 18px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-family);
  color: #fff;
  background: var(--color-text);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-input-bg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-icon:hover {
  background: var(--color-border);
}

.btn-icon-light {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-icon-light:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* App Download */
.app-download {
  margin-top: 48px;
  text-align: center;
}

.app-download p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.app-store-badge {
  display: inline-block;
}

/* Step 2: Background Selection */
.background-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.step-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.spacer {
  width: 44px;
}

/* Preview Card */
.preview-card {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 320px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #E8E8E8 0%, #B8C6DB 100%);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-card.has-image {
  background-size: cover;
  background-position: center;
}

.preview-content {
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.countdown-display {
  margin-bottom: 12px;
}

.countdown-number {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
}

.countdown-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0.9;
}

.event-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Background Options */
.background-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  overflow: hidden;
}

.option-section {
  background: var(--color-input-bg);
  border-radius: 12px;
  overflow: hidden;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.option-row:hover {
  background: var(--color-border);
}

.option-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: 10px;
  color: var(--color-text);
  flex-shrink: 0;
}

.option-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.option-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.search-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background 0.2s ease, color 0.2s ease;
}

.search-toggle:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.unsplash-expanded {
  display: none;
  padding: 0 16px 16px;
}

.unsplash-expanded.active {
  display: block;
}

.unsplash-suggestions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}

.unsplash-suggestions .photo-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.unsplash-suggestions .photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Unsplash Section */
.unsplash-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  overflow: hidden;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-input-bg);
  border-radius: 12px;
}

.search-bar svg {
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-size: 16px;
  font-family: var(--font-family);
  color: var(--color-text);
  outline: none;
}

.search-bar input::placeholder {
  color: #999;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 16px;
}

.photo-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.photo-item:hover {
  transform: scale(1.02);
}

.photo-item.selected {
  outline: 3px solid var(--color-text);
  outline-offset: 2px;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--color-text-secondary);
}

/* Step 3: Countdown Display */
.countdown-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #E8E8E8 0%, #B8C6DB 100%);
  background-size: cover;
  background-position: center;
  position: relative;
}

.countdown-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 30%,
    rgba(0, 0, 0, 0.1) 70%,
    rgba(0, 0, 0, 0.5) 100%
  );
  pointer-events: none;
}

.countdown-header {
  position: relative;
  z-index: 10;
  padding: 24px;
  display: flex;
  justify-content: flex-end;
}

.countdown-main {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

/* Default state uses dark text for silver background */
.countdown-container:not(.has-image) .countdown-main {
  color: #333;
  text-shadow: none;
}

.countdown-container:not(.has-image) .countdown-event-date {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.countdown-container:not(.has-image) .btn-icon-light {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.countdown-container:not(.has-image) .download-prompt {
  color: #333;
}

.countdown-time {
  margin-bottom: 8px;
}

.time-block {
  text-align: center;
}

.time-value {
  font-size: clamp(80px, 20vw, 160px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.time-label {
  font-size: clamp(14px, 3vw, 18px);
  font-weight: 600;
  letter-spacing: 0.15em;
  opacity: 0.9;
}

.countdown-secondary {
  display: flex;
  gap: clamp(24px, 6vw, 48px);
  margin-bottom: 16px;
}

.time-block-small {
  text-align: center;
}

.time-value-small {
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 700;
  line-height: 1.2;
}

.time-label-small {
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.countdown-direction {
  font-size: clamp(12px, 3vw, 16px);
  font-weight: 600;
  letter-spacing: 0.2em;
  opacity: 0.9;
  margin-bottom: 32px;
}

.countdown-event-name {
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.countdown-event-date {
  font-size: clamp(14px, 3vw, 16px);
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 20px;
  border-radius: 50px;
}

.countdown-footer {
  position: relative;
  z-index: 10;
  padding: 24px;
}

.download-prompt {
  text-align: center;
  color: #fff;
}

.download-prompt p {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 12px;
}

.app-store-badge-small {
  display: inline-block;
}

/* Responsive */
@media (max-width: 480px) {
  .headline {
    font-size: 36px;
  }

  .subheadline {
    font-size: 16px;
  }

  .preview-card {
    max-height: 280px;
  }

  .countdown-number {
    font-size: 48px;
  }
}

@media (min-width: 768px) {
  .landing-container {
    padding: 80px 40px;
  }

  .headline {
    font-size: 56px;
  }

  .preview-card {
    max-height: 400px;
  }
}

/* Landscape mode for countdown */
@media (orientation: landscape) and (max-height: 500px) {
  .countdown-main {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
  }

  .countdown-time {
    margin-bottom: 0;
  }

  .countdown-secondary {
    margin-bottom: 0;
  }

  .countdown-direction {
    width: 100%;
    text-align: center;
    margin-bottom: 16px;
  }

  .countdown-event-name,
  .countdown-event-date {
    width: 100%;
    text-align: center;
  }

  .countdown-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step.active {
  animation: fadeIn 0.3s ease;
}
