/* ============================================================
   SCHWUNGCOACH — Design System
   Stripe/Linear-inspired minimal golf analysis tool
   ============================================================ */

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

/* --- Tokens --- */
:root {
  --green-deep: #0f3d2b;
  --green: #1c5538;
  --green-light: #2c7350;
  --green-faint: rgba(15, 61, 43, 0.07);
  --gold: #b0883a;
  --gold-light: #c9a45c;

  --bg: #f8f7f4;
  --surface: #ffffff;
  --text: #1a1a18;
  --text-secondary: #6b6b64;
  --text-muted: #9c9c93;
  --border: #e5e4df;
  --border-focus: var(--green);
  --error: #b5342d;
  --error-bg: rgba(181, 52, 45, 0.06);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);

  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 200ms;
  --duration-slow: 400ms;
}

/* --- Base --- */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- App shell --- */
.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  position: relative;
}

@media (max-width: 560px) {
  .app {
    padding: 32px 20px 48px;
  }
}

/* ============================================================
   STATES
   ============================================================ */
.state {
  display: none;
  opacity: 0;
  transform: translateY(12px);
}

.state.active {
  display: block;
}

.state.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--duration-slow) var(--ease),
              transform var(--duration-slow) var(--ease);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--green-deep);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.01em;
}

/* ============================================================
   DROPZONE
   ============================================================ */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color var(--duration) var(--ease),
              border-style var(--duration) var(--ease),
              background var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
  margin-bottom: 32px;
}

.dropzone:hover {
  border-color: rgba(28, 85, 56, 0.35);
  background: rgba(15, 61, 43, 0.015);
}

.dropzone.drag-over {
  border-color: var(--green);
  border-style: solid;
  background: var(--green-faint);
  box-shadow: 0 0 0 4px rgba(15, 61, 43, 0.06);
  animation: dropPulse 1.2s ease-in-out infinite;
}

@keyframes dropPulse {
  0%, 100% { background: rgba(15, 61, 43, 0.04); }
  50% { background: rgba(15, 61, 43, 0.08); }
}

.dropzone.has-file {
  border-color: var(--green);
  border-style: solid;
  background: rgba(15, 61, 43, 0.02);
  cursor: default;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone-success {
  display: none;
  gap: 10px;
}

.dropzone-icon {
  color: var(--text-muted);
  transition: color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
  margin-bottom: 4px;
}

.dropzone:hover .dropzone-icon,
.dropzone.drag-over .dropzone-icon {
  color: var(--green);
}

.dropzone.drag-over .dropzone-icon {
  transform: translateY(-3px);
}

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

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

.btn-file-select {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--green);
  background: var(--green-faint);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--duration) var(--ease),
              transform var(--duration) var(--ease);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.btn-file-select:hover {
  background: rgba(15, 61, 43, 0.12);
}

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

/* -- File selected state -- */
.dropzone-check-icon {
  animation: checkScaleIn 0.4s var(--ease-spring) both;
}

@keyframes checkScaleIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.dropzone-filename {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--green-deep);
}

.link-change {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px 8px;
  min-height: 48px;
  display: flex;
  align-items: center;
  transition: color var(--duration) var(--ease);
}

.link-change:hover {
  color: var(--green);
}

/* ============================================================
   FORM
   ============================================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: slideIn var(--duration-slow) var(--ease) both;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  min-height: 48px;
}

.input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 61, 43, 0.08);
}

.input::placeholder {
  color: var(--text-muted);
}

/* Chrome date input fix */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
}

/* --- Segmented control --- */
.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.seg-option {
  position: relative;
  z-index: 2;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: color var(--duration) var(--ease);
  min-height: 48px;
  justify-content: center;
}

.seg-option.active {
  color: var(--green-deep);
}

.seg-detail {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.6;
}

.seg-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--green-faint);
  border-radius: calc(var(--radius) - 4px);
  transition: transform var(--duration-slow) var(--ease);
  z-index: 1;
}

.segmented.right .seg-indicator {
  transform: translateX(100%);
}

/* --- Submit button --- */
.btn-submit {
  width: 100%;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--green-deep);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 4px;
  transition: background var(--duration) var(--ease),
              transform var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              opacity var(--duration) var(--ease);
  min-height: 52px;
  position: relative;
}

.btn-submit:not(:disabled):hover {
  background: var(--green);
  transform: scale(1.01);
  box-shadow: 0 4px 16px rgba(15, 61, 43, 0.25);
}

.btn-submit:not(:disabled):active {
  transform: scale(0.99);
}

.btn-submit:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ============================================================
   PROCESSING
   ============================================================ */
.processing-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: 28px;
  padding: 80px 0;
}

.progress-bar-track {
  width: 100%;
  max-width: 320px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 600ms var(--ease);
}

.processing-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.processing-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================================
   RESULTS
   ============================================================ */
.results-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 60px 0 40px;
}

/* -- Animated checkmark -- */
.result-check {
  opacity: 0;
  transform: translateY(12px);
}

.check-circle-draw {
  stroke-dashoffset: 157;
}

.check-path-draw {
  stroke-dashoffset: 35;
}

@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}

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

/* Animations only fire when the results state is visible */
.state.visible .result-check {
  animation: fadeUp 0.5s var(--ease) 0.1s both;
}

.state.visible .check-circle-draw {
  animation: drawStroke 0.7s var(--ease) 0.3s both;
}

.state.visible .check-path-draw {
  animation: drawStroke 0.35s var(--ease) 0.8s both;
}

.result-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  opacity: 0;
  transform: translateY(12px);
}

.state.visible .result-heading {
  animation: fadeUp 0.5s var(--ease) 0.5s both;
}

.result-stats {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(12px);
}

.state.visible .result-stats {
  animation: fadeUp 0.5s var(--ease) 0.65s both;
}

/* -- Action buttons -- */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  opacity: 0;
  transform: translateY(12px);
}

.state.visible .result-actions {
  animation: fadeUp 0.5s var(--ease) 0.8s both;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  min-height: 48px;
  transition: background var(--duration) var(--ease),
              transform var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  cursor: pointer;
}

.btn-primary {
  background: var(--green-deep);
  color: #ffffff;
  border: none;
}

.btn-primary:hover {
  background: var(--green);
  transform: scale(1.01);
  box-shadow: 0 4px 16px rgba(15, 61, 43, 0.25);
}

.btn-secondary {
  background: transparent;
  color: var(--green-deep);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--green-faint);
  border-color: rgba(15, 61, 43, 0.2);
  transform: scale(1.01);
}

.link-restart {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px;
  min-height: 48px;
  display: flex;
  align-items: center;
  transition: color var(--duration) var(--ease);
  opacity: 0;
  transform: translateY(12px);
}

.state.visible .link-restart {
  animation: fadeUp 0.5s var(--ease) 0.95s both;
}

.link-restart:hover {
  color: var(--green);
}

/* ============================================================
   ERROR TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease),
              transform var(--duration) var(--ease);
  z-index: 1000;
  max-width: calc(100vw - 48px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ============================================================
   SELECTION & SCROLLBAR
   ============================================================ */
::selection {
  background: rgba(15, 61, 43, 0.12);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}
