/* Apple Podcasts-flavoured light theme. Single theme on purpose: no dark overrides. */
:root {
  --color-ground: #f2f2f7;
  --color-surface: #ffffff;
  --color-label: #1d1d1f;
  --color-secondary: #6e6e73;
  --color-tertiary: #aeaeb2;
  --color-separator: rgba(60, 60, 67, 0.16);
  --color-fill: rgba(120, 120, 128, 0.12);
  /* Apple Podcasts icon gradient, and a solid purple from its middle for text. */
  --color-gradient-top: #f452ff;
  --color-gradient-bottom: #832bc1;
  --gradient: linear-gradient(180deg, var(--color-gradient-top), var(--color-gradient-bottom));
  --color-accent: #9a3ad6;
  --color-accent-tint: rgba(186, 66, 230, 0.1);
  --color-accent-line: rgba(154, 58, 214, 0.35);
  --color-danger: #ff3b30;
  --color-overlay: rgba(186, 66, 230, 0.16);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', system-ui, sans-serif;

  --text-large-title: 2.125rem; /* 34px, iOS large title */
  --text-title: 1.375rem; /* 22px */
  --text-body: 1.0625rem; /* 17px, iOS body */
  --text-subhead: 0.9375rem; /* 15px */
  --text-footnote: 0.8125rem; /* 13px */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-artwork: 14px;
  --radius-thumb: 8px;
  --radius-group: 12px;
  --radius-sheet: 20px;

  --shadow-artwork: 0 12px 32px rgba(29, 29, 31, 0.22), 0 2px 6px rgba(29, 29, 31, 0.12);
  --shadow-sheet: 0 20px 60px rgba(29, 29, 31, 0.18);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-ground);
  color: var(--color-label);
  font: var(--text-body) / 1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

h1,
h2,
h3,
p {
  margin: 0;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---- Buttons ---- */

.button-primary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: 999px;
  font: 600 var(--text-subhead) / 1 var(--font);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.button-primary {
  background: var(--gradient);
  color: var(--color-surface);
}

.button-primary:hover {
  filter: brightness(0.94);
}

.button-secondary {
  background: var(--color-fill);
  color: var(--color-accent);
}

.button-secondary:hover {
  background: var(--color-accent-tint);
}

.button-primary:active,
.button-secondary:active {
  transform: scale(0.97);
}

.button-primary svg,
.button-secondary svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.dropzone:has(#file:focus-visible) {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.button-link {
  border: 0;
  background: none;
  padding: var(--space-2);
  color: var(--color-secondary);
  font: var(--text-footnote) / 1.3 var(--font);
  cursor: pointer;
}

.button-link:hover {
  color: var(--color-label);
}

/* ---- Sign-in sheet ---- */

.sheet {
  width: min(400px, calc(100% - 2 * var(--space-4)));
  margin: max(12vh, var(--space-7)) auto var(--space-7);
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-radius: var(--radius-sheet);
  background: var(--color-surface);
  box-shadow: var(--shadow-sheet);
  text-align: center;
}

.sheet-icon {
  display: block;
  margin: 0 auto var(--space-4);
  border-radius: 16px;
}

.sheet h1 {
  font: 700 var(--text-title) / 1.2 var(--font-display);
  letter-spacing: -0.01em;
}

.sheet > p {
  margin-top: var(--space-2);
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

.sheet form {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.sheet input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-thumb);
  background: var(--color-fill);
  color: var(--color-label);
  font: var(--text-body) var(--font);
}

.sheet input::placeholder {
  color: var(--color-tertiary);
}

.sheet .sheet-hint {
  margin-top: var(--space-4);
  font-size: var(--text-footnote);
}

.sheet-error {
  color: var(--color-danger);
  font-size: var(--text-footnote);
}

/* ---- App layout ---- */

main {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-6);
  padding-left: max(var(--space-5), env(safe-area-inset-left));
  padding-right: max(var(--space-5), env(safe-area-inset-right));
}

/* ---- Show header ---- */

.show {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-6);
  align-items: end;
}

.artwork {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-artwork);
  background: var(--color-fill);
  box-shadow: var(--shadow-artwork);
  object-fit: cover;
}

.show-text h1 {
  font: 700 var(--text-large-title) / 1.12 var(--font-display);
  letter-spacing: -0.022em;
  overflow-wrap: anywhere;
}

.show-author {
  margin-top: var(--space-1);
  color: var(--color-accent);
  font-size: var(--text-title);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.show-description {
  max-width: 60ch;
  margin-top: var(--space-3);
  color: var(--color-secondary);
  font-size: var(--text-subhead);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.show-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ---- Drop zone ---- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 240px;
  margin-top: var(--space-7);
  padding: var(--space-6) var(--space-5);
  border: 2px dashed var(--color-accent-line);
  border-radius: var(--radius-sheet);
  background: var(--color-surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.dropzone:hover,
body.dragging .dropzone {
  border-color: var(--color-accent);
  background: var(--color-accent-tint);
}

.dropzone-badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  background: var(--gradient);
  color: var(--color-surface);
  box-shadow: 0 8px 20px rgba(131, 43, 193, 0.3);
}

.dropzone-badge svg {
  width: 30px;
  height: 30px;
  stroke-width: 2.2;
}

.dropzone-title {
  font: 700 var(--text-title) / 1.2 var(--font-display);
  letter-spacing: -0.01em;
}

.dropzone-sub {
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

/* Wording follows the input: "drop / click" with a mouse, "tap" on touch screens. */
.pointer-coarse {
  display: none;
}

@media (pointer: coarse) {
  .pointer-fine {
    display: none;
  }

  .pointer-coarse {
    display: inline;
  }
}

/* ---- Episode list (inset grouped, like iOS) ---- */

.episodes {
  margin-top: var(--space-6);
}

.episodes-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
  padding: 0 var(--space-1);
}

.episodes-heading h2 {
  font: 700 var(--text-title) / 1.2 var(--font-display);
  letter-spacing: -0.01em;
}

#episode-count {
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: var(--radius-group);
  background: var(--color-surface);
  overflow: hidden;
}

.list:empty {
  display: none;
}

#uploads {
  margin-bottom: var(--space-4);
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
}

/* Inset separators that start after the artwork, as in iOS lists. */
.row + .row::before {
  content: '';
  position: absolute;
  top: 0;
  left: calc(var(--space-4) + 64px + var(--space-4));
  right: 0;
  border-top: 1px solid var(--color-separator);
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-thumb);
  background: var(--color-fill);
  object-fit: cover;
}

.row-text {
  min-width: 0;
}

.row-date {
  display: block;
  color: var(--color-secondary);
  font-size: var(--text-footnote);
  font-weight: 600;
}

.row-title {
  margin-top: 2px;
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.row-description {
  margin-top: 2px;
  color: var(--color-secondary);
  font-size: var(--text-subhead);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-duration {
  margin-top: var(--space-1);
  color: var(--color-accent);
  font-size: var(--text-footnote);
  font-weight: 600;
}

.row-action {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-tertiary);
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.row-action:hover {
  color: var(--color-danger);
  background: var(--color-fill);
}

.row-action svg {
  width: 20px;
  height: 20px;
}

/* ---- Upload rows with the download-style progress ring ---- */

.ring {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-thumb);
  background: var(--color-accent-tint);
  color: var(--color-accent);
}

.ring svg {
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
}

.ring .track {
  stroke: var(--color-separator);
  stroke-width: 3;
}

.ring .value {
  stroke: var(--color-accent);
  stroke-width: 3;
  stroke-dasharray: 88;
  stroke-dashoffset: 88;
  transition: stroke-dashoffset 0.2s linear;
}

.ring.processing svg {
  animation: spin 0.9s linear infinite;
}

.ring.done {
  background: var(--gradient);
  color: var(--color-surface);
}

.ring.done svg {
  transform: none;
}

.ring.failed {
  background: rgba(255, 59, 48, 0.1);
  color: var(--color-danger);
}

.ring.failed svg {
  transform: none;
}

.row-status {
  margin-top: 2px;
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

.row-status.failed {
  color: var(--color-danger);
}

@keyframes spin {
  from {
    transform: rotate(-90deg);
  }
  to {
    transform: rotate(270deg);
  }
}

/* ---- Empty state ---- */

.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.empty svg {
  width: 44px;
  height: 44px;
  color: var(--color-accent);
  stroke-width: 1.6;
}

.empty h3 {
  margin-top: var(--space-3);
  font-size: var(--text-body);
  font-weight: 600;
}

.empty p {
  max-width: 34ch;
  margin: var(--space-1) auto 0;
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

footer {
  margin-top: var(--space-6);
  text-align: center;
}

/* ---- Whole-page drop overlay ---- */

#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--color-overlay);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s var(--ease), visibility 0.18s;
}

body.dragging #drop-overlay {
  opacity: 1;
  visibility: visible;
}

.drop-card {
  width: min(360px, 100%);
  padding: var(--space-6) var(--space-5);
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-sheet);
  background: var(--color-surface);
  box-shadow: var(--shadow-sheet);
  text-align: center;
  transform: scale(0.96);
  transition: transform 0.18s var(--ease);
}

body.dragging .drop-card {
  transform: scale(1);
}

.drop-card svg {
  width: 48px;
  height: 48px;
  color: var(--color-accent);
}

#drop-title {
  margin-top: var(--space-3);
  font: 700 var(--text-title) / 1.2 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.drop-sub {
  margin-top: var(--space-1);
  color: var(--color-secondary);
  font-size: var(--text-subhead);
}

/* ---- Phone layout: stacked and centred, like the iOS show page ---- */

@media (max-width: 640px) {
  main {
    padding-top: var(--space-6);
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
  }

  .show {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--space-5);
    text-align: center;
  }

  .artwork {
    width: 200px;
    height: 200px;
  }

  .show-text h1 {
    font-size: 1.75rem;
  }

  .show-author {
    font-size: var(--text-body);
  }

  .show-description {
    margin-left: auto;
    margin-right: auto;
  }

  .show-actions {
    justify-content: center;
  }

  .show-actions > * {
    flex: 1 1 150px;
    padding: 0 var(--space-4);
    white-space: nowrap;
  }

  .dropzone {
    min-height: 180px;
    margin-top: var(--space-6);
  }

  .row {
    grid-template-columns: 56px 1fr auto;
    gap: var(--space-3);
  }

  .thumb,
  .ring {
    width: 56px;
    height: 56px;
  }

  .row + .row::before {
    left: calc(var(--space-4) + 56px + var(--space-3));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
