/* ========================================
   CapyConvert — Styles
   Full-screen background with content overlay
   ======================================== */

:root {
  /* Warm, spa-like palette */
  --color-bg: #fdfbf7;
  --color-cream: #fdfbf7;
  --color-text: #3d3830;
  --color-text-muted: #7a7265;
  --color-accent: #c47a4a;
  --color-accent-hover: #b06a3a;
  --color-border: #d4cdc2;
  --color-card-bg: rgba(255, 255, 255, 0.95);
  --color-dropzone-bg: rgba(255, 255, 255, 0.7);

  /* Typography */
  --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

/* ========================================
   Reset & Base
   ======================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ========================================
   Layout: Full-screen image + overlay
   ======================================== */

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Background scene - full screen */
.bg-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.bg-image {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.bg-image.active {
  opacity: 1;
}

/* Content overlay - positioned on the right */
.content {
  position: relative;
  z-index: 10;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 2rem;
}

/* ========================================
   States
   ======================================== */

.state {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.state.active {
  opacity: 1;
  visibility: visible;
}

.state-content {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.state-mixed .state-content {
  max-width: 480px;
}

/* ========================================
   Typography
   ======================================== */

.headline {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.subtext {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.filename {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  word-break: break-all;
  padding: 0.5rem 1rem;
  background: var(--color-card-bg);
  border-radius: 8px;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

/* ========================================
   Drop Zone
   ======================================== */

.dropzone {
  background: var(--color-dropzone-bg);
  backdrop-filter: blur(10px);
  border: 2px dashed var(--color-border);
  border-radius: 20px;
  padding: 3rem 2rem;
  margin: 1.5rem 0;
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background-color var(--transition-fast),
              transform var(--transition-fast);
  position: relative;
}

.dropzone:hover {
  border-color: var(--color-accent);
  background: rgba(255, 255, 255, 0.85);
  transform: scale(1.01);
}

.dropzone.dragover {
  border-color: var(--color-accent);
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.02);
  border-style: solid;
}

.dropzone.pulse {
  animation: dropzone-pulse 400ms ease;
}

@keyframes dropzone-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dropzone-text {
  font-size: 1.15rem;
  color: var(--color-text);
  font-weight: 500;
}

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

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}

.format-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

/* ========================================
   Format Options
   ======================================== */

.format-options {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.5rem 0 2rem;
}

.format-option {
  background: var(--color-card-bg);
  backdrop-filter: blur(10px);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  min-width: 120px;
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background-color var(--transition-fast),
              transform var(--transition-fast);
}

.format-option:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.format-option.selected {
  border-color: var(--color-accent);
  background: rgba(196, 122, 74, 0.1);
}

.format-option input {
  display: none;
}

.format-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.format-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* ========================================
   Format Groups (Mixed Files)
   ======================================== */

.format-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 200px;
  margin-bottom: 1.5rem;
}

.format-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.875rem 1rem;
}

.format-group-label {
  font-size: 0.95rem;
  color: var(--color-text);
}

.format-group-count {
  font-weight: 500;
}

.format-group-type {
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

.format-group select {
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a7265' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  background-size: 10px;
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 100px;
}

.format-group select:hover {
  border-color: var(--color-accent);
}

.format-group select:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ========================================
   Mode Toggle (Grouped vs Individual)
   ======================================== */

.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.mode-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
  cursor: pointer;
}

.mode-label.active {
  color: var(--color-text);
  font-weight: 500;
}

.toggle-pill {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  padding: 0;
}

.toggle-pill:hover {
  background: #c5beb3;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform var(--transition-fast);
}

.toggle-pill[aria-pressed="true"] .toggle-thumb {
  transform: translateX(20px);
}

.toggle-pill[aria-pressed="true"] {
  background: var(--color-accent);
}

/* ========================================
   Individual File Format Selection
   ======================================== */

.format-individual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, auto);
  grid-auto-flow: column;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.5rem;
}

.format-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  background: var(--color-card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.375rem 0.5rem;
}

.format-file-name {
  font-size: 0.75rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.format-file-row select {
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.35rem 1.25rem 0.35rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a7265' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.35rem center;
  background-size: 7px;
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
}

.format-file-row select:hover {
  border-color: var(--color-accent);
}

.format-file-row select:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  cursor: pointer;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
}

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

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-accent);
  font-family: var(--font-main);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
  margin-top: 1rem;
  transition: color var(--transition-fast);
}

.btn-text:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* ========================================
   Processing Dots
   ======================================== */

.dots {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.dot {
  width: 12px;
  height: 12px;
  background: var(--color-accent);
  border-radius: 50%;
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   File Card (Complete State)
   ======================================== */

.file-card {
  background: var(--color-card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  text-align: left;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.file-icon {
  color: var(--color-accent);
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  display: block;
  font-weight: 500;
  color: var(--color-text);
  word-break: break-all;
}

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

.btn-download {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
}

/* ========================================
   Tip Options
   ======================================== */

/* A: Soft tip card */
.tip-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  margin-top: 1.5rem;
}

.tip-card-icon {
  font-size: 1.5rem;
}

.tip-card-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.125rem;
}

.tip-card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.tip-card-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.btn-tip-card {
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tip-card:hover {
  background: var(--color-text);
  color: white;
  border-color: var(--color-text);
}

/* B: Inline tip */
.tip-inline {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.tip-inline a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition-fast);
}

.tip-inline a:hover {
  opacity: 0.7;
}

/* Share buttons */
.share-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

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

.share-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.share-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateY(-2px);
}

.share-btn.copied {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

/* C: Floating corner button */
.tip-float {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tip-float:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Tip Modal
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--color-cream);
  border-radius: 16px;
  padding: 2rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.25s ease-out;
}

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

.modal-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem 0;
}

.modal-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0 0 1.5rem 0;
}

.modal-buttons {
  display: flex;
  gap: 0.75rem;
}

.modal-buttons .btn {
  flex: 1;
  padding: 0.75rem 1rem;
}

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

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
}


/* ========================================
   Privacy Note
   ======================================== */

.privacy-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  max-width: 260px;
  margin-left: auto;
  margin-right: auto;
}

/* ========================================
   Error State
   ======================================== */

.state-error .headline {
  color: var(--color-text);
}

/* ========================================
   Navbar
   ======================================== */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none; /* Let clicks pass through navbar background */
}

.navbar-logo-link {
  display: inline-block;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto; /* But logo is clickable */
}

.navbar-logo-link:hover {
  transform: scale(1.12);
}

.navbar-logo-link:hover .navbar-logo {
  /* Combine base color filter with brightness boost */
  filter: sepia(100%) saturate(350%) brightness(80%) hue-rotate(-10deg);
}

.navbar-logo-link:active {
  transform: scale(0.96);
  transition: transform 0.1s ease;
}

.navbar-logo-link:active .navbar-logo {
  filter: sepia(100%) saturate(250%) brightness(65%) hue-rotate(-10deg);
}

.navbar-logo {
  height: 40px;
  width: auto;
  display: block;
  /* Apply brown color #53321b using CSS filter */
  filter: sepia(100%) saturate(300%) brightness(70%) hue-rotate(-10deg);
  transition: filter 0.3s ease;
}


/* ========================================
   Mobile Responsive
   ======================================== */

/* Tablet landscape */
@media (max-width: 1024px) {
  .state {
    width: 55%;
  }
}

/* Tablet portrait */
@media (max-width: 900px) {
  .state {
    width: 60%;
  }

  .bg-image {
    object-position: 25% center;
  }
}

/* Large phone / small tablet */
@media (max-width: 700px) {
  .state {
    width: 100%;
    /* Gradient from right to let capy show on left */
    background: linear-gradient(
      to right,
      transparent 0%,
      rgba(253, 251, 247, 0.7) 15%,
      rgba(253, 251, 247, 0.92) 35%
    );
  }

  .bg-image {
    object-position: 20% center;
  }

  .state-content {
    margin-left: auto;
    max-width: 300px;
    padding-right: 1.5rem;
  }

  .dropzone {
    padding: 2.5rem 1.5rem;
  }
}

/* Phone portrait - stack layout */
@media (max-width: 550px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app {
    overflow: visible;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .bg-scene {
    /* Image takes top portion of screen - fixed so it doesn't scroll */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 55vh;
    bottom: auto;
    overflow: hidden;
  }

  /* Gradient overlay for smooth blend into background */
  .bg-scene::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      rgba(253, 251, 247, 0.15) 20%,
      rgba(253, 251, 247, 0.4) 40%,
      rgba(253, 251, 247, 0.7) 55%,
      rgba(253, 251, 247, 0.9) 70%,
      var(--color-bg) 85%,
      var(--color-bg) 100%
    );
    pointer-events: none;
    z-index: 2;
  }

  .bg-image {
    /* Scale up and position from left */
    object-fit: contain;
    object-position: left top;
    background: var(--color-bg);
    transform: scale(2);
    transform-origin: left top;
  }

  .state {
    /* Content in bottom portion - now relative for scrolling */
    position: relative;
    width: 100%;
    background: transparent;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 1.5rem;
    padding-top: calc(55vh + 0.5rem);
    padding-bottom: 6rem;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .state:not(.active) {
    display: none;
  }

  .state-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .headline {
    font-size: 1.5rem;
  }

  .subtext {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .dropzone {
    padding: 2rem 1.5rem;
    border-radius: 16px;
  }

  .dropzone-text {
    font-size: 1.05rem;
  }

  .format-hint {
    font-size: 0.8rem;
  }

  .navbar {
    padding: 0.75rem 1rem;
  }

  .navbar-logo {
    height: 32px;
  }

  .format-individual {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .format-groups {
    min-height: 150px;
  }
}

/* Small phone */
@media (max-width: 400px) {
  .bg-scene {
    height: 50vh;
  }

  .bg-image {
    transform: scale(2);
    transform-origin: left top;
  }

  .state {
    background: transparent;
    padding: 1rem;
    padding-top: calc(50vh + 0.5rem);
    padding-bottom: 5rem;
  }

  .headline {
    font-size: 1.35rem;
  }

  .dropzone {
    padding: 1.75rem 1.25rem;
  }

  .format-options {
    gap: 0.6rem;
  }

  .format-option {
    min-width: 95px;
    padding: 0.75rem 0.9rem;
  }

  .format-name {
    font-size: 0.95rem;
  }

  .format-desc {
    font-size: 0.75rem;
  }

  .btn {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
  }

  .file-card {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .btn-download {
    width: 100%;
    margin-top: 0.5rem;
  }

  .privacy-note {
    font-size: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
  }
}

/* Landscape phone - keep side by side */
@media (max-height: 500px) and (orientation: landscape) {
  .state {
    width: 55%;
    background: linear-gradient(
      to right,
      transparent 0%,
      rgba(253, 251, 247, 0.8) 10%,
      rgba(253, 251, 247, 0.95) 30%
    );
    align-items: center;
    padding: 1rem 1.5rem;
  }

  .bg-image {
    object-position: 15% center;
  }

  .state-content {
    max-width: 320px;
    margin-left: auto;
  }

  .headline {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
  }

  .subtext {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .dropzone {
    padding: 1.25rem 1rem;
    margin: 0.75rem 0;
  }

  .format-hint {
    font-size: 0.75rem;
  }
}
