/* Match sheet tool — quiet chrome on top of site.css tokens. */

:root {
  --sheet-ink: var(--ink);
  --sheet-rule: #c5d0de;
  --sheet-soft: #edf9f2;
}

[hidden] {
  display: none !important;
}

.btn-secondary,
a.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.btn-secondary:hover,
a.btn-secondary:hover {
  border-color: var(--green-deep);
  color: var(--green-deep);
}

.h-md {
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.65rem;
}

.article-hero.tool-hero {
  padding-block: clamp(1.5rem, 4vw, 2.6rem);
}

.article-hero.tool-hero .lead {
  margin-bottom: 0;
}

.section-tight.tool-section {
  padding-top: clamp(1.25rem, 3vw, 2rem);
}

.tool-lead-answer {
  max-width: 38rem;
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--muted);
}

#match-sheet-app {
  display: grid;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  /* Stable floor so the module swap does not shove the page (CLS). */
  min-height: 52rem;
}

.sheet-controls {
  display: grid;
  gap: 1rem;
  padding: 0 0 0.35rem;
}

.sheet-controls-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 720px) {
  .sheet-controls-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .sheet-controls-grid--no-paper {
    grid-template-columns: minmax(0, 16rem);
  }
}

.sheet-more-options {
  margin: 0.35rem 0 0.75rem;
  max-width: 22rem;
}

.sheet-more-options > summary {
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--muted);
  list-style: none;
}

.sheet-more-options > summary::-webkit-details-marker {
  display: none;
}

.sheet-more-options > summary::before {
  content: "▸ ";
}

.sheet-more-options[open] > summary::before {
  content: "▾ ";
}

.sheet-more-options .sheet-field {
  margin-top: 0.65rem;
}

.sheet-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.sheet-field > span {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.sheet-field input,
.sheet-field select,
.sheet-meta input,
.sheet-table input,
.sheet-period-scores input,
.sheet-final input {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.sheet-field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.sheet-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.sheet-segment button {
  min-height: 48px;
  min-width: 5.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.sheet-segment button.is-active {
  border-color: var(--green-deep);
  background: var(--sheet-soft);
  color: var(--green-deep);
}

.sheet-format-line {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  /* Non-sticky: sticky bar covered the next field on ~390px viewports. */
  position: static;
  padding: 0.35rem 0 0.15rem;
}

.sheet-paper {
  --sheet-pad: clamp(1rem, 3vw, 1.6rem);
  width: min(100%, 52rem);
  margin-inline: auto;
  padding: var(--sheet-pad);
  scroll-margin-top: 1rem;
  /* Solid base first so dark-mode contrast tools see white, not transparent. */
  background-color: #ffffff;
  background-image:
    radial-gradient(circle at top left, rgb(47 214 116 / 0.08), transparent 34%),
    linear-gradient(180deg, #ffffff, #f7fafc);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  color: var(--sheet-ink);
}

.sheet-paper-header {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.35rem;
}

.sheet-brand-row {
  display: flex;
  justify-content: flex-start;
  gap: 1rem;
  align-items: baseline;
  /* Clear band between wordmark and sheet title (no logo-on-title). */
  margin-bottom: 1.15rem;
}

/* Keep long FR/PT topnav labels on one row at ~390px without editing #19 chrome. */
@media (max-width: 26.875rem) {
  body.tool-page .topbar-tool .topnav {
    gap: 0.12rem 0.28rem;
  }

  body.tool-page .topbar-tool .topnav a {
    font-size: 0.64rem;
    letter-spacing: -0.015em;
  }
}

.sheet-brand {
  color: var(--green-deep);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.sheet-kicker {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.sheet-paper-header h2 {
  font-size: clamp(1.55rem, 3vw, 2rem);
  margin: 0;
}

.sheet-goals-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

@media (max-width: 40rem) {
  .sheet-goals-grid {
    grid-template-columns: 1fr;
  }
}

.sheet-subtitle {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.sheet-meta {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .sheet-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-meta .sheet-span-2,
  .sheet-meta label:has(.sheet-span-2) {
    grid-column: 1 / -1;
  }
}

.sheet-block {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
}

.sheet-block + .sheet-block {
  /* Same breathing room as the first block under the meta fields. */
  margin-top: 0.55rem;
  padding-top: 0.55rem;
}

.sheet-block h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sheet-periods {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 720px) {
  .sheet-periods {
    grid-template-columns: repeat(var(--period-count, 4), minmax(0, 1fr));
  }
}

.sheet-period {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--sheet-rule);
  border-radius: 14px;
  background: rgb(255 255 255 / 0.72);
}

.sheet-period-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: none;
}

.sheet-period-scores {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.35rem;
  align-items: center;
}

.sheet-period-scores input,
.sheet-final input {
  text-align: center;
  font-weight: 750;
  font-size: 1.15rem;
  min-height: 44px;
}

.sheet-final {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  /* Match top spacing of the period-score heading above the period boxes. */
  margin-top: 1.15rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--sheet-rule);
}

.sheet-final > span:first-child {
  font-weight: 700;
  margin-right: auto;
}

.sheet-final input {
  width: 3.25rem;
  min-height: 48px;
  text-align: center;
  font-weight: 750;
  font-size: 1.15rem;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.sheet-table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.35rem 0.25rem;
  border-bottom: 1.5px solid var(--ink);
}

.sheet-table td {
  padding: 0.25rem;
  border-bottom: 1px solid var(--sheet-rule);
  vertical-align: middle;
}

.sheet-table input {
  min-height: 42px;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: transparent;
  border-color: transparent;
}

.sheet-table input:hover,
.sheet-table input:focus {
  background: var(--white);
  border-color: var(--line);
}

.sheet-minutes th:first-child,
.sheet-minutes td:first-child,
.sheet-minutes th:last-child,
.sheet-minutes td:last-child {
  width: 3.2rem;
}

.sheet-minutes th:nth-child(n + 3),
.sheet-minutes td:nth-child(n + 3) {
  width: 4.2rem;
}

.sheet-minutes td:nth-child(n + 3) input {
  text-align: center;
}

.sheet-footer-note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.sheet-facts,
.sheet-cta,
.sheet-age-links {
  max-width: 40rem;
}

.sheet-answer {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
}

.sheet-dl {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.sheet-dl div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.sheet-dl dt {
  color: var(--muted);
  font-weight: 650;
}

.sheet-dl dd {
  margin: 0;
  font-weight: 700;
}

.sheet-source {
  color: var(--muted);
  font-size: 0.95rem;
}

.sheet-cta {
  padding: 1.25rem 0 0;
}

.sheet-cta .btn {
  margin-top: 0.85rem;
}

.sheet-age-links ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0;
  margin: 0.35rem 0 0;
}

.sheet-age-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.sheet-age-links a[aria-current="page"] {
  border-color: var(--green-deep);
  background: var(--sheet-soft);
  color: var(--green-deep);
}

.tool-prose {
  max-width: 40rem;
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.tool-prose-below {
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
  margin-bottom: 0;
}

.tool-prose p {
  color: var(--muted);
}

.updated-stamp {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (prefers-reduced-motion: no-preference) {
  .sheet-paper {
    animation: sheet-rise 480ms ease both;
  }

  .sheet-controls,
  .sheet-facts,
  .sheet-cta {
    animation: sheet-rise 560ms ease both;
  }

  .sheet-facts {
    animation-delay: 40ms;
  }

  .sheet-cta {
    animation-delay: 80ms;
  }
}

@keyframes sheet-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-color-scheme: dark) {
  body.tool-page {
    background: #07111f;
    color: #e8eef8;
  }

  body.tool-page .topbar {
    background: #0a1526;
    border-bottom-color: #243552;
  }

  body.tool-page .brand,
  body.tool-page .topnav a,
  body.tool-page .h-lg,
  body.tool-page .h-md,
  body.tool-page .sheet-controls .sheet-field > span,
  body.tool-page .sheet-dl dd,
  body.tool-page .sheet-answer,
  body.tool-page .crumbs,
  body.tool-page .article-hero.tool-hero {
    color: #e8eef8;
  }

  /* Links in chrome only — never override primary button ink. */
  body.tool-page .topnav a:hover,
  body.tool-page .crumbs a,
  body.tool-page .sheet-sources a,
  body.tool-page .sheet-guide-link a,
  body.tool-page .tool-prose a,
  body.tool-page .footer a {
    color: #6fe8a4;
  }

  body.tool-page .btn-primary,
  body.tool-page a.btn-primary,
  body.tool-page .header-cta,
  body.tool-page a.header-cta {
    background: var(--green);
    border-color: var(--green);
    color: #07111f;
  }

  body.tool-page .lead,
  body.tool-page .tool-lead-answer,
  body.tool-page .tool-prose p,
  body.tool-page .sheet-format-line,
  body.tool-page .sheet-source,
  body.tool-page .sheet-source-meta,
  body.tool-page .updated-stamp,
  body.tool-page .sheet-dl dt,
  body.tool-page .sheet-cta p,
  body.tool-page .faq details p {
    color: #a9b8d0;
  }

  body.tool-page .btn-secondary,
  body.tool-page a.btn-secondary,
  body.tool-page .sheet-segment button,
  body.tool-page .sheet-age-links a {
    background: #12233d;
    border-color: #314867;
    color: #e8eef8;
  }

  body.tool-page .sheet-segment button.is-active,
  body.tool-page .sheet-age-links a[aria-current="page"] {
    background: #143528;
    border-color: #2fd674;
    color: #b8f5d0;
  }

  /* Controls outside the printable sheet. */
  body.tool-page .sheet-controls .sheet-field input,
  body.tool-page .sheet-controls .sheet-field select {
    background-color: #0f1c31;
    border-color: #314867;
    color: #e8eef8;
  }

  /* Re-declare the chevron: `background` alone would wipe background-image. */
  body.tool-page .sheet-controls .sheet-field select {
    background-image: linear-gradient(45deg, transparent 50%, #c5d3e8 50%),
      linear-gradient(135deg, #c5d3e8 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
  }

  body.tool-page .sheet-actions {
    background: transparent;
  }

  /*
   * Printable sheet stays black-on-white in dark mode too, so filled values
   * stay visible and the on-screen preview matches print/PDF.
   */
  body.tool-page .sheet-paper {
    background-color: #ffffff;
    background-image:
      radial-gradient(circle at top left, rgb(47 214 116 / 0.08), transparent 34%),
      linear-gradient(180deg, #ffffff, #f7fafc);
    border-color: #c5d0de;
    color: #07111f;
    box-shadow: none;
  }

  body.tool-page .sheet-paper,
  body.tool-page .sheet-paper h2,
  body.tool-page .sheet-paper h3,
  body.tool-page .sheet-paper .sheet-field > span,
  body.tool-page .sheet-paper .sheet-final > span:first-child,
  body.tool-page .sheet-paper .sheet-footer-note {
    color: #07111f;
  }

  body.tool-page .sheet-paper .sheet-brand {
    color: #0b6b36;
  }

  body.tool-page .sheet-paper .sheet-kicker,
  body.tool-page .sheet-paper .sheet-subtitle,
  body.tool-page .sheet-paper .sheet-period-label,
  body.tool-page .sheet-paper .sheet-table th {
    color: #3d4f66;
  }

  body.tool-page .sheet-paper .sheet-field input,
  body.tool-page .sheet-paper .sheet-meta input,
  body.tool-page .sheet-paper .sheet-table input,
  body.tool-page .sheet-paper .sheet-period-scores input,
  body.tool-page .sheet-paper .sheet-final input {
    background: #ffffff;
    border-color: #c5d0de;
    color: #07111f;
  }

  body.tool-page .sheet-paper .sheet-period {
    background: rgb(255 255 255 / 0.92);
    border-color: #c5d0de;
  }

  body.tool-page .sheet-paper .sheet-final {
    background: #ffffff;
    border-color: #c5d0de;
  }

  body.tool-page .sheet-paper .sheet-table td {
    border-bottom-color: #c5d0de;
  }

  body.tool-page .sheet-paper .sheet-table th {
    border-bottom-color: #07111f;
  }

  body.tool-page .faq details,
  body.tool-page .sheet-sources,
  body.tool-page .sheet-cta {
    color: #e8eef8;
  }

  body.tool-page .faq details {
    background: #12233d;
    border-color: #314867;
  }

  body.tool-page .footer {
    background: #050b14;
    color: #a9b8d0;
  }
}

@media print {
  /* Exact @page size is injected by sheet-app.js from the paper control. */
  @page {
    margin: 12mm;
    size: A4;
  }

  .skip-link,
  .topbar,
  .article-hero,
  .sheet-controls,
  .sheet-facts,
  .sheet-sources,
  .sheet-cta,
  .sheet-age-links,
  .faq,
  .footer,
  .tool-prose,
  .updated-stamp,
  .section.section-no-top {
    display: none !important;
  }

  body,
  body.tool-page {
    background: #ffffff !important;
    color: #000000 !important;
  }

  main,
  .section-tight,
  .shell {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  .sheet-paper {
    width: 100% !important;
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    background-image: none !important;
    color: #000000 !important;
    padding: 0 !important;
  }

  .sheet-final {
    background: #ffffff !important;
    border-color: #c5d0de !important;
  }

  .sheet-minutes th,
  .sheet-minutes td {
    height: 8mm;
    min-height: 8mm;
    vertical-align: middle;
  }

  .sheet-minutes input {
    min-height: 7mm !important;
  }

  .sheet-paper *,
  .sheet-brand,
  .sheet-kicker,
  .sheet-subtitle,
  .sheet-period-label,
  .sheet-footer-note {
    color: #000000 !important;
  }

  .sheet-actions {
    display: none !important;
  }

  .sheet-field input,
  .sheet-meta input,
  .sheet-table input,
  .sheet-period-scores input,
  .sheet-final input {
    border: 0 !important;
    border-bottom: 1px solid var(--sheet-rule) !important;
    border-radius: 0 !important;
    background: transparent !important;
    min-height: 28px !important;
    padding: 0.15rem 0.1rem !important;
    color: black !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-period {
    break-inside: avoid;
  }

  .sheet-table {
    break-inside: avoid;
  }
}
