/* Public paper page controls: zoom bar, long-text panels and language bar.
 * Loaded after style.css, paper_view_overrides.css and academic.css; uses the
 * visual identity tokens from docs/visual-identity.md. */
:root {
  --scieee-discovery-blue: #016dc6;
  --scieee-science-green: #70cd31;
  --scieee-deep-navy: #173b75;
  --scieee-soft-blue: #3a78bc;
  --scieee-cloud: #f5f9fd;
  --scieee-mist: #e8f1f7;
  --scieee-slate: #6d859c;
  --scieee-white: #ffffff;
  --paper-focus-ring: 0 0 0 3px rgba(1, 109, 198, .28);
}

/* Floating, movable zoom bar. It is fixed over the document viewer and no
 * longer reserves an empty row above the first page. */
body.paper-page .scieee-doc-zoom-toolbar {
  position: fixed;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--scieee-mist);
  border-radius: 10px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 2px 10px rgba(23, 59, 117, .10);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body.paper-page .scieee-doc-zoom-toolbar.is-floating-hidden {
  visibility: hidden;
}

body.paper-page .scieee-doc-zoom-toolbar[hidden] {
  display: none;
}

body.paper-page .scieee-doc-zoom-toolbar.is-dragging {
  box-shadow: 0 6px 18px rgba(23, 59, 117, .18);
}

body.paper-page .scieee-doc-zoom-toolbar button {
  min-width: 32px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--scieee-mist);
  border-radius: 7px;
  background: var(--scieee-white);
  color: var(--scieee-deep-navy);
  font: 600 12px/1.1 Inter, ui-sans-serif, system-ui, sans-serif;
  box-shadow: none;
  cursor: pointer;
}

body.paper-page .scieee-doc-zoom-toolbar button:hover:not(:disabled) {
  border-color: var(--scieee-soft-blue);
  background: var(--scieee-cloud);
}

body.paper-page .scieee-doc-zoom-toolbar button:focus-visible {
  outline: none;
  box-shadow: var(--paper-focus-ring);
}

body.paper-page .scieee-doc-zoom-toolbar button:disabled {
  opacity: .45;
  cursor: default;
}

body.paper-page .scieee-doc-zoom-toolbar .scieee-doc-zoom-grip {
  min-width: 22px;
  padding: 4px 5px;
  border-color: transparent;
  background: transparent;
  color: var(--scieee-slate);
  cursor: grab;
  touch-action: none;
}

body.paper-page .scieee-doc-zoom-toolbar .scieee-doc-zoom-grip svg {
  display: block;
  fill: currentColor;
}

body.paper-page .scieee-doc-zoom-toolbar.is-dragging,
body.paper-page .scieee-doc-zoom-toolbar.is-dragging .scieee-doc-zoom-grip {
  cursor: grabbing;
}

/* Document metadata panel: a long-text section with "Show more" / "Show
 * less". The collapsed body fades out instead of being covered by an overlay;
 * the toggle stays in normal flow, so expanding never overlaps the text, and
 * the side column (not the panel) scrolls when the expanded text is long. */
body.public-page.paper-page .paper-ad {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

body.paper-page .paper-right-meta-panel {
  position: relative;
  max-height: none;
  overflow: visible;
  background: var(--scieee-white);
}

body.paper-page .right-doc-title {
  margin: 0 0 12px;
  color: var(--scieee-deep-navy);
  font-family: Lora, Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

body.paper-page .right-doc-meta {
  display: grid;
  gap: 8px;
  color: var(--scieee-deep-navy);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

body.paper-page .right-doc-meta b {
  color: var(--scieee-slate);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.long-text-body {
  --long-text-collapsed-height: 15rem;
  --long-text-fade: 3.5rem;
}

.long-text:not(.is-expanded):not(.is-short) .long-text-body {
  max-height: var(--long-text-collapsed-height);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--long-text-fade)), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--long-text-fade)), transparent);
}

.public-page .long-text-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--scieee-discovery-blue);
  font: 600 13px/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
  box-shadow: none;
  cursor: pointer;
}

.public-page .long-text-toggle:hover {
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.long-text-toggle:focus-visible {
  outline: none;
  box-shadow: var(--paper-focus-ring);
}

.long-text-toggle[hidden] {
  display: none;
}

.long-text-chevron {
  flex: 0 0 auto;
  transition: transform .15s ease;
}

.long-text.is-expanded .long-text-chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .long-text-chevron {
    transition: none;
  }
}

/* In-place language switch: the document region dims while the selected
 * language loads; the rest of the page stays as it is. */
body.paper-page .paper-document {
  transition: opacity .15s ease;
}

body.paper-page .paper-main.is-switching-language .paper-document {
  opacity: .45;
  pointer-events: none;
}

/* A pill over the dimmed document; the negative margin cancels its height so
 * showing it never moves the document. */
body.paper-page .paper-switch-status {
  position: sticky;
  top: 56px;
  z-index: 36;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: max-content;
  height: 36px;
  margin: 0 auto -36px;
  padding: 0 14px;
  border: 1px solid var(--scieee-mist);
  border-radius: 999px;
  background: var(--scieee-white);
  box-shadow: 0 4px 14px rgba(23, 59, 117, .10);
  color: var(--scieee-deep-navy);
  font-size: 13px;
  font-weight: 600;
}

body.paper-page .paper-switch-status[hidden] {
  display: none;
}

body.paper-page .paper-switch-status .scieee-loading-spinner {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  border-width: 2px;
  border-top-color: var(--scieee-discovery-blue);
}

@media (prefers-reduced-motion: reduce) {
  body.paper-page .paper-document {
    transition: none;
  }
}

/* Language bar: languages that can be read now are pills; languages without
 * a published translation sit behind "Other languages". */
body.paper-page .language-topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  width: auto;
  max-width: 1840px;
  margin: 0 auto;
  padding: 7px 14px;
  overflow: visible;
  border: 0;
  background: transparent;
}

body.paper-page .language-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

body.paper-page .language-group-label {
  margin-right: 2px;
  color: var(--scieee-slate);
  font-size: 12px;
  font-weight: 500;
}

body.paper-page .lang-pill.lang-pill--available {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 6px 11px;
  border: 1px solid var(--scieee-mist);
  border-radius: 999px;
  background: var(--scieee-white);
  color: var(--scieee-deep-navy);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-transform: none;
  text-decoration: none;
}

body.paper-page .lang-pill.lang-pill--available:hover {
  border-color: var(--scieee-soft-blue);
  background: var(--scieee-cloud);
}

body.paper-page .lang-pill.lang-pill--available.active {
  border-color: var(--scieee-discovery-blue);
  background: var(--scieee-discovery-blue);
  color: var(--scieee-white);
}

body.paper-page .lang-pill.lang-pill--available:focus-visible,
body.paper-page .language-more-toggle:focus-visible,
body.paper-page .language-option-action:focus-visible {
  outline: none;
  box-shadow: var(--paper-focus-ring);
}

body.paper-page .lang-pill .lang-origin {
  font-size: 10px;
  font-weight: 500;
  opacity: .8;
}

body.paper-page .language-more {
  position: relative;
  padding-left: 12px;
  border-left: 1px solid var(--scieee-mist);
}

body.paper-page .language-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--scieee-slate);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

body.paper-page .language-more-toggle::-webkit-details-marker {
  display: none;
}

body.paper-page .language-more-toggle:hover,
body.paper-page .language-more[open] .language-more-toggle {
  border-color: var(--scieee-mist);
  background: var(--scieee-cloud);
  color: var(--scieee-deep-navy);
}

body.paper-page .language-more-count {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--scieee-mist);
  color: var(--scieee-deep-navy);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

body.paper-page .language-more-chevron {
  transition: transform .15s ease;
}

body.paper-page .language-more[open] .language-more-chevron {
  transform: rotate(180deg);
}

body.paper-page .language-more-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 45;
  width: min(320px, calc(100vw - 32px));
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--scieee-mist);
  border-radius: 12px;
  background: var(--scieee-white);
  box-shadow: 0 8px 24px rgba(23, 59, 117, .12);
  text-align: left;
}

body.paper-page .language-more-note {
  margin: 0 0 6px;
  color: var(--scieee-slate);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

body.paper-page .language-more-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

body.paper-page .language-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 4px 0;
  border-bottom: 1px solid var(--scieee-mist);
}

body.paper-page .language-option:last-child {
  border-bottom: 0;
}

body.paper-page .language-option-name {
  color: var(--scieee-deep-navy);
  font-size: 13px;
}

body.paper-page .language-option-code {
  color: var(--scieee-slate);
  font-size: 11px;
  font-weight: 600;
}

body.paper-page .language-option-action {
  min-width: 92px;
  padding: 4px 10px;
  border: 1px solid var(--scieee-discovery-blue);
  border-radius: 999px;
  background: var(--scieee-white);
  color: var(--scieee-discovery-blue);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: none;
  cursor: pointer;
}

body.paper-page .language-option-action [data-translation-status] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

body.paper-page .language-option-action:hover:not(:disabled) {
  background: var(--scieee-cloud);
}

body.paper-page .language-option-action:disabled {
  border-color: var(--scieee-mist);
  background: var(--scieee-white);
  color: var(--scieee-slate);
  cursor: default;
}

body.paper-page .language-option-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  color: var(--scieee-slate);
  font-size: 12px;
}

body.paper-page .language-option .language-progress {
  margin-left: 0;
  color: var(--scieee-soft-blue);
  opacity: 1;
}

/* Narrow screens: the disclosure panel spans the bar instead of hanging off
 * a control that may sit at either edge. */
@media (max-width: 760px) {
  body.paper-page .language-topbar-inner {
    justify-content: flex-start;
  }

  body.paper-page .language-group-label {
    display: none;
  }

  body.paper-page .language-more {
    position: static;
    padding-left: 0;
    border-left: 0;
  }

  body.paper-page .language-more-panel {
    right: 16px;
    left: 16px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.paper-page .language-more-chevron {
    transition: none;
  }
}
