/* ==========================================================================
   resource-style.css
   Styles for individual resource/article pages (/resources/resource-*.html)
   Uses the same custom-property names as the rest of the site (--ink,
   --ink-mute, --border, --font-display, --font-body) with safe fallbacks,
   so pages render consistently whether or not the global styles.css has
   already set those variables on :root.
   ========================================================================== */

:root {
  --r-ink: var(--ink, #111827);
  --r-ink-mute: var(--ink-mute, #6B7280);
  --r-border: var(--border, #E5E7EB);
  --r-bg: var(--bg, #F9FAFB);
  --r-card: #FFFFFF;
  --r-brand: var(--brand, #2563EB);
  --r-brand-dark: var(--brand-dark, #1D4ED8);
  --r-brand-soft: #EFF4FF;
  --r-radius: 14px;
  --r-radius-sm: 8px;
  --r-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
  --font-display: var(--font-display, 'Sora', 'Inter', sans-serif);
  --font-body: var(--font-body, 'Inter', sans-serif);
}

* { box-sizing: border-box; }

body {
  background: var(--r-bg);
  font-family: var(--font-body);
  color: var(--r-ink);
  margin: 0;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* -------------------- Back link -------------------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--r-ink-mute);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--r-brand);
}

/* -------------------- Hero image -------------------- */

.resource-hero-img {
  width: 100%;
  height: auto;
  aspect-ratio: 860 / 380;
  object-fit: cover;
  border-radius: var(--r-radius);
  background: var(--r-border);
  display: block;
  margin-bottom: 20px;
}

/* -------------------- Meta row / badges -------------------- */

.resource-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.badge-cat {
  background: var(--r-brand-soft);
  color: var(--r-brand-dark);
}

.badge-art {
  background: #F3F4F6;
  color: var(--r-ink-mute);
}

/* -------------------- Title / description / byline -------------------- */

.resource-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.15rem + 1.4vw, 2.1rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--r-ink);
  margin: 0 0 12px;
}

.resource-desc {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--r-ink-mute);
  margin: 0;
}

.resource-byline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 26px;
  font-size: 0.85rem;
  color: var(--r-ink-mute);
}

.resource-byline::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--r-brand), var(--r-brand-dark));
  display: inline-block;
  flex-shrink: 0;
}

.resource-byline__name {
  font-weight: 600;
  color: var(--r-ink);
}

/* -------------------- Action card / article body -------------------- */

.action-card {
  background: var(--r-card);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius);
  box-shadow: var(--r-shadow);
  padding: 28px clamp(18px, 4vw, 40px) 8px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.article-content {
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--r-ink);
}

.article-content h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--r-border);
}

.article-content h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--r-ink);
  margin: 34px 0 12px;
}

.article-content h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--r-ink);
  margin: 22px 0 8px;
}

.article-content p {
  margin: 0 0 16px;
}

.article-content ul,
.article-content ol {
  margin: 0 0 18px;
  padding-left: 22px;
}

.article-content li {
  margin-bottom: 8px;
}

.article-content li::marker {
  color: var(--r-brand);
}

.article-content a {
  color: var(--r-brand);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.35);
}

.article-content strong { color: var(--r-ink); }

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 0.95rem;
}

.article-content th,
.article-content td {
  border: 1px solid var(--r-border);
  padding: 8px 12px;
  text-align: left;
}

.article-content th {
  background: var(--r-bg);
  font-weight: 700;
}

.article-content blockquote {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-left: 3px solid var(--r-brand);
  background: var(--r-brand-soft);
  border-radius: 0 var(--r-radius-sm) var(--r-radius-sm) 0;
  color: var(--r-ink-mute);
}

.article-content img {
  max-width: 100%;
  border-radius: var(--r-radius-sm);
}

/* -------------------- Save row / save button -------------------- */

.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 28px calc(-1 * clamp(18px, 4vw, 40px)) 0;
  padding: 18px clamp(18px, 4vw, 40px);
  border-top: 1px solid var(--r-border);
}

.save-row-label {
  font-size: 0.88rem;
  color: var(--r-ink-mute);
}

.btn-save-resource {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--r-border);
  background: var(--r-card);
  color: var(--r-ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-save-resource svg {
  width: 18px;
  height: 18px;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.btn-save-resource:hover {
  border-color: var(--r-brand);
  color: var(--r-brand-dark);
}

.btn-save-resource:active {
  transform: scale(0.97);
}

.btn-save-resource:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Saved (active) state */
.btn-save-resource.is-saved {
  background: var(--r-brand-soft);
  border-color: var(--r-brand);
  color: var(--r-brand-dark);
}

.btn-save-resource.is-saved svg {
  fill: var(--r-brand);
  stroke: var(--r-brand);
}

/* -------------------- Toast -------------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--r-ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--r-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast.toast--error {
  background: #B91C1C;
}

#toast.toast--success {
  background: #15803D;
}

/* -------------------- Responsive -------------------- */

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 90px;
  }

  .action-card {
    padding: 22px 16px 6px;
    border-radius: 12px;
  }

  .save-row {
    margin: 24px -16px 0;
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .btn-save-resource {
    justify-content: center;
  }
}
