/* Podcast Digest — Editorial Stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,700;1,6..72,400&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-raised: #fdfcfa;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --border: #e7e5e0;
  --border-light: #f0eeea;
  --header-bg: #1c1917;
  --header-accent: #d4a574;
  --link: #92400e;

  --must-listen: #15803d;
  --must-listen-bg: #f0fdf2;
  --must-listen-border: #bbf7c8;
  --outside-bubble: #1d4ed8;
  --outside-bubble-bg: #eff5ff;
  --outside-bubble-border: #bfdbfe;
  --worth-a-look: #a16207;
  --worth-a-look-bg: #fefce8;
  --worth-a-look-border: #fde68a;
  --safe-to-skip: #78716c;
  --safe-to-skip-bg: #fafaf9;
  --safe-to-skip-border: #e7e5e4;
  --unanalyzed: #a8a29e;
  --unanalyzed-bg: #fafaf9;
  --unanalyzed-border: #e7e5e4;

  --feedback-up: #16a34a;
  --feedback-up-bg: #dcfce7;
  --feedback-down: #dc2626;
  --feedback-down-bg: #fee2e2;

  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.06), 0 1px 2px rgba(28, 25, 23, 0.04);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--text); }

/* ─── Header ─── */

header {
  background: var(--header-bg);
  color: #fff;
  padding: 0;
  border-bottom: 3px solid var(--header-accent);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 24px;
}

header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.1;
}

header .subtitle {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--header-accent);
  font-size: 16px;
  margin-top: 6px;
  font-weight: 400;
}

nav {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 24px;
}

nav a {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding-bottom: 2px;
  transition: color 0.2s;
}

nav a.active {
  color: #fff;
  border-bottom: 2px solid var(--header-accent);
}

nav a:hover { color: #fff; }

/* ─── Main ─── */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ─── Tier Sections ─── */

.tier-section {
  margin-bottom: 40px;
  animation: fadeInUp 0.4s ease both;
}

.tier-section:nth-child(1) { animation-delay: 0.05s; }
.tier-section:nth-child(2) { animation-delay: 0.15s; }
.tier-section:nth-child(3) { animation-delay: 0.25s; }
.tier-section:nth-child(4) { animation-delay: 0.35s; }
.tier-section:nth-child(5) { animation-delay: 0.45s; }

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

.tier-heading {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding-bottom: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-heading::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-heading-must_listen { color: var(--must-listen); border-color: var(--must-listen); }
.tier-heading-must_listen::before { background: var(--must-listen); }
.tier-heading-outside_bubble { color: var(--outside-bubble); border-color: var(--outside-bubble); }
.tier-heading-outside_bubble::before { background: var(--outside-bubble); }
.tier-heading-worth_a_look { color: var(--worth-a-look); border-color: var(--worth-a-look); }
.tier-heading-worth_a_look::before { background: var(--worth-a-look); }
.tier-heading-safe_to_skip { color: var(--safe-to-skip); border-color: var(--safe-to-skip-border); }
.tier-heading-safe_to_skip::before { background: var(--safe-to-skip); }
.tier-heading-unanalyzed { color: var(--unanalyzed); border-color: var(--unanalyzed-border); }
.tier-heading-unanalyzed::before { background: var(--unanalyzed); }

/* ─── Episode Cards ─── */

.episode-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.episode-card:hover {
  box-shadow: var(--shadow);
}

.episode-card-must_listen {
  background: var(--must-listen-bg);
  border-color: var(--must-listen-border);
  border-left-color: var(--must-listen);
}

.episode-card-outside_bubble {
  background: var(--outside-bubble-bg);
  border-color: var(--outside-bubble-border);
  border-left-color: var(--outside-bubble);
}

.episode-card-worth_a_look {
  background: var(--worth-a-look-bg);
  border-color: var(--worth-a-look-border);
  border-left-color: var(--worth-a-look);
}

.episode-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.podcast-name {
  font-weight: 600;
  letter-spacing: 0.2px;
}

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

.duration::before {
  content: '\00b7';
  margin-right: 6px;
}

.episode-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.episode-title a {
  color: var(--text);
  transition: color 0.2s;
}

.episode-title a:hover {
  color: var(--link);
}

.rationale {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
  font-style: italic;
}

.episode-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ─── Feedback Buttons ─── */

.feedback-buttons {
  display: inline-flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 20px;
  padding: 3px;
}

.btn-feedback {
  background: transparent;
  border: none;
  border-radius: 16px;
  width: 36px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.4;
  position: relative;
}

.btn-feedback:hover {
  opacity: 0.8;
  background: var(--surface);
}

.btn-feedback.active {
  opacity: 1;
  transform: scale(1.1);
}

.btn-up.active {
  background: var(--feedback-up-bg);
}

.btn-down.active {
  background: var(--feedback-down-bg);
}

/* ─── Skip List ─── */

.skip-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.skip-list li {
  padding: 12px 16px;
}

.skip-list li:not(:last-child) {
  border-bottom: 1px solid var(--border-light);
}

.skip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.skip-text {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
  line-height: 1.4;
}

.skip-text .podcast-name {
  color: var(--text-muted);
  font-weight: 500;
}

.unanalyzed-note {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
}

/* ─── History ─── */

.history-list { list-style: none; }
.history-list li {
  margin-bottom: 4px;
  animation: fadeInUp 0.3s ease both;
}

.history-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.history-link:hover {
  box-shadow: var(--shadow);
  border-color: var(--border);
  transform: translateX(4px);
}

.history-date {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.history-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Empty State ─── */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 8px;
  font-size: 15px;
}

.empty-state p:first-child {
  font-family: var(--font-display);
  font-size: 20px;
  font-style: italic;
  color: var(--text-secondary);
}

/* ─── Dark Mode ─── */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --surface: #1c1917;
    --surface-raised: #292524;
    --text: #e7e5e4;
    --text-secondary: #a8a29e;
    --text-muted: #78716c;
    --border: #44403c;
    --border-light: #292524;
    --header-bg: #0c0a09;
    --header-accent: #d4a574;
    --link: #d4a574;

    --must-listen-bg: #052e16;
    --must-listen-border: #14532d;
    --outside-bubble-bg: #0c1a3d;
    --outside-bubble-border: #1e3a5f;
    --worth-a-look-bg: #271a05;
    --worth-a-look-border: #422006;
    --safe-to-skip-bg: #1c1917;
    --safe-to-skip-border: #292524;
    --unanalyzed-bg: #1c1917;
    --unanalyzed-border: #292524;

    --feedback-up-bg: #14532d;
    --feedback-down-bg: #7f1d1d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  header {
    border-bottom-color: var(--header-accent);
  }

  .episode-title a { color: var(--text); }
  .episode-title a:hover { color: var(--header-accent); }

  .history-link:hover { border-color: var(--border); }
  .history-date { color: var(--text); }

  .btn-feedback { opacity: 0.35; }
  .btn-feedback:hover { opacity: 0.7; background: var(--surface-raised); }
}

/* Manage Subscriptions */

.manage-upload,
.manage-result {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.manage-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.manage-upload form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.manage-upload input[type="file"] {
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.btn-primary {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  background: var(--link);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }

.sync-summary {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 2rem;
  margin: 1.5rem 0;
}

.sync-summary li {
  font-size: 1rem;
  color: var(--text-secondary);
}

.total-active {
  font-size: 1.1rem;
  margin-top: 1rem;
}

/* ─── Login ─── */

.login-form {
  max-width: 340px;
  margin: 0 auto;
  padding-top: 32px;
}

.login-form form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-form label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: -0.4rem;
}

.login-form input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--header-accent);
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}

.login-form .btn-primary {
  margin-top: 0.5rem;
  width: 100%;
}

.totp-prompt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

.login-error {
  color: var(--feedback-down);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0.6rem 1rem;
  background: var(--feedback-down-bg);
  border-radius: 6px;
  text-align: center;
}

/* ─── Nav Logout ─── */

nav .nav-logout {
  margin-left: auto;
  opacity: 0.4;
  font-size: 12px;
}

nav .nav-logout:hover {
  opacity: 1;
}
