/* =========================================================
   Rivista SIMG — Article stylesheet
   Hero, body typography, flowcharts, tables, references,
   footer, PDF buttons, reading progress, callouts.
   ========================================================= */

/* ---------- Reading progress bar ---------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 200;
  pointer-events: none;
}
.reading-progress::before {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, #f3a25b 100%);
  transform-origin: left center;
  transform: scaleX(var(--reading-progress, 0));
  transition: transform 80ms linear;
  box-shadow: 0 0 8px rgba(232, 121, 43, 0.4);
}

/* ---------- Section badge ---------- */
.section-badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-primary);
  background: rgba(26, 127, 181, 0.1);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

/* ---------- Article hero ---------- */
.article-hero {
  background:
    radial-gradient(1200px 300px at 80% -20%, rgba(232, 121, 43, 0.08), transparent 70%),
    linear-gradient(135deg, #f0f4f7 0%, #dfe8ee 100%);
  padding: clamp(32px, 6vw, 56px) 20px clamp(28px, 5vw, 44px);
  border-bottom: 3px solid var(--color-primary);
}
.article-hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.hero-image {
  flex-shrink: 0;
  width: 150px;
  height: 190px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.hero-text { flex: 1; min-width: 0; }

.article-hero h1 {
  font-family: var(--font-body);
  font-size: clamp(1.4rem, 1rem + 1.6vw, 1.85rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-primary-deep);
  margin-bottom: 10px;
  letter-spacing: -0.005em;
}
.article-hero .subtitle {
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.05rem);
  font-style: italic;
  color: var(--color-text-light);
  margin-bottom: 16px;
  line-height: 1.45;
}
.article-authors {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--color-text-light);
  line-height: 1.55;
}
.article-authors strong { color: var(--color-text); font-weight: 600; }
.author-affil {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- PDF buttons ---------- */
.pdf-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  border: 1.5px solid var(--color-accent);
  box-shadow: 0 4px 12px rgba(232, 121, 43, 0.25);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-med) var(--ease),
    background var(--t-fast) var(--ease);
  white-space: nowrap;
}
.pdf-button:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(232, 121, 43, 0.35);
}
.pdf-button:focus-visible {
  outline: 2px solid var(--color-primary-dark);
  outline-offset: 2px;
  border-radius: 2px;
}
.pdf-button:active { transform: translateY(0); }
.pdf-button::before {
  content: "⬇";
  font-size: 0.95em;
  line-height: 1;
}

.pdf-button--secondary {
  background: transparent;
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
  box-shadow: none;
}
.pdf-button--secondary:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 6px 16px rgba(26, 127, 181, 0.25);
}
.pdf-button--secondary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Article body ---------- */
.article-body {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 44px) 20px 60px;
}
.article-body p {
  margin-bottom: 1.15em;
  text-align: justify;
  hyphens: auto;
}
.article-body p.first-para::first-letter {
  font-size: 3.2em;
  float: left;
  line-height: 0.82;
  margin: 6px 10px 0 0;
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-body);
}
.article-body h2 {
  font-family: var(--font-ui);
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.25rem);
  font-weight: 700;
  color: var(--color-primary-dark);
  margin: 2em 0 0.65em;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-border);
  scroll-margin-top: 110px;
  position: relative;
}
.article-body h2[id] { cursor: pointer; }
.article-body h2[id]::before {
  content: "#";
  position: absolute;
  left: -0.85em;
  top: 0;
  color: var(--color-accent);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.article-body h2[id]:hover::before { opacity: 1; }

.article-body h3 {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 1.6em 0 0.5em;
}
.article-body ul,
.article-body ol {
  margin: 0 0 1.15em 1.3em;
}
.article-body li { margin-bottom: 0.35em; }

.article-body sup { font-size: 0.65em; vertical-align: super; }
.article-body em { font-style: italic; }
.article-body strong { font-weight: 600; }

/* ---------- Callout ---------- */
.callout {
  margin: 1.8em 0;
  padding: 18px 22px;
  background: rgba(26, 127, 181, 0.06);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.6;
}
.callout--accent {
  background: rgba(232, 121, 43, 0.07);
  border-left-color: var(--color-accent);
}
.callout--warning {
  background: rgba(232, 121, 43, 0.07);
  border-left-color: var(--color-accent);
}
.callout-title {
  display: block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--color-primary-dark);
  margin-bottom: 6px;
}
.callout--accent .callout-title { color: var(--color-accent-dark); }

/* ---------- Figure / caption ---------- */
figure {
  margin: 2em 0;
}
figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
figcaption {
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-light);
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

/* ---------- Flowchart ---------- */
.flowchart {
  margin: 2em 0;
  padding: 26px 18px;
  background: #f7fafb;
  border: 1px solid #d6e4eb;
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.flowchart-title {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: 18px;
}
.fc-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.fc-box {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  min-width: 130px;
  max-width: 220px;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}
.fc-box.primary {
  background: var(--color-primary);
  color: white;
}
.fc-box.secondary {
  background: #e1eff6;
  color: var(--color-primary-deep);
  border: 1px solid #b5d4e8;
}
.fc-box.accent {
  background: #fff3e6;
  color: #a35600;
  border: 1px solid #f0d4a8;
}
.fc-box.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.fc-arrow {
  text-align: center;
  color: var(--color-primary);
  font-size: 1.25rem;
  margin: 4px 0;
  line-height: 1;
}

/* ---------- Table ---------- */
.table-wrapper {
  margin: 2em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  min-width: 520px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
}
.table-wrapper caption {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  text-align: left;
  margin-bottom: 10px;
  line-height: 1.4;
}
.table-wrapper th {
  background: var(--color-primary);
  color: white;
  padding: 11px 9px;
  text-align: center;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table-wrapper td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  vertical-align: middle;
}
.table-wrapper tbody tr:nth-child(odd) { background: rgba(240, 244, 247, 0.5); }
.table-wrapper tbody tr:hover { background: #edf4f8; }
.table-wrapper .row-label {
  text-align: left;
  font-weight: 700;
  background: #f0f4f7;
  color: var(--color-primary-deep);
}
.table-note {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  color: var(--color-text-muted);
  margin-top: 8px;
  line-height: 1.5;
  font-style: italic;
}

/* ---------- References ---------- */
.references {
  margin-top: 2.6em;
  padding-top: 1.6em;
  border-top: 2px solid var(--color-border);
}
.references h2 {
  font-family: var(--font-ui);
  font-size: 1rem;
  border: none;
  padding: 0;
  margin-bottom: 0.9em;
  color: var(--color-primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ref-list {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--color-text-light);
}
.ref-list p,
.ref-list li {
  text-align: left;
  margin-bottom: 0.5em;
  padding-left: 1.8em;
  text-indent: -1.8em;
  list-style: none;
}

/* ---------- Article footer ---------- */
.article-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 44px;
}
.article-meta-footer {
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-light);
  line-height: 1.7;
  margin-bottom: 18px;
}
.article-meta-footer strong { color: var(--color-text); font-weight: 600; }
.article-footer .footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .article-hero { padding: 28px 16px 24px; }
  .article-hero-inner { flex-direction: column; gap: 16px; }
  .hero-image { width: 100%; max-width: 220px; height: auto; aspect-ratio: 150/190; align-self: center; }
  .article-hero h1 { font-size: 1.32rem; }
  .article-body { padding: 24px 16px 40px; }
  .article-body p { text-align: left; hyphens: none; }
  .article-body h2[id]::before { display: none; }
  .fc-box { min-width: 100px; font-size: 0.7rem; padding: 8px 10px; }
  .article-footer { padding: 0 16px 32px; }
  .article-meta-footer { padding: 16px 18px; }
}

/* Affiliation lines (small italic block under authors) */
.article-affiliations,
.article-authors-affiliations {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-text-light);
  margin: 0 auto 1.5rem;
  max-width: var(--max-width);
  padding: 0 20px;
}

/* Callout title (heading inside an aside.callout) */
.callout-title,
.callout > h2,
.callout > h3 {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary-dark);
  margin: 0 0 .5em;
}

/* ---------- Dark mode tweaks ---------- */
@media (prefers-color-scheme: dark) {
  .article-hero {
    background:
      radial-gradient(1200px 300px at 80% -20%, rgba(232, 121, 43, 0.12), transparent 70%),
      linear-gradient(135deg, #1d2733 0%, #14202c 100%);
    border-bottom-color: var(--color-primary);
  }
  .article-hero h1 { color: #d9e8f3; }
  .section-badge {
    color: #7ec3e6;
    background: rgba(79, 169, 217, 0.14);
  }
  .article-body h2 { color: #7ec3e6; border-bottom-color: var(--color-border); }
  .article-body p.first-para::first-letter { color: #7ec3e6; }
  .callout { background: rgba(79, 169, 217, 0.08); }
  .flowchart { background: #1c2329; border-color: #2c3a44; }
  .fc-box.secondary { background: #1f3849; color: #c9deef; border-color: #2d5871; }
  .fc-box.accent { background: #3a2a18; color: #f3b97a; border-color: #5a3f1f; }
  .fc-box.success { background: #1f3324; color: #a5d6a7; border-color: #2e5234; }
  .table-wrapper table { background: var(--color-surface); }
  .table-wrapper tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
  .table-wrapper tbody tr:hover { background: rgba(79, 169, 217, 0.08); }
  .table-wrapper .row-label { background: #25313b !important; color: #d9e8f3; }
  .article-meta-footer { background: var(--color-surface); }
  .pdf-button--secondary { color: #9bd0ec; border-color: #4fa9d9; }
  .reading-progress::before { background: linear-gradient(90deg, #f3a25b 0%, #e8792b 100%); }
}
