/* ==========================================================================
   The Liberty Articulator - Wagtail / React integration layer - Revision 2
   --------------------------------------------------------------------------
   publication.css owns the site-wide design system and article layout.
   This file adds only integration-specific controls, tools, fallbacks, and
   native/reference edition refinements. Keeping layout ownership in one file
   prevents cascade conflicts.
   ========================================================================== */

:root {
  --line: var(--rule);
  --panel: var(--paper-light);
  --soft: var(--paper-deep);
}

[hidden] { display: none !important; }

/* Controls and forms */
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }

input,
select,
textarea {
  background: var(--paper-light);
  border: 1px solid var(--rule);
  border-radius: 0.12rem;
  box-sizing: border-box;
  color: var(--ink);
  font: inherit;
  max-width: 100%;
  padding: 0.65rem 0.7rem;
  width: 100%;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 2px;
}

input[type='checkbox'],
input[type='radio'] { width: auto; }

.archive-form label,
.react-tool label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
}

.archive-form label > input,
.archive-form label > select,
.react-tool label > input,
.react-tool label > select {
  display: block;
  font-weight: 400;
  margin-top: 0.35rem;
}

.archive-form {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  margin-bottom: 1.5rem;
  padding: 1.5rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1.2rem;
}

.form-grid > div { min-width: 0; }

button,
.pagination a {
  background: var(--oxblood);
  border: 1px solid var(--oxblood);
  border-radius: 0.12rem;
  color: white;
  padding: 0.65rem 1rem;
}

button.secondary,
.pagination a {
  background: var(--paper-light);
  border-color: var(--rule);
  color: var(--ink);
}

/* React tools */
.react-tool { color: var(--ink); }
.react-tool button.source-select,
.react-tool button.timeline-event { color: var(--ink); }

.react-tool a,
.prose a,
.bibliography a,
.footnotes a {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.react-tool .tool-count,
.react-tool small,
.results-summary { color: var(--muted-ink); }

.results-summary { margin: 1.5rem 0; }

.pagination {
  align-items: center;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin: 2rem 0;
}

/* Publication cards and fallbacks */
.publication-card h2 {
  font: 400 clamp(1.7rem, 2.4vw, 2.7rem) / 1.1 Georgia, serif;
  letter-spacing: -0.035em;
  margin: 1.25rem 0 0.9rem;
}

.publication-card details { margin: 1rem 0; }
.publication-card summary { cursor: pointer; text-decoration: underline; }
.publication-card .meta { font-size: 0.1rem; }

.notice,
.missing-artwork,
.missing-asset {
  background: var(--paper-deep);
  border-left: 0.25rem solid var(--gold);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 1rem 1.2rem;
}

.missing-artwork,
.missing-asset {
  color: var(--muted-ink);
  display: grid;
  min-height: 12rem;
  place-content: center;
  text-align: center;
}

.badge {
  border: 1px solid var(--rule);
  display: inline-block;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  text-transform: uppercase;
}

/* Reference edition additions. Article column geometry stays in publication.css. */
.article-record .tool-placeholder {
  border: 1px solid var(--rule);
  padding: 1rem;
}

.article-record .source-tool {
  margin-top: 1.5rem;
  max-height: none;
  overflow: visible;
}

.article-record .source-tool h2 {
  font-size: 1.65rem;
  line-height: 1.1;
}

.article-record .source-tool .source-results { max-height: 24rem; }

.article-record > .article-tools {
  border-top: 0;
  display: block;
  min-width: 0;
  padding: 0;
}

/* Right-sidebar containment. Interactive descendants must honor the width of
   the 20% grid track defined by publication.css instead of contributing an
   intrinsic width that visually pushes the sidebar outward. */
.article-record .article-tools,
.article-record .react-tool,
.article-record .source-tool {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    width: 100%;
}

.article-record .source-results,
.article-record .source-results > *,
.article-record .tool-placeholder {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

.article-record input,
.article-record select,
.article-record textarea,
.article-record button {
  max-width: 100%;
  min-width: 0;
}

/* Native edition */
.native-edition > .page-header,
.native-edition > .prose,
.native-edition > .chronology-shell {
  margin: 0 auto;
  max-width: 85rem;
  padding: 3rem clamp(1.25rem, 4vw, 4.5rem);
}

.native-edition .page-header h1 {
  font: 400 clamp(2.5rem, 5vw, 5rem) / 1 Georgia, serif;
  letter-spacing: -0.04em;
}

.native-edition .page-header .lead {
  color: var(--muted-ink);
  font: 1.15rem / 1.6 Georgia, serif;
  max-width: 55rem;
}

.native-edition .article-tools { min-width: 0; }
.native-edition .article-header .abstract { margin: 1.5rem 0; font: 1.15rem / 1.8 Georgia, serif; }

/* Server-rendered rich text */
.prose { font: 1.1rem / 1.85 Georgia, serif; }
.prose h2,
.prose h3,
.prose h4 { line-height: 1.2; margin: 2rem 0 1rem; }
.prose p { margin: 1rem 0; }
.prose ul,
.prose ol { padding-left: 1.65rem; }
.prose li { margin: 0.55rem 0; }
.prose figure { margin: 2rem 0; }
.prose figcaption { color: var(--muted-ink); font: 0.8rem / 1.6 system-ui, sans-serif; }

.footnotes,
.bibliography {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1.5rem;
}

.footnotes li,
.bibliography li {
  margin: 1rem 0;
  padding-left: 0.4rem;
}

/* Archive, chronology, and research utilities */
.article-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-card { border-top: 1px solid var(--rule); padding-top: 1rem; }
.research-tool-nav { border-top: 1px solid #4f514b; font-size: 1.2rem; margin-top: 1rem; padding-top: 1rem; }
.research-tool-nav a { text-decoration: underline; }
.byline { display: flex; flex-wrap: wrap; font-size: 1.2rem; gap: 0.7rem 1.5rem; }
.timeline-linear,
.linear-timeline { padding-left: 1.5rem; }
.timeline-linear > li,
.linear-timeline > li { border-top: 1px solid var(--rule); margin: 2rem 0; padding-top: 1rem; }

.reading-width,
#chronology-island {
  margin: 0 auto;
  max-width: 85rem;
  padding: 2rem clamp(1.25rem, 4vw, 4.5rem);
}

/* Preserve uploaded artwork proportions at every reading width. */
.article-figure img { height: auto; }

@media (max-width: 800px) {
  .form-grid,
  .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .source-results,
  .source-tool { max-height: none; }
}

@media (max-width: 560px) {
  .form-grid,
  .article-grid { grid-template-columns: 1fr; }

  .pagination { flex-wrap: wrap; gap: 0.75rem; }
  input,
  select,
  textarea { font-size: 1rem; }

  .mobile-nav summary .ui-symbol {
    display: inline;
    font-size: 1.3rem;
  }
}

@media print {
  body::before,
  .site-header,
  .site-footer,
  .credibility-bar,
  .article-tools,
  .article-record,
  .archive-form,
  .react-tool,
  .pagination,
  .skip-link {
    display: none !important;
  }

  body { background: white; color: black; }

  .article-layout,
  .article-record .article-layout,
  .native-edition .article-layout {
    display: block;
    padding: 0;
  }

  .article-toc { position: static; }
  .article-body { border: 0; padding: 0; }
  #archive-fallback,
  #chronology-fallback { display: block !important; }
  .publication-card,
  .article-notes li { break-inside: avoid; }
}
