/* I4 public judgment reader. Opt-in only: the surface class is the sole scope. */
.judgment-surface {
  --judgment-paper: var(--sheet, #fbf9f2);
  --judgment-ground: #f0ece2;
  --judgment-ink: var(--ink, #252c2b);
  --judgment-muted: var(--ink-soft, #62665f);
  --judgment-rule: var(--line, #d6cdbf);
  --judgment-accent: var(--brick, #8b392e);
  --judgment-accent-deep: var(--brick-deep, #672d26);
  --judgment-focus: var(--gold, #c59643);
  --judgment-editorial: var(--serif, Georgia, serif);
  --judgment-ui: var(--sans, sans-serif);
  --judgment-apparatus: var(--sans, sans-serif);

  box-sizing: border-box;
  color: var(--judgment-ink);
  font-family: var(--judgment-ui);
  min-width: 0;
}

.judgment-surface *,
.judgment-surface *::before,
.judgment-surface *::after {
  box-sizing: border-box;
}

.judgment-surface[hidden],
.judgment-surface [hidden] {
  display: none !important;
}

dialog.judgment-surface {
  width: min(1040px, calc(100vw - 48px));
  max-width: none;
  height: min(860px, calc(100dvh - 48px));
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #bdb29e;
  background: var(--judgment-paper);
  box-shadow: 0 22px 80px rgb(37 44 43 / 24%);
}

dialog.judgment-surface::backdrop {
  background: rgb(31 34 32 / 58%);
  backdrop-filter: blur(2px);
}

section.judgment-surface.is-standalone {
  width: min(1040px, calc(100% - 48px));
  min-height: min(720px, calc(100dvh - 48px));
  margin: 24px auto;
  border: 1px solid var(--judgment-rule);
  background: var(--judgment-paper);
  box-shadow: 0 8px 32px rgb(53 47 36 / 9%);
}

.judgment-surface .judgment-header {
  position: relative;
  padding: 24px clamp(20px, 4vw, 48px) 17px;
  border-bottom: 1px solid var(--judgment-rule);
  background: linear-gradient(110deg, #f3efe5, #f8f1e3);
}

.judgment-surface .judgment-header :is(h1, h2) {
  margin: 0;
  padding-right: 58px;
  color: var(--judgment-ink);
  font: 700 clamp(27px, 3.3vw, 38px)/1.08 var(--judgment-editorial);
  letter-spacing: -.045em;
}

.judgment-surface .judgment-identity {
  max-width: 78ch;
  margin-top: 8px;
  color: var(--judgment-muted);
  font: 12px/1.55 var(--judgment-ui);
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-close {
  position: absolute;
  top: 17px;
  right: clamp(16px, 3vw, 34px);
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid #bdb29e;
  border-radius: 0;
  background: var(--judgment-paper);
  color: var(--judgment-accent-deep);
  cursor: pointer;
  font: 600 10px/1.3 var(--judgment-apparatus);
  letter-spacing: .045em;
}

.judgment-surface .judgment-close::before {
  content: "×";
  font: 400 20px/1 var(--judgment-ui);
}

.judgment-surface .judgment-close:hover {
  background: #eee4d2;
  border-color: var(--judgment-accent);
}

.judgment-surface .judgment-toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--judgment-rule);
  background: var(--judgment-paper);
}

.judgment-surface .judgment-views {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.judgment-surface .judgment-views button,
.judgment-surface .judgment-external {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--judgment-muted);
  cursor: pointer;
  font: 600 10px/1.4 var(--judgment-apparatus);
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-views button:hover,
.judgment-surface .judgment-external:hover {
  color: var(--judgment-accent-deep);
  background: #f4efe4;
}

.judgment-surface .judgment-views button[aria-pressed="true"] {
  border-color: #bfb39e;
  border-bottom: 2px solid var(--judgment-accent);
  background: #f4efe4;
  color: var(--judgment-accent-deep);
}

.judgment-surface .judgment-external {
  flex: 0 1 auto;
  border-color: var(--judgment-rule);
  color: var(--judgment-accent-deep);
}

.judgment-surface .judgment-external::after {
  content: "↗";
  margin-left: 8px;
  font: 12px/1 var(--judgment-ui);
}

.judgment-surface .judgment-status {
  min-height: 0;
  margin: 0;
  padding: 0 clamp(20px, 4vw, 48px);
  color: var(--judgment-muted);
  font: 11px/1.5 var(--judgment-ui);
}

.judgment-surface .judgment-status:not(:empty) {
  padding-top: 9px;
}

.judgment-surface .judgment-reading {
  min-width: 0;
  height: calc(100% - 151px);
  min-height: 300px;
  padding: 20px clamp(20px, 4vw, 48px) 36px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #b7aa94 transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.judgment-surface .judgment-explanation {
  max-width: 76ch;
  margin: 0 0 20px;
  padding: 11px 14px;
  border-left: 2px solid var(--judgment-focus);
  background: #f5f0e5;
  color: var(--judgment-muted);
  font: 12px/1.6 var(--judgment-ui);
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-ranges {
  min-width: 0;
}

.judgment-surface .judgment-range {
  min-width: 0;
  margin: 0 0 29px;
}

.judgment-surface .judgment-range h3 {
  margin: 0 0 10px;
  color: var(--judgment-accent-deep);
  font: 600 10px/1.5 var(--judgment-apparatus);
  letter-spacing: .055em;
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-paragraph {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 0 14px;
  min-width: 0;
  margin: 0;
  padding: 13px 14px 15px 0;
  border-top: 1px solid var(--judgment-rule);
  border-left: 2px solid #b7aa94;
  background: transparent;
  scroll-margin-block: 20px;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.judgment-surface .judgment-number {
  display: block;
  padding: 2px 0 0 13px;
  color: var(--judgment-accent-deep);
  font: 500 12px/1.55 var(--judgment-apparatus);
  white-space: nowrap;
}

.judgment-surface .judgment-number::before,
.judgment-surface .judgment-number::after { content: none; }

.judgment-surface .judgment-body {
  min-width: 0;
  max-width: 72ch;
  color: var(--judgment-ink);
  font: 400 16px/1.72 var(--judgment-editorial);
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

/* Natural header/toolbar height must not subtract from an assumed fixed height. */
dialog.judgment-surface[open],
section.judgment-surface.is-standalone {
  display: flex;
  flex-direction: column;
}
section.judgment-surface.is-standalone { height: calc(100dvh - 126px); min-height: 0; }
.judgment-surface .judgment-header,
.judgment-surface .judgment-toolbar,
.judgment-surface .judgment-status { flex: 0 0 auto; }
.judgment-surface .judgment-reading { flex: 1 1 auto; height: auto; min-height: 0; }

.judgment-surface .judgment-body > :first-child { margin-top: 0; }
.judgment-surface .judgment-body > :last-child { margin-bottom: 0; }
.judgment-surface .judgment-body p { margin: 0 0 .85em; }
.judgment-surface .judgment-body blockquote {
  margin: .35em 0;
  padding: 0;
  border: 0;
  color: inherit;
  font: inherit;
}

.judgment-surface .judgment-paragraph.is-target {
  border-left: 3px solid var(--judgment-accent);
  background: #f4ecda;
  box-shadow: inset 0 0 0 1px #e5d7bc;
}

.judgment-surface .judgment-paragraph.is-target .judgment-number {
  color: var(--judgment-accent);
  font-weight: 700;
}

.judgment-surface .judgment-paragraph:focus,
.judgment-surface .judgment-paragraph:focus-visible {
  outline: 2px solid var(--judgment-focus);
  outline-offset: 3px;
}

.judgment-surface .judgment-apparatus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .82fr);
  gap: 18px 32px;
  margin-top: 26px;
  padding: 18px 0 0;
  border-top: 2px solid var(--judgment-ink);
}

.judgment-surface .judgment-apparatus > * { min-width: 0; }

.judgment-surface .judgment-copy {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 0 8px 8px 0;
  padding: 8px 12px;
  border: 1px solid #bdb29e;
  border-radius: 0;
  background: transparent;
  color: var(--judgment-accent-deep);
  cursor: pointer;
  font: 600 10px/1.4 var(--judgment-apparatus);
  text-align: center;
}

.judgment-surface .judgment-copy:hover {
  border-color: var(--judgment-accent);
  background: #f4efe4;
}

.judgment-surface .judgment-copy-status {
  display: inline-block;
  color: var(--judgment-muted);
  font: 11px/1.5 var(--judgment-ui);
}

.judgment-surface .judgment-other {
  align-self: start;
  border-top: 1px solid var(--judgment-rule);
  border-bottom: 1px solid var(--judgment-rule);
}

.judgment-surface .judgment-other > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--judgment-accent-deep);
  cursor: pointer;
  font: 600 10px/1.45 var(--judgment-apparatus);
  list-style: none;
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-other > summary::-webkit-details-marker { display: none; }
.judgment-surface .judgment-other > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--judgment-accent);
  font: 16px/1 var(--judgment-apparatus);
}
.judgment-surface .judgment-other[open] > summary::after { content: "−"; }

.judgment-surface .judgment-other button,
.judgment-surface .judgment-jump button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  max-width: 100%;
  margin: 0 6px 8px 0;
  padding: 7px 10px;
  border: 1px solid var(--judgment-rule);
  border-radius: 0;
  background: transparent;
  color: var(--judgment-muted);
  cursor: pointer;
  font: 500 10px/1.4 var(--judgment-apparatus);
  text-align: left;
  overflow-wrap: anywhere;
}

.judgment-surface .judgment-other button:hover,
.judgment-surface .judgment-jump button:hover {
  border-color: var(--judgment-accent);
  color: var(--judgment-accent-deep);
  background: #f4efe4;
}

.judgment-surface .judgment-jump {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin: 20px 0 4px;
  padding: 13px 0 0;
  border-top: 1px solid var(--judgment-rule);
}

.judgment-surface .judgment-jump label {
  display: grid;
  flex: 1 1 180px;
  gap: 5px;
  color: var(--judgment-muted);
  font: 600 9px/1.4 var(--judgment-apparatus);
  letter-spacing: .055em;
  text-transform: uppercase;
}

.judgment-surface .judgment-jump input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #bdb29e;
  border-radius: 0;
  background: var(--judgment-paper);
  color: var(--judgment-ink);
  font: 14px/1.4 var(--judgment-apparatus);
}

.judgment-surface .judgment-jump button {
  justify-content: center;
  margin: 0;
  border-color: var(--judgment-accent);
  background: var(--judgment-accent);
  color: #fff8ec;
  font-weight: 600;
}

.judgment-surface .judgment-qualification {
  margin: 19px 0 0;
  padding: 13px 0 0 18px;
  border-top: 1px solid var(--judgment-rule);
  color: var(--judgment-muted);
  font: 11px/1.6 var(--judgment-ui);
}

.judgment-surface .judgment-error {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--judgment-accent);
  background: #f6e9df;
  color: #672d26;
  font: 12px/1.55 var(--judgment-ui);
  overflow-wrap: anywhere;
}

.judgment-surface :is(button, a, input, summary, [tabindex]):focus-visible {
  /* public.css's white outline requires an outer dark ring. This surface
     intentionally has no shadow, so use the existing dark accent instead. */
  outline: 3px solid var(--judgment-accent-deep) !important;
  outline-offset: 3px;
  box-shadow: none;
}

@media (max-width: 700px) {
  dialog.judgment-surface {
    width: calc(100vw - 24px);
    height: calc(100dvh - 24px);
  }

  section.judgment-surface.is-standalone {
    width: calc(100% - 24px);
    min-height: calc(100dvh - 24px);
    margin: 12px auto;
  }

  .judgment-surface .judgment-header {
    padding: 18px 18px 14px;
  }

  .judgment-surface .judgment-header :is(h1, h2) {
    max-width: calc(100% - 46px);
    padding-right: 0;
    font-size: clamp(26px, 7vw, 34px);
  }

  .judgment-surface .judgment-close {
    top: 12px;
    right: 12px;
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .judgment-surface .judgment-close::before {
    margin: 0;
    font-size: 22px;
  }

  .judgment-surface .judgment-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
  }

  .judgment-surface .judgment-views {
    flex: 1 1 100%;
    gap: 4px;
  }

  .judgment-surface .judgment-views button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 7px;
    font-size: 9px;
  }

  .judgment-surface .judgment-external {
    min-height: 40px;
    justify-content: flex-start;
    padding: 5px 8px;
    font-size: 9px;
  }

  .judgment-surface .judgment-status {
    padding-right: 18px;
    padding-left: 18px;
  }

  .judgment-surface .judgment-reading {
    height: calc(100% - 173px);
    min-height: 240px;
    padding: 16px 18px 28px;
  }

  .judgment-surface .judgment-paragraph {
    grid-template-columns: 3.3rem minmax(0, 1fr);
    gap: 0 9px;
    padding-right: 2px;
  }

  .judgment-surface .judgment-number {
    padding-left: 8px;
    font-size: 11px;
  }

  .judgment-surface .judgment-body {
    font-size: 15.5px;
    line-height: 1.68;
  }

  .judgment-surface .judgment-apparatus {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
}

@media (max-width: 420px) {
  dialog.judgment-surface {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
  }

  section.judgment-surface.is-standalone {
    width: calc(100% - 12px);
    min-height: calc(100dvh - 12px);
    margin: 6px auto;
  }

  .judgment-surface .judgment-header {
    padding: 15px 14px 12px;
  }

  .judgment-surface .judgment-header :is(h1, h2) {
    max-width: calc(100% - 42px);
  }

  .judgment-surface .judgment-identity {
    max-width: calc(100% - 36px);
    font-size: 11px;
  }

  .judgment-surface .judgment-toolbar {
    padding-inline: 10px;
  }

  .judgment-surface .judgment-views button {
    min-height: 44px;
    font-size: 8px;
    letter-spacing: -.02em;
  }

  .judgment-surface .judgment-reading {
    height: calc(100% - 169px);
    padding: 14px 13px 24px;
  }

  .judgment-surface .judgment-paragraph {
    grid-template-columns: 2.85rem minmax(0, 1fr);
    gap: 0 7px;
    padding-top: 11px;
  }

  .judgment-surface .judgment-number {
    padding-left: 6px;
    font-size: 10px;
  }

  .judgment-surface .judgment-body {
    font-size: 15px;
    line-height: 1.65;
  }
}

@media (prefers-reduced-motion: reduce) {
  .judgment-surface .judgment-paragraph {
    transition: none;
  }
}

/* The reading pane uses the remaining space, including under short mobile chrome. */
.judgment-surface .judgment-reading { min-height: 0; height: auto; }
