/* =========================================================
   Rivista SIMG — Common stylesheet
   Shared tokens, reset, typography base, header, footer, utils
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@400;500;600;700&display=swap");

/* ---------- Design tokens ---------- */
:root {
  /* Color palette */
  --color-primary: #1a7fb5;
  --color-primary-dark: #0d5f8a;
  --color-primary-deep: #1b3a5c;
  --color-accent: #e8792b;
  --color-accent-dark: #c45f15;
  --color-bg: #fafaf8;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f0ec;
  --color-text: #2c2c2c;
  --color-text-light: #5a5a5a;
  --color-text-muted: #888888;
  --color-border: #e0ddd8;
  --color-border-soft: #ebe9e4;

  /* Layout */
  --max-width: 780px;
  --max-width-wide: 1080px;

  /* Typography */
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 30, 45, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 30, 45, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 30, 45, 0.12);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --t-fast: 140ms;
  --t-med: 240ms;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;
}

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 90px; /* space for sticky header + breadcrumb */
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--t-fast) var(--ease);
}
a:hover {
  color: var(--color-primary-dark);
}
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection {
  background: rgba(232, 121, 43, 0.25);
  color: var(--color-text);
}

/* ---------- Site header ---------- */
.site-header {
  background: linear-gradient(135deg, #1b3a5c 0%, #1a7fb5 100%);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.site-header a.site-header-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}
.site-header a.site-header-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.site-header img {
  height: 46px;
  width: auto;
  border-radius: 100px;
  background: white;
  padding: 2px;
}

.site-header-text {
  font-family: var(--font-ui);
  min-width: 0;
}
.site-header-text .journal-name {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.85;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-header-text .issue {
  font-size: 0.95rem;
  font-weight: 600;
  display: block;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  padding: 10px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 74px;
  z-index: 90;
}
.breadcrumb-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.breadcrumb a {
  color: var(--color-text-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t-fast) var(--ease);
}
.breadcrumb a:hover {
  color: var(--color-primary);
}
.breadcrumb a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Copyright bar ---------- */
.copyright-bar {
  text-align: center;
  padding: 22px 20px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.copyright-bar a {
  color: var(--color-text-light);
  text-decoration: none;
}
.copyright-bar a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ---------- Utilities ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}
.container-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.muted { color: var(--color-text-light); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .site-header { padding: 12px 14px; gap: 10px; }
  .site-header img { height: 36px; }
  .site-header-text .journal-name { font-size: 0.65rem; }
  .site-header-text .issue { font-size: 0.85rem; }
  .breadcrumb { top: 62px; padding: 8px 14px; font-size: 0.78rem; }
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .breadcrumb,
  .reading-progress,
  .pdf-button { display: none !important; }
  body { background: white; color: black; }
}

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

/* ---------- Dark mode (tasteful) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #161719;
    --color-surface: #1f2125;
    --color-surface-alt: #25282d;
    --color-text: #e8e8e8;
    --color-text-light: #b5b5b5;
    --color-text-muted: #8a8a8a;
    --color-border: #2e3137;
    --color-border-soft: #262930;
    --color-primary: #4fa9d9;
    --color-primary-dark: #6db9e0;
    --color-primary-deep: #c9deef;
  }
  .site-header {
    background: linear-gradient(135deg, #0a1a2a 0%, #0d3d5c 100%);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
  }
  ::selection { background: rgba(232, 121, 43, 0.4); color: #fff; }
}
