/* keaiui public-web patterns — framework-neutral editorial standards for Tanji
   websites. Load after tokens.css. These classes own shared anatomy and state,
   not a product-shell skin; each site owns its compact, unboxed layout and
   frames only content whose meaning needs a boundary. */

.keaiui-web-page,
.keaiui-web-page * {
  box-sizing: border-box;
}

.keaiui-web-page {
  min-height: 100vh;
  margin: 0;
  color: var(--color-text);
  background: var(--color-surface-page);
  font-family: var(--keaiui-web-page-font-family, var(--font-sans));
  font-size: var(--keaiui-web-page-font-size, var(--text-size-web-body));
  line-height: var(--keaiui-web-page-line-height, 1.5);
  -webkit-text-size-adjust: 100%;
}

.keaiui-web-page ::selection {
  background: var(--color-accent-tint);
}

.keaiui-web-page :where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 1px dotted var(--focus-ring);
  outline-offset: 2px;
}

/* Grammar defaults at zero specificity: the link state colors and heading face
   are shared, so any site rule (even a bare `a {}`) still overrides them for
   its dialect — weight, size and spacing stay with the site. */
:where(.keaiui-web-page) :where(a) {
  color: var(--color-accent);
  text-underline-offset: 2px;
}

:where(.keaiui-web-page) :where(a:hover) {
  color: var(--color-accent-hover);
}

:where(.keaiui-web-page) :where(h1, h2, h3, h4) {
  color: var(--color-text-strong);
  font-family: var(--font-serif);
}

/* The page gutter that keeps the shell off the viewport edge. */
.keaiui-web-gutter {
  padding: 0 16px 24px;
}

.keaiui-web-shell {
  width: min(100%, var(--keaiui-web-shell-width, 720px));
  margin-inline: auto;
}

.keaiui-web-reading {
  --keaiui-web-shell-width: 820px;
}

.keaiui-web-prose {
  max-width: 72ch;
}

.keaiui-web-skip-link {
  position: fixed;
  z-index: 10;
  top: var(--space-4);
  left: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  color: var(--color-text-strong);
  background: var(--color-button-face);
  box-shadow: var(--bevel-raised);
  transform: translateY(-160%);
}

.keaiui-web-skip-link:focus-visible {
  transform: translateY(0);
}

.keaiui-web-lockup {
  display: inline-flex;
  align-items: center;
  gap: var(--keaiui-web-lockup-gap, 0.23em);
}

.keaiui-web-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.keaiui-web-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--size-ctrl-md);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  color: var(--color-text-strong);
  background: var(--color-button-face);
  box-shadow: var(--bevel-raised);
  font-size: var(--text-size-web-ui);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast), color var(--motion-fast);
}

.keaiui-web-action:hover {
  color: var(--color-text-strong);
  background: var(--color-button-hover);
  box-shadow: var(--bevel-raised-hover);
}

.keaiui-web-action:active {
  background: var(--color-button-active);
  box-shadow: var(--bevel-pressed);
}

.keaiui-web-action-primary,
.keaiui-web-action[aria-current='page'] {
  border-color: var(--color-accent-soft-border);
  color: var(--color-text-strong);
  background: var(--color-accent-soft);
}

/* Public entry actions have their own reading/target role. Compact navigation
   and data controls keep the default geometry. */
.keaiui-web-action-primary {
  min-height: var(--size-ctrl-xl);
  font-size: var(--text-size-web-body);
}

.keaiui-web-action-primary:hover {
  border-color: var(--color-accent-soft-border);
  color: var(--color-text-strong);
  background: var(--color-accent-soft-hover);
}

.keaiui-web-action-primary:active {
  background: var(--color-accent-soft-active);
}

.keaiui-web-action[aria-current='page'] {
  box-shadow: var(--bevel-active);
  font-weight: 600;
}

.keaiui-web-action[aria-disabled='true'] {
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.keaiui-web-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  color: var(--color-text-muted);
  background: var(--color-surface-raised);
  font: 600 var(--text-size-web-meta)/1.2 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.keaiui-web-status-live {
  border-color: var(--color-success);
  color: var(--color-success);
  background: var(--color-success-bg);
}

.keaiui-web-local-scroll {
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable both-edges;
}

.keaiui-web-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

@media (max-width: 480px) {
  .keaiui-web-gutter {
    padding-inline: 12px;
  }

  .keaiui-web-action {
    min-width: var(--size-touch);
    min-height: var(--size-touch);
  }

  a.keaiui-web-lockup,
  .keaiui-web-nav > :where(a, button) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--size-touch);
    min-height: var(--size-touch);
  }

  .keaiui-web-footer {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .keaiui-web-action {
    transition: none;
  }
}
