/* Controls shared by the public SSR pages and the SPA shell: the skip link,
   the language switcher, the menu toggle and the screen-reader helper. Each
   surface keeps only its own sizing, spacing and colour next to its markup. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The first stop for keyboard users: hidden until it receives focus, then
   shown above the page (WCAG 2.4.1). */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-raised);
}

.skip-link:not(:focus) {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The public pages' language switcher: a disclosure button over a list of
   links, so choosing a language is a deliberate activation rather than a
   side effect of moving through a select (WCAG 3.2.2). Without JavaScript the
   list is simply shown and the button stays hidden. nav.js drives it. */
.language-switcher {
  position: relative;
  flex: 0 0 auto;
}

.language-switcher__toggle {
  display: none;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  padding: 0 var(--space-3) 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
}

.js .language-switcher__toggle { display: inline-flex; }
.language-switcher__toggle:hover { border-color: var(--border-strong); background: var(--surface-subtle); }

.language-switcher__toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-switcher__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.js .language-switcher__list {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  min-width: 10rem;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.js .language-switcher.is-open .language-switcher__list { display: flex; }

.language-switcher__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.language-switcher__list a:hover { background: var(--surface-subtle); }
.language-switcher__list a[aria-current] { color: var(--primary); font-weight: 800; }

.language-switcher__list a[aria-current]::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

/* The SPA keeps a select: switching its language rewrites the interface in
   place without leaving the page. */
.language-select {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* The select drops its own outline; the wrapper carries the ring instead. */
.language-select:focus-within { border-color: var(--focus); outline: 3px solid var(--focus); outline-offset: 2px; }

.language-select svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-select select {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.language-select select:disabled { cursor: wait; opacity: 0.6; }

.menu-toggle {
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}

.menu-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.menu-toggle__line {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 180ms ease, opacity 120ms ease;
}

.menu-toggle.is-open .menu-toggle__line--top { transform: translateY(5px) rotate(45deg); }
.menu-toggle.is-open .menu-toggle__line--middle { opacity: 0; }
.menu-toggle.is-open .menu-toggle__line--bottom { transform: translateY(-5px) rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
  .menu-toggle__line { transition: none; }
}

@media (forced-colors: active) {
  [aria-current] { outline: 2px solid Highlight; outline-offset: 2px; }
}

/* Opt-in form controls, shared by Angular, custom elements and SSR.
   Consumers own values and validation; these classes own presentation.
   Repeated classes give the contract precedence over legacy element selectors
   during migration without affecting unmarked third-party/editor controls. */
.goat-control.goat-control {
  box-sizing: border-box;
  inline-size: 100%; min-inline-size: 0; max-inline-size: 100%;
  min-block-size: var(--goat-control-height, var(--control-height, 2.5rem));
  padding: var(--goat-control-padding, .5rem .75rem);
  border: 1px solid var(--goat-control-border, var(--control-border, #7f8e80));
  border-radius: var(--goat-control-radius, var(--radius-md, .5rem));
  background: var(--goat-control-surface, var(--surface, #fff));
  color: var(--goat-control-text, var(--text, #18231c));
  font: inherit; font-weight: 400; line-height: 1.5;
}
.goat-control.goat-control::placeholder { color: var(--text-muted, #526055); opacity: 1; }
textarea.goat-control.goat-control { min-block-size: 7rem; resize: vertical; }
select.goat-control.goat-control { appearance: auto; background-image: none; padding-inline-end: .75rem; }
.goat-control.goat-control:is([type=checkbox], [type=radio]) {
  appearance: auto; inline-size: 1.15rem; block-size: 1.15rem; min-block-size: 0;
  flex: 0 0 auto; margin: 0; padding: 0; accent-color: var(--primary, #176447);
}
.goat-control.goat-control:is(:disabled, [readonly]) {
  background-color: var(--goat-control-disabled-surface, var(--surface-subtle, #edf1eb));
  color: var(--text-muted, #526055); opacity: 1;
}
.goat-control.goat-control[aria-invalid=true],
.ng-invalid.ng-touched > label > .goat-control { border-color: var(--danger, #aa3f34); }
.goat-control.goat-control:focus-visible, .goat-button.goat-button:focus-visible {
  outline: 3px solid var(--focus, #247a5a); outline-offset: 3px;
}
.goat-control.goat-control[aria-invalid=true]:focus-visible { outline-color: var(--danger, #aa3f34); }
.goat-button.goat-button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  box-sizing: border-box; min-inline-size: 0; max-inline-size: 100%;
  min-block-size: var(--goat-control-height, var(--control-height, 2.5rem));
  padding: .5rem .85rem; border: 1px solid var(--border-strong, #aebbad);
  border-radius: var(--goat-control-radius, var(--radius-md, .5rem));
  background: var(--surface, #fff); color: var(--text, #18231c);
  font: inherit; font-weight: 600; line-height: 1.5;
  text-decoration: none; text-align: center; white-space: normal; overflow-wrap: anywhere; cursor: pointer;
}
.goat-button.goat-button:hover:where(:not(:disabled, [aria-disabled=true])) { background: var(--surface-subtle, #edf1eb); }
.goat-button.goat-button--primary { background: var(--primary, #176447); border-color: var(--primary, #176447); color: var(--on-primary, #fff); }
.goat-button.goat-button--primary:hover:where(:not(:disabled, [aria-disabled=true])) { background: var(--primary-hover, #0f5339); border-color: var(--primary-hover, #0f5339); }
.goat-button.goat-button--danger { background: var(--danger, #aa3f34); border-color: var(--danger, #aa3f34); color: var(--on-danger, #fff); }
.goat-button.goat-button--danger:hover:where(:not(:disabled, [aria-disabled=true])) { background: var(--danger-strong, #8b332a); border-color: var(--danger-strong, #8b332a); }
.goat-button.goat-button--quiet { border-color: transparent; background: transparent; }
/* Sort labels and row actions determine the table's minimum column width.
   Let the wrapper scroll instead of breaking short labels into letters. */
.goat-button.goat-button.sort-button,
.goat-button.goat-button.action-menu-trigger { white-space: nowrap; overflow-wrap: normal; max-inline-size: none; }
.goat-button.sort-button > svg { flex-shrink: 0; }
.goat-button.goat-button:is(:disabled, [aria-disabled=true]) { opacity: .55; cursor: default; }
.goat-button.goat-button[aria-busy=true] { cursor: progress; }
.goat-button.goat-button[hidden], .goat-control.goat-control[hidden] { display: none; }
.goat-icon-button.goat-button { flex: 0 0 auto; aspect-ratio: 1; padding: .4rem; }
.goat-field, .goat-form { display: grid; align-content: start; gap: .35rem; min-inline-size: 0; }
.goat-form { container-type: inline-size; gap: 1rem; }
.goat-label { color: var(--text, #18231c); font-weight: 500; overflow-wrap: anywhere; }
.goat-check { display: flex; align-items: center; gap: .5rem; min-inline-size: 0; min-block-size: var(--goat-control-height, var(--control-height, 2.5rem)); }
.goat-hint, .goat-error { margin: 0; font-size: .875rem; overflow-wrap: anywhere; }
.goat-hint { color: var(--text-muted, #526055); }
.goat-error { color: var(--danger-strong, #8b332a); }
.goat-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; min-inline-size: 0; align-items: start; }
.goat-form-section { min-inline-size: 0; margin: 0; padding: 1rem 0; border: 0; border-block-start: 1px solid var(--border, #d5ddd4); }
.goat-form-section > legend { max-inline-size: 100%; padding-inline: 0 .5rem; font-weight: 600; overflow-wrap: anywhere; }
.goat-field--full { grid-column: 1 / -1; }
.goat-form-actions, .goat-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; min-inline-size: 0; }
.goat-form-actions { justify-content: flex-end; grid-column: 1 / -1; }
.goat-toolbar { align-items: end; }
.goat-toolbar > :where(label, .goat-field) { flex: 1 1 15rem; }
.goat-message { display: block; margin-block: .5rem; padding: .75rem; border: 1px solid var(--border-strong, #aebbad); border-radius: var(--radius-md, .5rem); color: var(--text-muted, #526055); background: var(--surface-subtle, #edf1eb); overflow-wrap: anywhere; }
.goat-message:empty { display: none; }
.goat-message--error { color: var(--danger-strong, #8b332a); border-color: var(--danger, #aa3f34); }
.goat-message--warning { color: var(--warning, #8b6110); border-color: currentColor; }
.goat-message--success { color: var(--success, #166b4a); border-color: currentColor; }
.goat-message p { margin-block: 0; }
.goat-message a { color: inherit; }
.goat-chip { display: inline-flex; align-items: center; gap: .25rem; min-inline-size: 0; max-inline-size: 100%; padding-inline: .5rem; border: 1px solid var(--border-strong, #aebbad); border-radius: var(--radius-md, .5rem); background: var(--surface-subtle, #edf1eb); color: var(--text, #18231c); overflow-wrap: anywhere; }
.goat-combobox { display: grid; gap: .35rem; min-inline-size: 0; position: relative; }
.goat-options { list-style: none; padding: .25rem; margin: 0; max-block-size: 18rem; overflow: auto; border: 1px solid var(--control-border, #7f8e80); border-radius: var(--radius-md, .5rem); background: var(--surface, #fff); color: var(--text, #18231c); }
.goat-options [role=option] { padding: .65rem .75rem; min-block-size: var(--goat-control-height, var(--control-height, 2.5rem)); box-sizing: border-box; overflow-wrap: anywhere; cursor: pointer; }
.goat-options [role=option]:is(:hover, [aria-selected=true]) { background: var(--surface-subtle, #edf1eb); }
@media (forced-colors: active) {
  .goat-control.goat-control[aria-invalid=true] { outline: 2px solid Highlight; }
  .goat-button.goat-button:is(:disabled, [aria-disabled=true]) { color: GrayText; opacity: 1; }
}
/* Keep native controls usable when a parent form is narrower than the viewport. */
.goat-field > *, .goat-form-grid > * { min-inline-size: 0; }
.goat-check.goat-check { flex-direction: row; }
.goat-button.goat-button:is([aria-pressed=true], [aria-selected=true], .is-selected, .selected, .current, .is-active) {
  background: var(--surface-subtle, #edf1eb); border-color: var(--primary, #176447); color: var(--primary-strong, #0d432f);
}

/* Shared Angular and HTML/SSR layout. Load after tokens; projects may override
   these variables without replacing markup or component styles. */
:root {
  --goat-page-standard: 68rem;
  --goat-page-wide: 90rem;
  --goat-page-gutter: var(--space-4);
  --goat-layout-gap: var(--space-4);
  --goat-grid-min: 18rem;
  --goat-sidebar-width: 24rem;
  --goat-surface-padding: var(--space-5);
}
.goat-page-layout {
  display: block;
  inline-size: 100%; max-inline-size: var(--goat-page-standard);
  min-inline-size: 0; margin-inline: auto; padding: var(--goat-page-gutter);
}
.goat-page-layout[data-width=wide] { max-inline-size: var(--goat-page-wide); }
.goat-page-layout[data-width=full] { max-inline-size: none; }
.goat-page-header, .goat-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--goat-layout-gap); min-inline-size: 0;
}
.goat-page-header { justify-content: space-between; align-items: start; }
.goat-page-header > :first-child { flex: 1 1 18rem; }
.goat-page-header :where(h1,h2,h3,p) { margin: 0; overflow-wrap: anywhere; }
.goat-page-header p { margin-block-start: var(--space-2); color: var(--text-muted); }
.goat-stack { display: grid; align-content: start; gap: var(--goat-layout-gap); min-inline-size: 0; }
.goat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--goat-grid-min)), 1fr));
  gap: var(--goat-layout-gap); align-items: start; min-inline-size: 0;
}
.goat-surface {
  min-inline-size: 0; padding: var(--goat-surface-padding); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text); background: var(--surface);
}
.goat-split-layout { display: block; container: goat-split / inline-size; min-inline-size: 0; }
.goat-split-grid { display: grid; grid-template-columns: var(--goat-split-columns,minmax(0,1fr) minmax(0,var(--goat-sidebar-width))); gap: var(--goat-layout-gap); align-items: start; }
.goat-split-main, .goat-split-aside { min-inline-size: 0; max-inline-size: 100%; }
@container goat-split (width < 52rem) { .goat-split-grid { grid-template-columns: minmax(0,1fr); } }
.goat-page-layout > *, .goat-stack > *, .goat-grid > *, .goat-row > *, .goat-page-header > * { min-inline-size: 0; max-inline-size: 100%; }
.goat-tabs { display: block; min-inline-size: 0; }
.goat-tab-list, .goat-view-navigation {
  display: flex; align-items: stretch; gap: var(--space-1); max-inline-size: 100%; min-inline-size: 0;
  overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin;
  border-block-end: 1px solid var(--border); padding: var(--space-1);
}
.goat-tab, .goat-view-navigation > a, .goat-view-switch-option {
  display: inline-flex; align-items: center; justify-content: center;
  min-block-size: var(--control-height); max-inline-size: 100%;
  padding: var(--space-2) var(--space-3); font: inherit; font-weight: 500;
  border: 0; border-block-end: 3px solid transparent;
  background: transparent; color: var(--text-muted); cursor: pointer;
  text-decoration: none; text-align: center;
}
.goat-tab, .goat-view-navigation > a { flex: 0 0 auto; overflow-wrap: anywhere; }
.goat-tab[aria-selected=true], .goat-view-navigation > a[aria-current=page] {
  color: var(--primary); border-block-end-color: var(--primary); font-weight: 700;
}
.goat-tab:disabled, .goat-view-switch-option:disabled { opacity: .55; cursor: default; }
.goat-tab-panel { display: block; min-inline-size: 0; padding-block: var(--space-4); }
.goat-tab-panel[hidden] { display: none !important; }
.goat-view-switch { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); min-inline-size: 0; max-inline-size: 100%; }
.goat-view-switch-option { border: 1px solid var(--border); border-radius: var(--radius-md); overflow-wrap: anywhere; }
.goat-view-switch-option[aria-pressed=true] { color: var(--primary); background: var(--surface-subtle); border-color: var(--primary); font-weight: 700; }
:where(.goat-tab,.goat-view-switch-option):enabled:hover, .goat-view-navigation > a:hover { background: var(--surface-subtle); color: var(--primary-hover); }
:where(.goat-tab,.goat-view-switch-option,.goat-view-navigation > a):focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
/* Existing form APIs retain their selectors and use the layout spacing contract. */
.goat-form, .goat-form-grid { gap: var(--goat-layout-gap); }
.goat-form-grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,var(--goat-grid-min)),1fr)); }
.goat-form-actions, .goat-toolbar { gap: var(--goat-layout-gap); }

/* Layout display rules must respect native conditional visibility. */
:where(.goat-page-layout,.goat-page-header,.goat-stack,.goat-row,.goat-grid,.goat-surface,.goat-split-layout,.goat-field)[hidden] { display: none !important; }
