/*
 * Shared geometry and typography contract for every authenticated Globus Lex
 * page, including HTML received through the Legislație/Jurisprudență gateway.
 */
:is(body.portal-body, body[data-portal-shell]) {
  --portal-font: "Noto Sans", "DejaVu Sans", "Liberation Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --portal-content-width: 1180px;
  --portal-card-radius: 8px;
  --portal-card-padding: 24px;
  --portal-hero-padding: 32px;
  --portal-list-card-padding: 16px;
  --portal-card-border: rgba(36, 22, 15, 0.09);
  --portal-card-shadow: 0 18px 42px rgba(48, 30, 19, 0.07);
  --portal-button-primary: #7a4a1f;
  --portal-button-primary-hover: #5f3518;
  --portal-button-secondary-bg: #ffffff;
  --portal-button-secondary-text: #4b2e1a;
  --portal-button-danger: #b42318;
  --portal-button-danger-hover: #8f1d15;
  font-family: var(--portal-font) !important;
  font-size: 16px;
  line-height: 1.55;
}

:is(body.portal-body, body[data-portal-shell]) :where(
  button,
  input,
  select,
  textarea,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  a,
  span,
  strong,
  small,
  label,
  summary,
  dt,
  dd,
  li,
  time
) {
  font-family: var(--portal-font) !important;
}

/*
 * One typographic scale for native and gateway pages. Module styles used to
 * assign different weights to equivalent headings and body copy.
 */
:is(body.portal-body, body[data-portal-shell]) :is(h1, h2, h3) {
  font-weight: 800 !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(h4, h5, h6) {
  font-weight: 700 !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  p,
  dd,
  li,
  .result-object,
  .result-excerpt,
  .meta,
  .lead
) {
  font-weight: 400 !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  label,
  dt,
  summary,
  .eyebrow,
  .portal-hero-kicker,
  .section-head > span
) {
  font-weight: 700 !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  button,
  .button,
  .button-link,
  input[type="submit"]
) {
  font-weight: 700 !important;
}

:is(body.portal-body, body[data-portal-shell]) strong {
  font-weight: 700 !important;
}

/* Generated legal documents intentionally retain document typography. */
body.portal-body .generated-document,
body.portal-body .generated-document * {
  font-family: "Times New Roman", Times, serif !important;
}

/* The same content column is used by native and gateway pages. */
body.portal-body .layout,
body[data-portal-shell] :is(main.page, main.site-main) {
  box-sizing: border-box !important;
  width: min(var(--portal-content-width), 100%) !important;
  max-width: var(--portal-content-width) !important;
  margin-right: auto !important;
  margin-left: auto !important;
  padding: 26px 28px 58px !important;
}

body[data-portal-shell] > .portal-hero {
  width: min(1124px, calc(100% - 32px));
}

/* The only hero component allowed in the authenticated portal. */
:is(body.portal-body, body[data-portal-shell]) .portal-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 10px;
  box-sizing: border-box;
  min-height: 192px;
  border: 1px solid rgba(36, 22, 15, 0.09) !important;
  border-top: 4px solid #8a5a1f !important;
  border-radius: var(--portal-card-radius) !important;
  padding: var(--portal-hero-padding) !important;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 236, 216, 0.94) 68%, rgba(232, 207, 145, 0.42) 100%) !important;
  box-shadow: var(--portal-card-shadow) !important;
}

:is(body.portal-body, body[data-portal-shell]) .portal-hero::after {
  content: "";
  position: absolute;
  top: -88px;
  right: -42px;
  width: 250px;
  height: 250px;
  border: 1px solid rgba(138, 90, 31, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

:is(body.portal-body, body[data-portal-shell]) .portal-hero-copy {
  position: relative;
  z-index: 1;
}

:is(body.portal-body, body[data-portal-shell]) .portal-hero-kicker {
  margin: 0 0 7px;
  color: #8a5a1f;
  font-size: 12px;
  font-weight: 700 !important;
  text-transform: uppercase;
}

:is(body.portal-body, body[data-portal-shell]) .portal-hero h1 {
  max-width: 900px;
  margin: 0;
  color: #24160f;
  font-size: clamp(34px, 4.5vw, 58px);
  font-weight: 800 !important;
  line-height: 1.04;
  letter-spacing: 0;
}

:is(body.portal-body, body[data-portal-shell]) .portal-hero p:not(.portal-hero-kicker) {
  max-width: 820px;
  margin: 10px 0 0;
  color: #6f6257;
  font-size: 15px;
  font-weight: 400 !important;
  line-height: 1.55;
}

/* Primary cards: one radius, padding, border and shadow everywhere. */
:is(body.portal-body, body[data-portal-shell]) :is(
  .panel,
  .search-panel,
  .filter-bar,
  .info-card,
  .sidebar-card,
  .domain-card,
  .details,
  .version-list,
  .modifier-list,
  .metadata-card,
  .article-card,
  .content-header,
  .source-notice,
  .decision-page,
  .page-intro,
  .hub-primary,
  .hub-list,
  .branch,
  .document-card,
  .dosare-tile,
  .dossier-card,
  .module-shortcuts > a,
  .summary > div,
  .stats > div
) {
  box-sizing: border-box;
  border-color: var(--portal-card-border) !important;
  border-radius: var(--portal-card-radius) !important;
  box-shadow: var(--portal-card-shadow) !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  .panel,
  .search-panel,
  .filter-bar,
  .info-card,
  .sidebar-card,
  .domain-card,
  .details,
  .version-list,
  .modifier-list,
  .metadata-card,
  .article-card,
  .content-header,
  .source-notice,
  .hub-primary,
  .hub-list,
  .branch,
  .document-card,
  .dosare-tile,
  .dossier-card,
  .module-shortcuts > a,
  .summary > div,
  .stats > div
) {
  padding: var(--portal-card-padding) !important;
}

/* Search and module-intro sections are regular cards, never secondary heroes. */
:is(body.portal-body, body[data-portal-shell]) :is(
  .portal-search-panel,
  .legal-search-card,
  .module-page-header,
  .document-header-card
) {
  box-sizing: border-box;
  min-height: 0 !important;
  border: 1px solid var(--portal-card-border) !important;
  border-radius: var(--portal-card-radius) !important;
  padding: var(--portal-card-padding) !important;
  background: #fff !important;
  box-shadow: var(--portal-card-shadow) !important;
}

:is(body.portal-body, body[data-portal-shell]) .legal-search-card::before,
:is(body.portal-body, body[data-portal-shell]) .legal-search-card::after {
  display: none !important;
  content: none !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  .portal-search-panel,
  .legal-search-card
) {
  overflow: visible !important;
}

body.portal-body .case-actions-panel {
  padding: 16px 24px !important;
}

body.portal-body .case-actions-panel .case-actions {
  margin: 0;
}

body[data-portal-shell] :is(
  .module-page-header h2,
  .document-header-card h2,
  .content-header h2,
  .decision-header h2
) {
  max-width: 900px;
  margin: 0;
  color: #24160f;
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 800 !important;
  line-height: 1.1;
}

body[data-portal-shell] :is(.module-page-header, .document-header-card) {
  display: grid;
  gap: 12px;
}

/* One semantic button palette across native and proxied modules. */
:is(body.portal-body, body[data-portal-shell]) main :where(
  button:not(.danger-button):not(.button-secondary):not(.secondary),
  input[type="submit"],
  a.button-link:not(.secondary),
  a.button.button-primary,
  a.official-button,
  a.download-button,
  a.button-source
) {
  border-color: var(--portal-button-primary) !important;
  background-color: var(--portal-button-primary) !important;
  background-image: none !important;
  color: #ffffff !important;
  text-decoration: none !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  button:not(.danger-button):not(.button-secondary):not(.secondary),
  input[type="submit"],
  a.button-link:not(.secondary),
  a.button.button-primary,
  a.official-button,
  a.download-button,
  a.button-source
):hover {
  border-color: var(--portal-button-primary-hover) !important;
  background-color: var(--portal-button-primary-hover) !important;
  background-image: none !important;
  color: #ffffff !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  a.button-link.secondary,
  a.secondary-action,
  a.legal-search-reset,
  a.secondary-button,
  a.button.button-secondary,
  a.reset-search,
  a.calendar-link,
  button.button-secondary,
  button.secondary
) {
  border-color: rgba(36, 22, 15, 0.16) !important;
  background-color: var(--portal-button-secondary-bg) !important;
  background-image: none !important;
  color: var(--portal-button-secondary-text) !important;
  text-decoration: none !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  a.button-link.secondary,
  a.secondary-action,
  a.legal-search-reset,
  a.secondary-button,
  a.button.button-secondary,
  a.reset-search,
  a.calendar-link,
  button.button-secondary,
  button.secondary
):hover {
  border-color: #8a5a1f !important;
  background-color: #fbf6ec !important;
  background-image: none !important;
  color: #6a411f !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  .danger-button,
  .button-danger,
  [data-confirm-remove] button,
  [data-confirm-client-remove] button
) {
  border-color: var(--portal-button-danger) !important;
  background-color: var(--portal-button-danger) !important;
  background-image: none !important;
  color: #ffffff !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  .danger-button,
  .button-danger,
  [data-confirm-remove] button,
  [data-confirm-client-remove] button
):hover {
  border-color: var(--portal-button-danger-hover) !important;
  background-color: var(--portal-button-danger-hover) !important;
  color: #ffffff !important;
}

:is(body.portal-body, body[data-portal-shell]) main :where(
  button,
  input[type="submit"],
  a.button,
  a.button-link,
  a.official-button,
  a.secondary-button,
  a.download-button,
  a.legal-search-reset,
  a.secondary-action,
  a.calendar-link
):focus-visible {
  outline: 3px solid rgba(181, 138, 42, 0.38) !important;
  outline-offset: 3px !important;
}

:is(body.portal-body, body[data-portal-shell]) main :is(
  button:disabled,
  input[type="submit"]:disabled,
  [aria-disabled="true"]
) {
  border-color: #dbc9aa !important;
  background-color: #e7dcc8 !important;
  background-image: none !important;
  color: #76695e !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 0.78;
}

/* Compact repeated cards use one density and stretch equally inside a list. */
:is(body.portal-body, body[data-portal-shell]) :is(
  .result-card,
  .result,
  .court-card,
  .agenda-item,
  .watched-case-card,
  .timeline-item,
  .party-row,
  .simple-row,
  .metadata-grid > div,
  .meta-grid > div,
  .note,
  .footnotes
) {
  box-sizing: border-box;
  border-color: var(--portal-card-border) !important;
  border-radius: var(--portal-card-radius) !important;
  padding: var(--portal-list-card-padding) !important;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  .result-list,
  .agenda-list,
  .watched-case-list,
  .branches,
  .document-grid,
  .module-shortcuts,
  .dossier-grid,
  .summary,
  .stats
) {
  align-items: stretch;
  grid-auto-rows: 1fr;
}

:is(body.portal-body, body[data-portal-shell]) :is(
  .result-card,
  .result,
  .agenda-item,
  .watched-case-card,
  .branch,
  .document-card,
  .module-shortcuts > a,
  .dossier-card
) {
  height: 100%;
}

/* Jurisprudence detail is one card with consistent internal gutters. */
body[data-portal-shell] .decision-page {
  overflow: hidden;
}

body[data-portal-shell] :is(.decision-header, .decision-content, .decision-sidebar) {
  padding: var(--portal-hero-padding) !important;
}

/* Grid children may contain wide financial tables; keep them inside the card. */
body.portal-body :is(
  .firme-module,
  .firme-module > *,
  .finance-table-wrap
) {
  min-width: 0;
  max-width: 100%;
}

body.portal-body .finance-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 760px) {
  :is(body.portal-body, body[data-portal-shell]) {
    --portal-card-padding: 18px;
    --portal-hero-padding: 20px;
    --portal-list-card-padding: 14px;
  }

  body.portal-body .layout,
  body[data-portal-shell] :is(main.page, main.site-main) {
    width: 100% !important;
    padding: 18px 14px 48px !important;
  }

  body[data-portal-shell] > .portal-hero {
    width: calc(100% - 28px);
  }

  :is(body.portal-body, body[data-portal-shell]) .portal-hero {
    min-height: 0;
  }
}
