/* Page styles. Colours come only from tokens.css via var(--...). */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
}

.court-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  border-bottom: 2px solid var(--rule);
}

.seal {
  width: 4rem;
  height: 4rem;
  color: var(--seal);
}

.court-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: 0.5rem 0 0;
}

.court-main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

.court-main h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
}

.court-footer {
  text-align: center;
  color: var(--muted-ink);
  font-size: var(--text-sm);
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
  padding: 1rem;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--verdict-border);
  background: var(--verdict-bg);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-lg);
}

/* T05: judge portraits */
.portrait {
  display: inline-grid;
  width: 6rem;
  height: 6rem;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--accent, currentColor);
  border-radius: 50%;
  background: var(--paper, Canvas);
  color: var(--ink, CanvasText);
  vertical-align: middle;
}

.portrait__image,
.portrait__initials {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.portrait__image {
  display: block;
  object-fit: cover;
}

.portrait__initials {
  display: grid;
  place-items: center;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

/* Author display rules otherwise override the browser's hidden attribute. */
.portrait__image[hidden],
.portrait__initials[hidden] {
  display: none;
}

/* T02: file / case / join pages. Mobile-first: single column, sides sit
   side by side on wider screens. Colours only via tokens.css var(--...). */
.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.form-field input[type="text"],
.form-field textarea,
.judge-call input[type="password"] {
  display: block;
  width: 100%;
  padding: 0.5rem;
  font: inherit;
  color: var(--ink);
  background: var(--verdict-bg);
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
}

.form-field textarea {
  min-height: 7rem;
}

.char-count {
  color: var(--muted-ink);
  font-size: var(--text-sm);
  margin: 0.25rem 0 0;
}

.form-error {
  padding: 0.5rem 0.75rem;
  background: var(--verdict-bg);
  border: 1px solid var(--verdict-border);
}

.caption {
  font-size: var(--text-lg);
}

.case-no {
  color: var(--muted-ink);
}

.countdown {
  font-weight: 600;
}

.case-sides {
  display: grid;
  gap: 1rem;
  margin: 1rem 0;
}

@media (min-width: 40rem) {
  .case-sides {
    grid-template-columns: 1fr 1fr;
  }
}

.side {
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
}

.side-plaintiff h2 {
  color: var(--plaintiff);
}

.side-defendant h2 {
  color: var(--defendant);
}

.argument {
  border-top: 1px solid var(--rule);
  padding: 0.5rem 0;
}

.argument-author {
  font-weight: 600;
  margin: 0;
}

.argument-text {
  margin: 0.25rem 0;
  white-space: pre-wrap;
}

.edit-link,
.side-name {
  font-size: var(--text-sm);
}

.side-picker {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

.side-picker legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.5rem;
}

.side-option {
  display: block;
  margin-bottom: 0.75rem;
}

.side-option input {
  position: absolute;
  opacity: 0;
}

.side-option-card {
  display: block;
  padding: 0.75rem 1rem;
  font-size: var(--text-lg);
  background: var(--verdict-bg);
  border: 2px solid var(--rule);
  border-radius: 0.25rem;
  cursor: pointer;
}

.side-option input:checked + .side-option-card {
  border-color: var(--verdict-border);
}

.side-option input:focus-visible + .side-option-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.overruled {
  font-style: italic;
}

/* T02 QA: long unbroken user text must wrap, and grid children must shrink,
   so nothing overflows a 320px viewport. */
.caption,
.relief,
.side-name,
.argument-author,
.argument-text,
.side-option-card {
  overflow-wrap: anywhere;
}

.case-sides > *,
.side,
.argument,
.side-option,
.side-option-card {
  min-width: 0;
}
/* T04: docket home page. Cards on phones, table-like rows on wide screens. */
.docket-actions {
  margin: 1.5rem 0;
}

.docket-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--rule);
  background: var(--verdict-bg);
}

.docket-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--muted-ink);
}

.docket-field input,
.docket-field select {
  min-width: 0;
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
}

.docket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.docket-row {
  min-width: 0;
  border: 1px solid var(--rule);
  background: var(--verdict-bg);
}

.docket-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  color: var(--ink);
  text-decoration: none;
}

/* Grid children default to min-width: auto, which lets a long
   unbroken word force the page wider than a 320px viewport. */
.docket-link > * {
  min-width: 0;
}

.docket-no {
  font-size: var(--text-sm);
  color: var(--muted-ink);
  overflow-wrap: anywhere;
}

.docket-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.docket-matter {
  font-size: var(--text-sm);
  color: var(--muted-ink);
  overflow-wrap: anywhere;
}

.docket-status {
  justify-self: start;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--verdict-border);
  font-size: var(--text-xs);
}

.docket-verdict {
  font-size: var(--text-sm);
  color: var(--accent);
}

.docket-appeal {
  font-size: var(--text-sm);
  color: var(--muted-ink);
}

@media (min-width: 48rem) {
  .docket-link {
    grid-template-columns: 6rem minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 0.5rem 1rem;
  }

  .docket-matter,
  .docket-verdict,
  .docket-appeal {
    grid-column: 2;
  }

  .docket-status {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
}

/* T07: judged case page. Mobile-first, single column: caption, verdict box
   (the centrepiece), debate summary, opinions, arguments, then controls. */
.judged {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.verdict-box {
  text-align: center;
  padding: 1.25rem 1rem;
  background: var(--verdict-bg);
  border: 2px solid var(--verdict-border);
  border-radius: 0.25rem;
}

.verdict-line {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin: 0 0 0.75rem;
}

.default-ribbon {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--verdict-border);
  font-size: var(--text-sm);
}

.holding {
  font-weight: 600;
}

.debate-summary {
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
}

.debate-summary h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0 0 0.5rem;
}

.opinions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.opinion {
  min-width: 0;
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
}

.opinion-judge {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0.5rem 0 0.25rem;
}

.role-badge {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--verdict-border);
  font-size: var(--text-sm);
}

.role-majority {
  background: var(--verdict-bg);
  color: var(--ink);
}

.role-concurrence {
  color: var(--muted-ink);
}

.role-dissent {
  background: var(--seal);
  border-color: var(--seal);
  color: var(--paper);
}

.opinion-text {
  margin: 0;
  white-space: pre-wrap;
}

/* Long user text must wrap so nothing overflows a 320px viewport. */
.caption,
.case-no,
.verdict-line,
.default-ribbon,
.holding,
.relief,
.debate-summary,
.opinion-judge,
.role-badge,
.opinion-text,
.argument-author,
.argument-text,
.share-note,
.overruled {
  overflow-wrap: anywhere;
}

.original-arguments {
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
}

.original-arguments summary {
  cursor: pointer;
  font-weight: 600;
}

.judged-actions,
.appeal {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}

.share-note {
  margin: 0;
  color: var(--muted-ink);
  font-size: var(--text-sm);
}

/* Reveal: judges appear one at a time (~0.8 s apart via --d), verdict last.
   The animation class is added by reveal.js, so without JS (or on repeat
   visits, or with reduced motion) everything is simply visible. */
@keyframes judged-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.judged-reveal .reveal-item,
.judged-reveal .reveal-verdict {
  opacity: 0;
  animation: judged-in 0.6s ease forwards;
  animation-delay: var(--d, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .judged-reveal .reveal-item,
  .judged-reveal .reveal-verdict {
    opacity: 1;
    animation: none;
  }
}

@media print {
  .judged-actions,
  .appeal {
    display: none;
  }
}

/* T13: quiet strike control. A plain-text disclosure at the very bottom of
   open and judged pages; the password form needs no new JS. Colours only
   via tokens.css var(--...). */
.strike {
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
}

.strike-toggle {
  display: inline;
  cursor: pointer;
  color: var(--muted-ink);
  font-size: var(--text-sm);
}

.strike form {
  margin-top: 0.75rem;
}

.strike input[type="password"] {
  display: block;
  width: 100%;
  padding: 0.5rem;
  font: inherit;
  color: var(--ink);
  background: var(--verdict-bg);
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
}

.strike-submit {
  padding: 0.4rem 0.8rem;
  font-size: var(--text-sm);
  color: var(--muted-ink);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
  cursor: pointer;
}

.struck-notice {
  font-style: italic;
}

/* T09: court records (docket stats). Same card look as the docket list. */
.court-records {
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  background: var(--verdict-bg);
}

.court-records h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0 0 0.5rem;
}

.court-records ul {
  margin: 0;
  padding-left: 1.25rem;
}

.court-records li {
  margin: 0.25rem 0;
  overflow-wrap: anywhere;
}

/* T10: owner UI pass (Nov 7 2026). New rules live here; earlier rules are
   only overridden below, never rewritten, so widths/themes stay intact. */

/* Header home link + nav. Wraps cleanly at 360px. */
.court-home {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
}

.court-home .court-name {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.court-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  justify-content: center;
  margin-top: 0.75rem;
  font-size: var(--text-sm);
}

.court-nav a {
  padding: 0.25rem 0;
  color: var(--ink);
  text-decoration: none;
}

.court-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.court-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* One court button style (tokens only, site fonts, no browser Arial).
   Covers link-buttons, all <button>s and submit inputs. */
.button,
button,
input[type="submit"] {
  font-family: var(--font-body);
}

.button,
button,
input[type="submit"] {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--verdict-border);
  border-radius: 0.25rem;
  background: var(--verdict-bg);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-lg);
  line-height: 1.4;
  cursor: pointer;
}

.button:disabled,
button:disabled,
input[type="submit"]:disabled {
  cursor: default;
}

.button:focus-visible,
button:focus-visible,
input[type="submit"]:focus-visible,
.court-nav a:focus-visible,
.docket-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Primary variant (filled, accent): File a Case, file submit, join submit,
   Call for Judgement. Share + Appeal stay on the base (secondary) style. */
.button-primary,
form[action="/file"] button[type="submit"],
#join-submit,
.judge-call #call-judgement {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* Docket intro: short pitch + primary File a Case button. */
.docket-intro p {
  margin: 0 0 0.75rem;
  overflow-wrap: anywhere;
}

/* Opinions: left column (portrait, name, badge) stacked and centred,
   text on the right. Side by side even at 360px (no stacking). */
.opinion {
  display: grid;
  grid-template-columns: minmax(88px, max-content) minmax(0, 1fr);
  gap: 0.75rem 1rem;
  align-items: start;
}

.opinion-side {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.opinion-side .portrait {
  width: 100%;
  max-width: 88px;
  height: auto;
  aspect-ratio: 1 / 1;
}

.opinion-side .opinion-judge {
  margin: 0;
  font-size: var(--text-base);
  /* Judge names wrap only at spaces (never split mid-word). */
  overflow-wrap: normal;
  word-break: normal;
}

.opinion-side .role-badge {
  margin: 0;
  /* Badges never break: one word kept on one line. */
  white-space: nowrap;
  overflow-wrap: normal;
  font-size: var(--text-xs);
}

.opinion-body {
  min-width: 0;
}

.opinion-body .opinion-text {
  margin: 0;
}

/* Vote count never breaks across lines. */
.vote-count {
  white-space: nowrap;
}

/* Judged action row: Share + Appeal side by side under the verdict box,
   so both show without scrolling past the opinions. */
.judged-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: start;
}

.judged-action-row .appeal-inline {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}

.judged-action-row .share-note {
  flex-basis: 100%;
}

/* Reveal: hidden items collapse fully (display:none in the `from` frame with
   backwards fill, so no ~250px empty gap and no grid-gap residue before the
   verdict appears). Older browsers that cannot animate display ignore it and
   fall back to the opacity fade above. reveal.js is untouched: it still adds
   .judged-reveal on the first view only, so without JS everything stays
   visible. */
.judged-reveal .reveal-item,
.judged-reveal .reveal-verdict {
  animation-fill-mode: both;
}

@keyframes judged-in {
  from {
    display: none;
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Reduced motion (and print): animation is off, so the `from` frame with
   display:none never applies and everything stays visible. */
@media (prefers-reduced-motion: reduce) {
  .judged-reveal .reveal-item,
  .judged-reveal .reveal-verdict {
    opacity: 1;
    animation: none;
  }
}

@media print {
  .judged-reveal .reveal-item,
  .judged-reveal .reveal-verdict {
    opacity: 1;
    animation: none;
  }
}

/* Narrow phones: keep the header, nav and opinion row inside 360px. */
input,
textarea,
select {
  max-width: 100%;
}

@media (min-width: 48rem) {
  .opinion {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .opinion-side .portrait {
    max-width: 120px;
  }

  /* Desktop column fits the full-size badge on one line. */
  .opinion-side .role-badge {
    font-size: var(--text-sm);
  }
}

@media print {
  .judged-action-row {
    display: none;
  }
}

/* T14: judge profiles + The Bench grid. Colours only via tokens.css var(--...). */
.judges-grid {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.judges-cell {
  min-width: 0;
  border: 1px solid var(--rule);
  background: var(--verdict-bg);
}

.judges-link {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  text-align: center;
  padding: 0.75rem 0.5rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.judges-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}

.judges-record {
  font-size: var(--text-sm);
  color: var(--muted-ink);
  overflow-wrap: anywhere;
}

@media (min-width: 48rem) {
  .judges-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.judge-profile {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  min-width: 0;
}

.portrait--large .portrait {
  width: 12rem;
  height: 12rem;
}

.judge-source,
.judge-doctrine,
.judge-tendency,
.judge-record,
.judge-matter {
  overflow-wrap: anywhere;
}

.judge-source {
  font-style: italic;
  color: var(--muted-ink);
  margin: 0;
}

.judge-recent,
.judge-favors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  width: 100%;
}

.judge-opinion {
  min-width: 0;
  border: 1px solid var(--rule);
  padding: 0.75rem 1rem;
  overflow-wrap: anywhere;
}

/* T15 */
.public-opinion {
  border: 1px solid var(--rule);
  background: var(--verdict-bg);
  padding: 0.75rem 1rem;
}

.public-opinion h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0 0 0.5rem;
}

.reaction-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reaction-form button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.reaction-count {
  white-space: nowrap;
}

/* T17 */
.opinion {
  /* Fixed left column on phones: same 88px width whatever the judge's name. */
  grid-template-columns: 88px minmax(0, 1fr);
}

.opinion-side--fixed {
  /* Locks the left column to the grid track so long names can't stretch it. */
  width: 88px;
  min-width: 0;
  max-width: 100%;
}

.opinion-side--fixed .opinion-judge,
.opinion-side--fixed .opinion-judge a {
  /* Wrap at spaces inside the fixed column, never split mid-word. */
  overflow-wrap: normal;
  word-break: normal;
  min-width: 0;
  max-width: 100%;
}

.opinion-side--fixed .role-badge {
  /* Badges stay on one line, centred in the fixed column. */
  white-space: nowrap;
  max-width: 100%;
}

/* Single-column judged grid: every direct child must shrink, or a long
   word in the verdict, debate summary or reactions forces page overflow. */
.judged > * {
  min-width: 0;
}

.public-opinion-reveal {
  min-width: 0;
}

.public-opinion {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 48rem) {
  .opinion {
    /* Fixed left column on desktop: same 120px width whatever the name. */
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .opinion-side--fixed {
    width: 120px;
  }
}

/* T17 addendum: judge-name links use court ink (not browser blue),
   with underline only on hover/focus and a visible focus ring. */
.judge-link {
  color: var(--ink);
  text-decoration: none;
}

.judge-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.judge-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.2em;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The Bench cells link the whole card; keep the same ink treatment so
   no judge link ever falls back to the browser-default blue. */
.judges-link:hover .judges-name {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.judges-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
