/* ========================================================
   Remote Work Red Flags - Styles
   Dark theme | Red/orange accents | Mobile-first
   ======================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg:        #0e0e12;
  --bg-card:   #1a1a24;
  --bg-card-2: #22222e;
  --surface:   #2a2a38;
  --border:    #333346;
  --text:      #e8e8f0;
  --text-dim:  #8b8ba0;
  --accent:    #ff4444;
  --accent-2:  #ff6b35;
  --green:     #22c55e;
  --green-dim: rgba(34,197,94,.12);
  --red-dim:   rgba(255,68,68,.12);
  --orange:    #ff9500;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 8px 32px rgba(0,0,0,.45);
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --transition:   .3s cubic-bezier(.4,0,.2,1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Screen system ---------- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px 20px env(safe-area-inset-bottom, 16px);
}
.screen.active {
  display: flex;
}

/* ============================
   INTRO SCREEN
   ============================ */
.intro-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  animation: fadeUp .6s ease-out;
}

/* Animated flag icon */
.intro-flag-icon {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 4px;
}
.flag-pole {
  position: absolute;
  left: 24px;
  top: 8px;
  width: 4px;
  height: 64px;
  background: var(--text-dim);
  border-radius: 2px;
}
.flag-cloth {
  position: absolute;
  left: 28px;
  top: 8px;
  width: 40px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 0 6px 6px 0;
  animation: flagWave 2s ease-in-out infinite;
  transform-origin: left center;
}

@keyframes flagWave {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  25%      { transform: skewY(-3deg) scaleX(.96); }
  50%      { transform: skewY(2deg) scaleX(1.02); }
  75%      { transform: skewY(-1deg) scaleX(.98); }
}

.intro-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.intro-title .accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.intro-subtitle {
  font-size: 1.05rem;
  color: var(--text-dim);
  max-width: 300px;
  line-height: 1.5;
}

.intro-instruction {
  font-size: .88rem;
  color: var(--text-dim);
  background: var(--surface);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
.intro-instruction strong {
  color: var(--text);
}

.intro-count {
  font-size: .8rem;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 36px;
  border: none;
  border-radius: 60px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 24px rgba(255,68,68,.3);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active {
  transform: scale(.96);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: 2px solid var(--border);
  border-radius: 60px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active {
  transform: scale(.96);
  border-color: var(--text-dim);
}

/* ============================
   CHECKLIST / SWIPE SCREEN
   ============================ */
.checklist-header {
  padding: 8px 0 12px;
}
.progress-info {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
#progress-text {
  font-family: var(--font-heading);
  font-size: .9rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: .03em;
}
.progress-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width .4s ease-out;
}

/* ---------- Swipe zone ---------- */
.swipe-zone {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.card-stack {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 400px;
}

/* Single swipe card */
.swipe-card {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  will-change: transform, opacity;
  transition: box-shadow var(--transition);
}
.swipe-card:active {
  cursor: grabbing;
}
.swipe-card.dragging {
  transition: none;
}

.card-number {
  font-family: var(--font-heading);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card-emoji {
  font-size: 3.5rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.3));
}

.card-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  max-width: 280px;
}

/* Overlay stamps */
.card-stamp {
  position: absolute;
  top: 24px;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: 0;
  pointer-events: none;
  transition: none;
}
.card-stamp.stamp-fine {
  left: 20px;
  border: 3px solid var(--green);
  color: var(--green);
  transform: rotate(-15deg);
}
.card-stamp.stamp-flag {
  right: 20px;
  border: 3px solid var(--accent);
  color: var(--accent);
  transform: rotate(15deg);
}

/* Swipe hint labels */
.swipe-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 10;
}
.swipe-hint-left {
  left: 8px;
  background: var(--green-dim);
  color: var(--green);
}
.swipe-hint-right {
  right: 8px;
  background: var(--red-dim);
  color: var(--accent);
}

/* ---------- Swipe buttons ---------- */
.swipe-buttons {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 20px 0 12px;
}
.swipe-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 28px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.swipe-btn:active {
  transform: scale(.94);
}
.swipe-btn-fine:active,
.swipe-btn-fine:hover {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}
.swipe-btn-flag:active,
.swipe-btn-flag:hover {
  border-color: var(--accent);
  background: var(--red-dim);
  color: var(--accent);
}
.swipe-btn .flag-emoji {
  font-size: 1.6rem;
  line-height: 1;
}
.swipe-btn svg {
  width: 28px;
  height: 28px;
}

/* Stacked card depth effect */
.swipe-card[data-depth="1"] {
  transform: scale(.96) translateY(10px);
  opacity: .7;
  z-index: 1;
}
.swipe-card[data-depth="2"] {
  transform: scale(.92) translateY(20px);
  opacity: .4;
  z-index: 0;
}
.swipe-card[data-depth="0"] {
  z-index: 2;
}

/* Exit animations */
.swipe-card.exit-left {
  animation: exitLeft .4s ease-in forwards;
}
.swipe-card.exit-right {
  animation: exitRight .4s ease-in forwards;
}

@keyframes exitLeft {
  to {
    transform: translateX(-150%) rotate(-20deg);
    opacity: 0;
  }
}
@keyframes exitRight {
  to {
    transform: translateX(150%) rotate(20deg);
    opacity: 0;
  }
}

/* ============================
   RESULTS SCREEN
   ============================ */
.results-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 20px;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Score ring */
.results-score-ring {
  position: relative;
  width: 140px;
  height: 140px;
  animation: popIn .5s cubic-bezier(.175,.885,.32,1.275);
}
.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.score-bg {
  fill: none;
  stroke: var(--surface);
  stroke-width: 8;
}
.score-progress {
  fill: none;
  stroke: url(#scoreGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1);
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text);
}
.score-value small {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 2px;
}

.results-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeUp .5s ease-out .3s both;
}

.results-emoji {
  font-size: 2rem;
  animation: fadeUp .5s ease-out .4s both;
}

.results-description {
  font-size: .95rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
  animation: fadeUp .5s ease-out .5s both;
}

/* ---------- Bar chart ---------- */
.results-chart {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeUp .5s ease-out .6s both;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface) transparent;
}
.results-chart::-webkit-scrollbar {
  width: 4px;
}
.results-chart::-webkit-scrollbar-track {
  background: transparent;
}
.results-chart::-webkit-scrollbar-thumb {
  background: var(--surface);
  border-radius: 2px;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chart-label {
  flex: 1;
  font-size: .75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.chart-bar-wrapper {
  width: 60px;
  flex-shrink: 0;
}
.chart-bar {
  height: 16px;
  border-radius: 4px;
  transition: width .8s ease-out;
}
.chart-bar.bar-flag {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 100%;
}
.chart-bar.bar-fine {
  background: var(--green);
  opacity: .5;
  width: 40%;
}
.chart-icon {
  font-size: .85rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

/* ---------- Result actions ---------- */
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
  align-items: center;
  animation: fadeUp .5s ease-out .7s both;
}
.btn-share {
  width: 100%;
  justify-content: center;
}

/* ============================
   ANIMATIONS
   ============================ */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-height: 640px) {
  .card-stack {
    height: 320px;
  }
  .card-emoji {
    font-size: 2.8rem;
  }
  .card-text {
    font-size: 1.05rem;
  }
  .intro-title {
    font-size: 1.8rem;
  }
  .results-score-ring {
    width: 110px;
    height: 110px;
  }
  .score-value {
    font-size: 2.2rem;
  }
  .results-chart {
    max-height: 180px;
  }
}

@media (min-width: 420px) {
  .card-stack {
    max-width: 380px;
  }
  .card-text {
    font-size: 1.3rem;
  }
}

/* Small phone optimization */
@media (max-height: 560px) {
  .swipe-zone {
    padding: 0;
  }
  .card-stack {
    height: 260px;
  }
  .swipe-buttons {
    padding: 10px 0 6px;
  }
  .card-emoji {
    font-size: 2.2rem;
  }
  .card-text {
    font-size: .95rem;
  }
}
