/*
 * Shared UI kit — reusable primitives used on every surface:
 * skip-link, btn-pill (+variants), status-block, doc-prose helpers.
 * Page layouts belong in chrome/home/settings/search — not here.
 */

.skip-link {
  position: absolute;
  left: max(12px, env(safe-area-inset-left, 0px));
  top: max(12px, env(safe-area-inset-top, 0px));
  z-index: 10000;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--lift-1);
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--duration-base),
    opacity var(--duration-base);

  &:focus,
  &:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}

.btn-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border-radius: var(--r-pill);
  padding: 12px 18px;
  min-height: var(--control-height, 44px);
  box-sizing: border-box;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-spring),
    transform var(--duration-fast) var(--ease-spring),
    filter var(--duration-base) var(--ease-out);

  &:active {
    transform: scale(0.97);
  }

  &:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
    box-shadow: var(--focus-ring);
  }

  &:disabled {
    opacity: 0.7;
    cursor: wait;
  }
}

.btn-pill--primary {
  color: var(--bg);
  background: var(--blue);
  border-color: transparent;

  @media (hover: hover) {
    &:hover {
      filter: brightness(1.05);
      text-decoration: none;
    }
  }
}

.btn-pill--secondary {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
  box-shadow: var(--lift-1);

  @media (hover: hover) {
    &:hover {
      border-color: var(--border-strong);
      box-shadow: var(--lift-2);
      background: var(--surface0);
      text-decoration: none;
    }
  }
}

.status-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  width: min(100%, 28rem);
}

.status-block__title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}

.status-block__detail {
  margin: 0;
  font-size: 1.05rem;
  color: var(--subtext);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.status-block__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.status-block__badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  background: var(--surface0);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  margin: 0 0 16px;
  line-height: 1;
}

.doc-prose {
  max-width: none;
  display: block;
  width: 100%;
  color: var(--text);
  line-height: 28px;

  @media (max-width: 900px) {
    max-width: 100%;
  }

  strong {
    font-weight: 600;
  }

  em {
    font-style: italic;
  }

  h1,
  h2,
  h3 {
    line-height: 1.3;
  }

  /* Machine-translation notice on translated legal pages (src/pages.js). */
  .doc-note {
    margin: 0 0 16px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface0);
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
  }

  /* .page-title (chrome) owns the hero h1; keep a fallback for bare h1s. */
  h1:not(.page-title) {
    font-size: 24px;
  }

  h2 {
    font-size: 17px;
    margin-top: 1.8rem;
    font-weight: 600;
    margin-bottom: 0;
  }

  .bigh2 {
    margin: 48px 0 16px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
    letter-spacing: -0.02em;
    line-height: 32px;
    font-size: 24px;

    @media (max-width: 900px) {
      margin: 32px 0 12px;
      padding-top: 20px;
      font-size: 1.25rem;
      line-height: 1.3;
    }
  }

  h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 0;
    margin-top: 22px;
  }

  h1,
  h2,
  h3,
  b {
    color: var(--text);
  }

  a {
    color: var(--blue);
    text-decoration: underline;

    &:hover {
      text-decoration: none;
    }
  }

  code {
    background: var(--surface0);
    padding: 0.15em 0.35em;
    border-radius: var(--r-xs);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.9em;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  pre {
    background: var(--surface0);
    padding: 12px;
    border-radius: var(--r-sm);
    /* Wrap long lines instead of a sideways scroll region: readable on
       phones and reachable without a focus stop (WCAG 2.1.1). */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 1em 0;

    code {
      background: none;
      padding: 0;
      font-size: 0.9em;
      position: relative;
    }
  }

  ul,
  ol {
    padding-left: 1.4em;
    margin: 0.75em 0;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
  }

  li {
    margin: 0.3em 0;
    margin-bottom: -1px;

    b {
      font-weight: 500;
    }
  }

  table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.95em;
  }

  th,
  td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
  }

  th {
    color: var(--text);
    font-weight: 600;
  }

  blockquote {
    border-left: 3px solid var(--blue);
    padding-left: 12px;
    margin: 1em 0;
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link,
  .btn-pill {
    transition: none !important;
  }

  .btn-pill:active {
    transform: none !important;
  }
}
