/* ============================================ */
/* SHARED WORKOUT VIEWER                        */
/* Replica of the in-app workout result screen  */
/* (palette + type scale from palette.dart /    */
/* testStyles.dart — Outfit, radius 16, etc.)   */
/* ============================================ */

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

:root {
  --bg: #FFFFFF;
  --on-bg: #162D48;
  --surface: #F2F5F9;
  --primary: #2474D7;
  --primary-60: #7CB2F5;
  --primary-rgb: 36, 116, 215;
  --grey20: #6C7A8B;
  --grey30: #8E9BAB;
  --grey40: #A5BBD5;
  --positive: #6DBB6B;
  --positive-surface: #C3E5C3;
  --negative: #E27373;
  --negative-surface: #FBC8C8;
  --grabber: #D1E5FF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E0E;
    --on-bg: #FFFFFF;
    --surface: #181818;
    --primary: #2D8BFF;
    --primary-60: #5994DF;
    --primary-rgb: 45, 139, 255;
    --grey20: #9FAFC2;
    --grey40: #A5B8CF;
    --positive-surface: #497F48;
    --negative-surface: #A35757;
    --grabber: #2A3A4E;
  }
}

/* Accent follows the sharer's app theme (male blue / female red) */
:root[data-gender="female"] {
  --primary: #FF375B;
  --primary-60: #FF849A;
  --primary-rgb: 255, 55, 91;
}

html, body {
  background: var(--bg);
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--on-bg);
  letter-spacing: 0.02em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============================================ */
/* LOADING & ERROR STATES                       */
/* ============================================ */

.center-state {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(var(--primary-rgb), 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-badge {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.error-logo {
  width: 42px;
  height: 33px;
  color: var(--primary);
}

#state-error h2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
}

#state-error p {
  font-size: 16px;
  line-height: 24px;
  color: var(--grey20);
  max-width: 320px;
}

/* ============================================ */
/* LAYOUT                                       */
/* ============================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.topbar-title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ============================================ */
/* PULSING FJ BADGE                             */
/* ============================================ */

.badge {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breathe 2.6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.badge-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(var(--primary-rgb), 0.30) 50%,
    rgba(var(--primary-rgb), 0) 100%
  );
}

.badge-ring {
  position: absolute;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  border: 2px solid rgba(var(--primary-rgb), 0.6);
  animation: pulse-ring 2.6s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: 0.25; }
  100% { transform: scale(1.85); opacity: 0; }
}

.badge-circle {
  position: relative;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, var(--primary-60), var(--primary));
  border: 4px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-logo {
  width: 51px;
  height: 40px;
  color: #FFFFFF;
}

@media (prefers-reduced-motion: reduce) {
  .badge, .badge-ring { animation: none; }
  .badge-ring { opacity: 0; }
}

/* ============================================ */
/* HEADER TEXT                                  */
/* ============================================ */

.tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 8px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--primary);
}

.title {
  margin-top: 8px;
  text-align: center;
  font-size: 28px;
  line-height: 38px;
  font-weight: 700;
}

.coach {
  text-align: center;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--grey20);
}

/* ============================================ */
/* INFO CARDS                                   */
/* ============================================ */

.info-cards {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--surface);
}

.info-icon {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--primary);
}

.info-title {
  flex: 1;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--grey20);
}

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

.info-sub-label {
  font-size: 14px;
  line-height: 20px;
  color: var(--grey20);
}

.info-sub-value {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-trailing {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--on-bg);
}

.pos { color: var(--positive) !important; }
.neg { color: var(--negative) !important; }

/* ============================================ */
/* SECTIONS                                     */
/* ============================================ */

.section-title {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
}

#muscles-section { margin-top: 36px; }
#muscles-section .pills { margin-top: 14px; }
#strength-section { margin-top: 32px; }
#cardio-section { margin-top: 28px; }
.tile-list { margin-top: 12px; }

/* Muscle pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 4px 12px;
  border-radius: 24px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

/* ============================================ */
/* EXERCISE TILES                               */
/* ============================================ */

.tile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  letter-spacing: inherit;
  color: inherit;
  transition: transform 0.12s ease;
}

.tile:active { transform: scale(0.985); }

.tile-main {
  flex: 1;
  min-width: 0;
}

.tile-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  color: var(--on-bg);
}

.tile-info-icon {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--primary);
}

.tile-sub {
  font-size: 16px;
  line-height: 24px;
  color: var(--grey20);
  margin-top: 2px;
}

.tile-pct {
  flex: none;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--on-bg);
}

.cardio-chip {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(var(--primary-rgb), 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cardio-chip svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

/* ============================================ */
/* FOOTER                                       */
/* ============================================ */

.footer {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.app-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 32px;
  border-radius: 100px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

/* ============================================ */
/* BOTTOM SHEET (exercise detail)               */
/* ============================================ */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sheet-overlay.open { opacity: 1; }

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.sheet-overlay.open .sheet { transform: translateY(0); }

.grabber {
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--grabber);
  margin: 0 auto 40px;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: none;
}

.sheet-head-text { flex: 1; min-width: 0; }

.sheet-head h3 {
  font-size: 28px;
  line-height: 38px;
  font-weight: 700;
}

.sheet-sub {
  margin-top: 4px;
  font-size: 16px;
  line-height: 24px;
  color: var(--grey20);
}

.sheet-pct {
  flex: none;
  font-size: 28px;
  line-height: 38px;
  font-weight: 700;
}

.sheet-sets {
  margin-top: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.set-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--surface);
  flex: none;
}

.set-row.over { background: var(--positive-surface); }
.set-row.under { background: var(--negative-surface); }

.set-icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--primary);
}

.set-icon.skip {
  width: 24px;
  height: 24px;
  color: var(--grey40);
}

.set-label {
  margin-left: 12px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--on-bg);
}

.set-value {
  margin-left: auto;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--on-bg);
  text-align: right;
}

.set-row.skipped .set-label,
.set-row.skipped .set-value { color: var(--grey20); }

.set-times { color: var(--grey40); }

/* Cardio settings cards inside the sheet */
.cardio-settings {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cardio-setting {
  min-width: 140px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.cardio-setting .value {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  color: var(--on-bg);
}

.cardio-setting .name {
  margin-top: 8px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
  color: var(--grey30);
}
