/* ============================================================
   Ticinus — visual identity
   A research publication: petrol-blue ink on warm paper,
   Source Serif 4 (self-hosted, variable) for display and
   long-form reading, system sans for UI chrome. Editorial
   index rows instead of card grids; one committed ink band.
   ============================================================ */

@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-italic-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: oklch(0.38 0.055 220);
  --ink-deep: oklch(0.30 0.05 222);
  --ink-soft: oklch(0.52 0.04 220);
  --paper: oklch(0.978 0.006 90);
  --paper-2: oklch(0.945 0.009 90);
  --hairline: oklch(0.885 0.012 90);
  --accent: oklch(0.55 0.07 220);
  --text: oklch(0.32 0.02 230);
  --max: 1100px;
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* short pages: keep the footer anchored to the bottom */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body > main { flex: 1 0 auto; width: 100%; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--ink); text-decoration-color: color-mix(in oklch, var(--ink) 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

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

h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink-deep); font-weight: 600; line-height: 1.22; text-wrap: balance; }

::selection { background: color-mix(in oklch, var(--ink) 18%, transparent); }

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

.site-header {
  background: color-mix(in oklch, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
}

.header-inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 68px;
}

.brand {
  display: flex; align-items: baseline; gap: .6rem;
  text-decoration: none; color: var(--ink-deep);
  margin-right: auto;
}
.brand-mark { align-self: center; }
.brand-word {
  font-family: var(--serif);
  font-size: 1.45rem; letter-spacing: .32em; font-weight: 600;
}
.brand-sub {
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft);
}

.site-nav ul {
  display: flex; align-items: center; gap: 1.15rem;
  list-style: none; margin: 0; padding: 0;
}
.site-nav a {
  text-decoration: none; font-size: .95rem; color: var(--ink-soft);
  padding: .35rem 0; border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink-deep); }
.site-nav a.active { border-bottom-color: var(--accent); color: var(--ink-deep); }
.nav-toggle { display: none; }
.nav-search a { font-size: 1.15rem; }

.lang-switch { display: flex; gap: .15rem; }
.lang {
  font-size: .78rem; letter-spacing: .05em; text-decoration: none;
  padding: .25rem .4rem; border-radius: 3px; color: var(--ink-soft);
}
.lang.on { background: var(--ink); color: var(--paper); }
.lang:not(.on):hover { background: var(--paper-2); }

/* ---------- hero ---------- */

.hero { text-align: center; padding: clamp(2.5rem, 6vw, 4.5rem) 0 1.5rem; }
.hero-logo { max-width: min(400px, 72vw); height: auto; }
.hero-intro {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.6vw, 1.8rem);
  font-weight: 400;
  color: var(--ink);
  max-width: 42rem; margin: 1.25rem auto 0;
  line-height: 1.4;
  text-wrap: balance;
}
.hero-body { max-width: 42rem; margin: 1rem auto 0; color: var(--ink-soft); }
.hero-body p { margin: .6em 0; }
.hero-wave { color: var(--accent); opacity: .55; margin-top: 2.25rem; }
.wave { width: 160px; height: 12px; }

/* ---------- lead article (featured) ---------- */

.lead {
  border-block: 1px solid var(--hairline);
  padding: clamp(1.5rem, 3vw, 2.5rem) 0;
  margin-top: 2rem;
  display: grid; gap: 1.25rem 3rem;
  grid-template-columns: 1fr;
}
.lead.has-cover { grid-template-columns: 3fr 2fr; align-items: center; }
.lead-meta { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 .5rem; }
.lead h2 {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  margin: 0 0 .6rem; letter-spacing: -0.01em;
}
.lead h2 a { text-decoration: none; }
.lead h2 a:hover { color: var(--accent); }
.lead-summary { font-family: var(--serif); font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 1rem; max-width: 62ch; }
.lead-more { font-size: .92rem; text-decoration: none; color: var(--accent); }
.lead-cover img { width: 100%; border-radius: 4px; display: block; }

/* ---------- editorial index rows ---------- */

.section-title {
  font-size: 1.05rem;
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-soft);
  margin: 3rem 0 .5rem;
}

.index-list { list-style: none; margin: 0; padding: 0; }
.index-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 1.5rem; align-items: baseline;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--hairline);
}
.index-date {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-soft); white-space: nowrap;
}
.index-main h3 {
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  margin: 0 0 .25rem; font-weight: 600;
}
.index-main h3 a { text-decoration: none; }
.index-main h3 a:hover { color: var(--accent); }
.index-summary { margin: 0; font-size: .95rem; color: var(--ink-soft); max-width: 68ch; }
.index-tags { margin: .35rem 0 0; font-size: .8rem; }
.index-tags a { color: var(--ink-soft); text-decoration: none; margin-right: .6rem; }
.index-tags a:hover { color: var(--accent); }
.lang-badge {
  font-size: .72rem; letter-spacing: .1em; color: var(--accent);
  border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent);
  padding: .1rem .45rem; border-radius: 999px; white-space: nowrap;
}

.more-link { text-align: right; margin: 1rem 0 0; }
.more-link a { font-size: .95rem; }

/* ---------- ink band: thematic areas ---------- */

.band {
  background: var(--ink-deep);
  color: oklch(0.88 0.015 210);
  margin: 3.5rem calc(50% - 50vw) 0;
  padding: clamp(2.5rem, 5vw, 4rem) calc(50vw - 50%);
}
.band .section-title { color: oklch(0.72 0.03 215); margin-top: 0; }
.band-list {
  list-style: none; margin: 1.5rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .75rem 2.5rem;
}
.band-list a {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  color: oklch(0.93 0.01 210);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklch, currentColor 30%, transparent);
  padding-bottom: .15rem;
}
.band-list a:hover { color: #fff; border-bottom-color: currentColor; }
.band .wave { color: oklch(0.6 0.05 215); }

/* ---------- article list page ---------- */

.page-head { padding: clamp(2rem, 4vw, 3rem) 0 1rem; }
.page-head h1 { margin: 0 0 .75rem; font-size: clamp(1.8rem, 3.5vw, 2.4rem); letter-spacing: -0.01em; }
.page-head .wave { color: var(--accent); opacity: .55; }
.page-intro {
  font-family: var(--serif); font-size: clamp(1.15rem, 2vw, 1.35rem);
  color: var(--ink); max-width: 46rem;
}

.list-layout { display: grid; grid-template-columns: 1fr 250px; gap: 3.5rem; margin-bottom: 3rem; }
.sidebar h2 {
  font-family: var(--sans); font-size: .85rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft);
}
.cat-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.cat-list li { border-bottom: 1px solid var(--hairline); }
.cat-list a { display: block; padding: .5rem 0; text-decoration: none; font-size: .95rem; }
.cat-list a.active { color: var(--accent); font-weight: 600; }

.search-box { display: flex; gap: .4rem; }
.search-box input {
  flex: 1; padding: .5rem .75rem; border: 1px solid var(--hairline); border-radius: 4px;
  font: inherit; background: #fff; color: inherit; min-width: 0;
}
.search-box button {
  padding: .5rem .9rem; border: none; border-radius: 4px;
  background: var(--ink); color: var(--paper); font: inherit; cursor: pointer;
}
.search-box button:hover { background: var(--ink-deep); }
.search-box.big { max-width: 560px; margin: 1rem 0 2rem; }

/* ---------- article ---------- */

.article { max-width: 44rem; margin: 0 auto 4rem; }
.article-head { padding-top: clamp(2rem, 4vw, 3rem); }
.article-head h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: .5rem 0; letter-spacing: -0.012em; }
.article-summary {
  font-family: var(--serif); font-size: 1.3rem; font-weight: 400;
  color: var(--ink-soft); line-height: 1.45;
  white-space: pre-line; /* editors separate paragraphs with blank lines */
}
.article-langs { font-size: .9rem; color: var(--ink-soft); }
.article-head .wave { color: var(--accent); opacity: .55; margin-top: 1rem; }
.article-cover { width: 100%; border-radius: 6px; margin: 1.5rem 0; }
.article-source { font-size: .9rem; color: var(--ink-soft); word-break: break-all; }

.prose {
  font-family: var(--serif);
  font-size: 1.14rem; line-height: 1.72;
  color: var(--text);
  max-width: 68ch;
}
.prose p { margin: 1.1em 0; }
.prose h2, .prose h3 { margin-top: 1.7em; }
.prose img, .prose iframe { max-width: 100%; border-radius: 4px; }
.prose blockquote {
  margin: 1.5em 0; padding: 0 0 0 1.4em;
  border-left: 1px solid var(--accent);
  color: var(--ink); font-style: italic; font-size: 1.05em;
}
.prose ul, .prose ol { padding-left: 1.4em; }

.article-foot { border-top: 1px solid var(--hairline); margin-top: 2.5rem; padding-top: 1.25rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .5rem; }
.tag {
  font-size: .82rem; text-decoration: none; padding: .2rem .65rem;
  background: var(--paper-2); border-radius: 999px; color: var(--ink-soft);
}
.tag:hover { color: var(--ink); }
.share { display: flex; gap: .9rem; align-items: center; font-size: .9rem; margin-top: 1rem; }
.share span { color: var(--ink-soft); }

/* ---------- notices ---------- */

.notice {
  background: oklch(0.96 0.025 90); border: 1px solid oklch(0.85 0.06 85);
  color: oklch(0.42 0.08 80);
  padding: .7rem 1rem; border-radius: 4px; margin: 1.5rem 0 0; font-size: .95rem;
}
.notice.ok { background: oklch(0.96 0.02 150); border-color: oklch(0.82 0.06 150); color: oklch(0.38 0.09 150); }
.notice.err { background: oklch(0.96 0.02 25); border-color: oklch(0.84 0.06 25); color: oklch(0.42 0.12 25); }

/* ---------- press ---------- */

.press-list { list-style: none; padding: 0; margin: 0 0 3rem; max-width: 46rem; }
.press-item { border-bottom: 1px solid var(--hairline); padding: 1.25rem 0; }
.press-item h3 { margin: .25rem 0; font-size: 1.15rem; }
.press-meta { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0; }

/* ---------- contact ---------- */

.contact-form { max-width: 34rem; margin: 1.5rem 0 4rem; display: grid; gap: 1rem; }
.contact-form label { display: grid; gap: .35rem; font-size: .92rem; color: var(--ink-soft); }
.contact-form input, .contact-form textarea {
  padding: .6rem .8rem; border: 1px solid var(--hairline); border-radius: 4px;
  font: inherit; background: #fff; color: inherit;
}
.contact-form button {
  justify-self: start; padding: .65rem 1.6rem; border: none; border-radius: 4px;
  background: var(--ink); color: var(--paper); font: inherit; cursor: pointer;
}
.contact-form button:hover { background: var(--ink-deep); }
.hp { position: absolute; left: -9999px; height: 0; width: 0; opacity: 0; }

/* ---------- footer ---------- */

.site-footer {
  background: var(--ink-deep); color: oklch(0.85 0.015 210); margin-top: 4rem;
  font-size: .9rem;
}
main:has(.band:last-child) + .site-footer { margin-top: 0; border-top: 1px solid oklch(0.4 0.04 220); }
.footer-inner { padding: 2.25rem 1.25rem; display: grid; gap: 1.25rem; }
.footer-brand { display: flex; gap: .8rem; align-items: center; }
.footer-brand img { filter: brightness(0) invert(.92); }
.footer-brand p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.site-footer a { color: oklch(0.93 0.01 210); text-decoration-color: color-mix(in oklch, currentColor 40%, transparent); }
.site-footer a:hover { color: #fff; }
.footer-credit { margin: 0; color: oklch(0.68 0.025 215); font-size: .82rem; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .hero-logo, .hero-intro, .hero-body, .hero-wave {
    animation: rise .7s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .hero-intro { animation-delay: .08s; }
  .hero-body { animation-delay: .16s; }
  .hero-wave { animation-delay: .24s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .list-layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
  .lead.has-cover { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .header-inner { flex-wrap: wrap; padding: .6rem 1.25rem; gap: .75rem; }
  .brand-sub { display: none; }
  .nav-toggle {
    display: block; background: none; border: 1px solid var(--hairline);
    border-radius: 4px; font-size: 1.1rem; padding: .2rem .55rem; cursor: pointer;
    color: var(--ink);
  }
  .site-nav { order: 3; width: 100%; }
  .site-nav ul {
    display: none; flex-direction: column; align-items: stretch; gap: 0;
    border-top: 1px solid var(--hairline); padding-top: .5rem;
  }
  .site-nav.open ul { display: flex; }
  .site-nav a { display: block; padding: .6rem 0; }
  .lang-switch { margin-left: auto; }

  .index-row { grid-template-columns: 1fr; gap: .2rem; }
  .index-date { order: -1; }
  .index-row .article-pills.list { justify-self: start; margin-top: .35rem; }
}

/* ---------- print ---------- */

@media print {
  .site-header, .site-footer, .share, .band, .search-box { display: none; }
  body { background: #fff; }
}

/* ---------- document (PDF) box ---------- */

.doc-box {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 68ch;
  margin: 2rem 0 0;
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.02rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc-box:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(20, 53, 67, 0.08);
  color: var(--ink-deep);
}

.doc-box svg { flex: none; color: var(--accent); }

/* ---------- pdf.js viewer (embedded on PDF-only articles) ---------- */

.pdf-viewer.full { margin: 1.75rem 0 0; }

.pdfjs-viewer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper-2);
  overflow: hidden;
  min-height: 220px;
  position: relative;
}

.pdfjs-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  background: #fff;
  border-bottom: 1px solid var(--hairline);
  font-size: .85rem;
}

.pdfjs-toolbar button {
  width: 28px; height: 26px;
  border: 1px solid var(--hairline); border-radius: 4px;
  background: #fff; color: var(--ink);
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.pdfjs-toolbar button:hover { border-color: var(--accent); color: var(--ink-deep); }
.pdfjs-pageinfo { color: var(--ink-soft); }
.pdfjs-spacer { flex: 1; }
.pdfjs-download { font-size: .85rem; color: var(--ink); }

.pdfjs-pages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  height: min(75vh, 950px);
}

.pdfjs-ph, .pdfjs-page {
  background: #fff;
  box-shadow: 0 1px 6px rgba(20, 53, 67, 0.15);
  flex: none;
}

.pdfjs-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.pdfjs-loading span {
  width: 28px; height: 28px;
  border: 3px solid var(--hairline); border-top-color: var(--accent);
  border-radius: 50%;
  animation: pdfspin 0.9s linear infinite;
}
@keyframes pdfspin { to { transform: rotate(360deg); } }

.pdfjs-viewer .viewer-fallback { display: none; padding: 2rem; text-align: center; }
.pdfjs-viewer.pdfjs-error .viewer-fallback { display: block; }

.article-document .article-head { padding-top: clamp(1.5rem, 3vw, 2.25rem); }
.article-document .article-head h1 { margin-bottom: 0; }
.article-document .pdf-viewer.full { margin-top: 1.25rem; }

/* ---------- per-article language pills ---------- */

.article-pills {
  display: flex;
  gap: .35rem;
  margin: .6rem 0 0;
}

.article-pill {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  padding: .18rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  text-decoration: none;
  background: #fff;
}

.article-pill:hover { border-color: var(--accent); color: var(--ink-deep); }
.article-pill.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* pills inside listings */
.article-pills.list { display: inline-flex; gap: .3rem; margin: 0; vertical-align: middle; }
.index-row .article-pills.list { justify-self: end; }
.lead-meta .article-pills.list { margin-left: .6rem; }

/* listings: clamp long summaries (Niccolò writes generous ones) */
.lead-summary {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.index-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 760px) {
  .pdfjs-toolbar { gap: .4rem; padding: .45rem .55rem; font-size: .8rem; }
  .pdfjs-pageinfo { white-space: nowrap; }
  .pdfjs-download { white-space: nowrap; }
  .pdfjs-pages { height: min(70dvh, 820px); }
}

.pdfjs-download .dl-short { display: none; }

@media (max-width: 480px) {
  .pdfjs-download .dl-full { display: none; }
  .pdfjs-download .dl-short { display: inline; }
}

/* phone archive: filters compress into chips instead of a full-height list */
@media (max-width: 900px) {
  .list-layout { gap: 1.5rem; }
  .sidebar h2 { margin: 0 0 .6rem; }
  .cat-list { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1rem; }
  .cat-list li { border-bottom: 0; }
  .cat-list a {
    display: inline-block; padding: .3rem .75rem;
    border: 1px solid var(--hairline); border-radius: 999px;
    font-size: .85rem; background: #fff;
  }
  .cat-list a.active { border-color: var(--accent); background: var(--accent); color: var(--paper); font-weight: 500; }
  .sidebar .search-box { margin-bottom: .5rem; }
}

/* iOS: inputs below 16px trigger focus auto-zoom */
@media (max-width: 760px) {
  input, textarea, select { font-size: 16px; }
}

/* ---------- PDF viewer fullscreen ---------- */

.pdfjs-toolbar .pdfjs-fs-btn { display: inline-flex; align-items: center; justify-content: center; }

.pdfjs-viewer:fullscreen {
  background: var(--paper-2);
  border-radius: 0;
}
.pdfjs-viewer:fullscreen .pdfjs-pages { height: calc(100dvh - 42px); }

/* Overlay fallback for browsers without element fullscreen (iOS Safari) */
.pdfjs-viewer.pdfjs-fs {
  position: fixed;
  inset: 0;
  z-index: 300;
  border-radius: 0;
  border: none;
}
.pdfjs-viewer.pdfjs-fs .pdfjs-pages { height: calc(100dvh - 42px); }
html.pdfjs-noscroll, html.pdfjs-noscroll body { overflow: hidden; }

/* ---------- press review: link back to the analysis ---------- */

.press-related { margin: .2rem 0 0; font-size: .9rem; }

/* source line on document-only analyses */
.article-document .article-source { margin: .25rem 0 1rem; }
