/* ============================================================
   Loop Practice — styles.css
   Layout 2: Card Stack
   ============================================================ */

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

:root {
  --clr-a: #4ecdc4;
  --clr-b: #f7b731;
  --clr-playhead: #ff5252;
  --clr-track: #e4e4ea;
  --clr-range: rgba(78,205,196,.22);

  --clr-bg: #eef0f5;
  --clr-surface: #ffffff;
  --clr-border: #e2e2ea;
  --clr-text: #16161a;
  --clr-text-muted: #999;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;

  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --shadow: 0 2px 8px rgba(0,0,0,.07);

  --bar-height: 8px;
  --handle-size: 28px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

html, body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---- App shell ---- */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--sp-md) var(--sp-md) 120px; /* bottom pad for PiP */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-xs);
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--clr-text);
  text-decoration: none;
}
.logo em {
  font-style: normal;
  color: var(--clr-b);
}

.btn-auth {
  font-size: 13px;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--clr-border);
  background: none;
  cursor: pointer;
  color: var(--clr-text);
  font-family: var(--font);
}
.btn-auth:hover { background: var(--clr-border); }

/* ---- Cards ---- */
.card {
  background: var(--clr-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  box-shadow: var(--shadow);
  border-top: 3px solid transparent;
}

.card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--clr-text-muted);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-md);
}

/* Card accent colours */
.card-loop  { border-top-color: var(--clr-a); overflow: visible; padding-left: 10px; padding-right: 10px; }
.card-play  { border-top-color: var(--clr-playhead); }
.card-saves { border-top-color: var(--clr-b); }
.card-shared { border-top-color: var(--clr-border); }
.card-url   { border-top-color: var(--clr-border); padding: 0; overflow: hidden; }

/* ---- URL card ---- */
.url-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--clr-text);
  font-family: var(--font);
}
.url-chevron {
  font-size: 18px;
  color: var(--clr-text-muted);
  transition: transform .2s;
  display: inline-block;
}
.url-chevron.open { transform: rotate(90deg); }

.url-body { padding: 0 var(--sp-md) var(--sp-md); }
.url-input-row { display: flex; gap: var(--sp-sm); }
.url-input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font);
  color: var(--clr-text);
  background: var(--clr-bg);
}
.url-input:focus { outline: none; border-color: var(--clr-a); }
.btn-load {
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: var(--clr-text);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
}
.btn-load:hover { opacity: .85; }

.error-message {
  color: #e74c3c;
  font-size: 13px;
  margin-top: var(--sp-sm);
  display: none;
}
.error-message.show { display: block; }

.youtube-player {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
}
.youtube-player iframe { width: 100%; height: 100%; border: none; display: block; }

/* ---- Loop card bars ---- */

.loop-summary {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--clr-text-muted);
}

/* Shared bar wrapper */
.bar-wrap {
  position: relative;
  height: 60px;
  display: flex;
  align-items: flex-end;
  padding: 0 20px;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
  margin: 4px 0 2px;
}

.bar-track {
  position: relative;
  width: 100%;
  height: var(--bar-height);
  background: var(--clr-track);
  border-radius: var(--r-pill);
  overflow: visible;
}

/* Range fill on loop bar */
.progress-range {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--clr-range);
  border-radius: var(--r-pill);
  pointer-events: none;
}

/* Play bar — slimmer, round dot playhead */
.bar-wrap-play {
  height: 44px;
  cursor: pointer;
  margin-top: 0;
}
.bar-wrap-play .bar-track { height: 4px; }

/* Dims out-of-loop sections on play bar */
.play-range-dim {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(0,0,0,.06);
  border-radius: var(--r-pill);
  pointer-events: none;
}

/* Playhead — round dot on play bar */
.progress-playhead {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--clr-playhead);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  left: 0%;
  z-index: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

/* ---- Flag handles (loop bar) ---- */
.handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 48px;
  cursor: grab;
  touch-action: none;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border-radius: 0;
  box-shadow: none;
  font-size: 0;
  color: transparent;
}
.handle:active { cursor: grabbing; }

.handle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 8px;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 1px;
  pointer-events: none;
}

.handle::after {
  content: attr(data-label);
  position: absolute;
  top: 0;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.4;
}

.handle-a { left: 0%; }
.handle-a::before { background: var(--clr-a); }
.handle-a::after  { background: var(--clr-a); right: calc(50%); left: auto; }

.handle-b { left: 100%; }
.handle-b::before { background: var(--clr-b); }
.handle-b::after  { background: var(--clr-b); left: calc(50%); }

/* Loupe */
.loupe {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--clr-text);
  color: #fff;
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: var(--r-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
  z-index: 20;
}
.loupe::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--clr-text);
}
.loupe.visible { opacity: 1; }

/* Time rows */
.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  padding: 0 4px;
}
.time-row-play { margin-top: 0; margin-bottom: var(--sp-xs); }
.time-label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--clr-text-muted);
}
.time-a { color: var(--clr-a); }
.time-b { color: var(--clr-b); }
.time-pos { color: var(--clr-playhead); }


.loop-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
}

/* ---- Playback card ---- */
.card-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-sm);
}

.card-play-row1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  width: 100%;
}

.card-play-row2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
}

/* Jog buttons */
.jog-group { display: flex; gap: 3px; align-items: center; }

.btn-jog {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--clr-border);
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--clr-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  padding: 0;
}
.btn-jog:active { background: var(--clr-border); color: var(--clr-text); }
.btn-jog:disabled { opacity: .3; cursor: not-allowed; }
.jog-a .btn-jog { border-color: color-mix(in srgb, var(--clr-a) 40%, var(--clr-border)); color: var(--clr-a); }
.jog-b .btn-jog { border-color: color-mix(in srgb, var(--clr-b) 40%, var(--clr-border)); color: var(--clr-b); }
.jog-a .btn-jog:disabled, .jog-b .btn-jog:disabled { color: var(--clr-text-muted); border-color: var(--clr-border); }

/* Row 1: set-a | play | set-b */
.btn-set-point {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 2px solid;
  background: none;
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.btn-set-point:disabled { opacity: .35; cursor: not-allowed; }

.btn-set-a {
  color: var(--clr-a);
  border-color: var(--clr-a);
  justify-self: end;
}
.btn-set-a:not(:disabled):active { background: var(--clr-a); color: #fff; }

.btn-set-b {
  color: var(--clr-b);
  border-color: var(--clr-b);
  justify-self: start;
}
.btn-set-b:not(:disabled):active { background: var(--clr-b); color: #fff; }

.btn-play-pause {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--clr-text);
  color: #fff;
  border: none;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  grid-column: 2;
  grid-row: 1;
}
.btn-play-pause:active { transform: scale(.93); }
.btn-play-pause:disabled { opacity: .4; cursor: not-allowed; }

/* Row 2: reset (col 1) + speed (col 3), centred under their respective set buttons */
.btn-reset {
  grid-column: 1;
  grid-row: 2;
  justify-self: end;
  background: none;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 13px;
  color: var(--clr-text-muted);
  cursor: pointer;
  font-family: var(--font);
}
.btn-reset:active { background: var(--clr-border); }
.btn-reset:disabled { opacity: .4; cursor: not-allowed; }

.btn-speed {
  grid-column: 3;
  grid-row: 2;
  justify-self: start;
  background: var(--clr-bg);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--clr-text);
  cursor: pointer;
}
.btn-speed:active { background: var(--clr-border); }
.btn-speed:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Saves card ---- */
.saves-title-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.count-chip {
  font-size: 11px;
  background: var(--clr-bg);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  color: var(--clr-text-muted);
  font-family: var(--font-mono);
}

.btn-save {
  font-size: 13px;
  padding: 6px 18px;
  border-radius: var(--r-pill);
  background: var(--clr-b);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-family: var(--font);
}
.btn-save:hover { opacity: .9; }

/* Bookmark items */
.favorite-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) 0;
  border-bottom: 1px solid var(--clr-border);
}
.favorite-item:last-child { border-bottom: none; }

.favorite-header {
  flex: 1;
  min-width: 0;
}
.favorite-header strong {
  font-size: 14px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.favorite-time {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--clr-text-muted);
}

.btn-fav-action {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.btn-fav-action:hover { background: var(--clr-border); }

/* Shared section bookmark items */
.shared-fav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) 0;
  border-bottom: 1px solid var(--clr-border);
  font-size: 14px;
}
.shared-fav-item:last-child { border-bottom: none; }
.shared-fav-item .fav-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--clr-text-muted);
  flex: 1;
}
.shared-fav-item button {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-md);
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
}

/* Share all / unshare all button */
#btn-share-video {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--clr-border);
  background: none;
  cursor: pointer;
  color: var(--clr-text-muted);
  font-family: var(--font);
  margin-bottom: var(--sp-sm);
}
#btn-share-video:hover { background: var(--clr-bg); }

/* Guest banner */
.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-md);
  background: #fff8e1;
  border: 1px solid #ffe082;
  font-size: 13px;
  color: #795548;
}
.btn-signin-nudge {
  background: none;
  border: none;
  color: #795548;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: underline;
}

/* ---- PiP video ---- */
.pip-wrap {
  position: fixed;
  bottom: var(--sp-md);
  right: var(--sp-md);
  z-index: 100;
}

.pip-thumb {
  width: 130px;
  aspect-ratio: 16/9;
  border-radius: var(--r-md);
  background: #111;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 20px;
  overflow: hidden;
  transition: width .3s ease;
}
.pip-thumb.expanded {
  position: fixed;
  bottom: auto;
  top: 0; left: 0; right: 0;
  width: 100%;
  border-radius: 0;
  aspect-ratio: 16/9;
}
.pip-thumb iframe { width: 100%; height: 100%; border: none; display: block; }

/* ---- Modals / overlays (save dialog etc.) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-sheet {
  background: var(--clr-surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--sp-lg) var(--sp-md);
  width: 100%;
  max-width: 480px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: var(--sp-lg); }
.modal-row { margin-bottom: var(--sp-md); }
.modal-row label { font-size: 13px; color: var(--clr-text-muted); display: block; margin-bottom: var(--sp-xs); }
.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font);
}
.modal-input:focus { outline: none; border-color: var(--clr-a); }
.modal-actions { display: flex; gap: var(--sp-sm); margin-top: var(--sp-lg); }
.btn-modal-primary {
  flex: 1;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--clr-text);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.btn-modal-cancel {
  flex: 1;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--clr-bg);
  color: var(--clr-text);
  border: none;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font);
}
.time-info-box {
  background: var(--clr-bg);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.time-info-box .ti-label { font-size: 11px; color: var(--clr-text-muted); }
.time-info-box .ti-value { font-size: 20px; font-family: var(--font-mono); font-weight: 300; }

/* ---- Limit exceeded overlay ---- */
.limit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
}
.limit-box {
  background: var(--clr-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.limit-box h2 { font-size: 20px; margin-bottom: var(--sp-sm); }
.limit-box p { font-size: 14px; color: var(--clr-text-muted); margin-bottom: var(--sp-lg); }
.limit-box .btn-modal-primary { display: block; width: 100%; margin-bottom: var(--sp-sm); }
.limit-box .btn-modal-cancel { display: block; width: 100%; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  body { background: var(--clr-bg); }
  .app { padding: var(--sp-sm) var(--sp-sm) 120px; }
}
