/* GrydCalcState, the calculating state shown between submit and result.
   Stands alone: it borrows the Daylight tokens but no other stylesheet, so it
   can mount in the site assessment page, the homepage popup and the FHS modal. */

.gcs {
  --gcs-ink: var(--red110, #4E251B);
  --gcs-muted: var(--warm-grey, #746056);
  --gcs-plate: var(--stonelight, #EFEAE3);
  --gcs-flare: var(--flare-ink, #BF3719);
  --gcs-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: var(--gcs-ink);
  font-family: "DM Sans", ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  opacity: 1;
  transition: opacity .2s ease;
}
.gcs.is-going { opacity: 0; }

/* Both the state and the result heading are scripted focus targets, not tab
   stops, so they take focus without drawing a ring the reader did not ask for. */
.gcs[tabindex="-1"]:focus,
.gcs[tabindex="-1"]:focus-visible,
.ar-title[tabindex="-1"]:focus,
.ar-title[tabindex="-1"]:focus-visible { outline: none; }

/* Ledger, the site assessment */

.gcs-pending { position: relative; }
.gcs-pending > :not(.gcs-ledger) { visibility: hidden; }
.gcs-ledger {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 8px 0 12px;
  background: var(--sam-paper, #F8F6F2);
}

.gl-plate {
  position: sticky;
  top: 8px;
  box-sizing: border-box;
  height: var(--gcs-fill, 420px);
  display: grid;
  grid-template-rows: repeat(6, minmax(0, 1fr)) minmax(0, 1.7fr);
  background: var(--gcs-plate);
  border-radius: 18px;
  padding: 4px 22px 8px;
  box-shadow: 0 6px 20px rgba(40, 18, 12, .07);
  overflow: hidden;
}

.gl-activity {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: var(--gcs-flare);
  transform-origin: left;
  animation: gl-progress 5s linear forwards, gl-pulse 1.2s 5s ease-in-out infinite;
}
@keyframes gl-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes gl-pulse { 50% { opacity: .35; } }

.gl-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 16px;
  min-width: 0;
  border-bottom: 1px solid rgba(120, 96, 86, .14);
  opacity: .42;
  transition: opacity .3s ease;
}
.gl-row.is-live, .gl-row.is-done { opacity: 1; }
.gl-row:nth-last-child(2) { border-bottom: 0; }

.gl-lab {
  font-size: 15px;
  line-height: 1.25;
  color: var(--gcs-muted);
  min-width: 0;
  text-wrap: pretty;
}
.gl-val {
  font-family: var(--gcs-mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: var(--gcs-ink);
  white-space: nowrap;
}
.gl-wait {
  display: none;
  width: 44px;
  height: 8px;
  border-radius: 4px;
  background: rgba(120, 96, 86, .2);
}
.gl-row:not(.is-live):not(.is-done) .gl-val { display: none; }
.gl-row:not(.is-live):not(.is-done) .gl-wait { display: block; }

.gl-tick {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity .2s ease;
  color: var(--gcs-flare);
  justify-self: end;
}
.gl-row.is-done .gl-tick { opacity: 1; }

.gl-row.is-head {
  grid-template-columns: minmax(0, 1fr) auto;
  border-top: 1px solid rgba(120, 96, 86, .22);
  border-bottom: 0;
  margin-top: 2px;
}
.gl-row.is-head .gl-lab {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.gl-row.is-head .gl-val {
  font-family: "Borna", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 1;
  letter-spacing: -.01em;
  color: var(--gcs-flare);
}
.gl-row.is-head .gl-wait { width: 96px; height: 14px; }

/* Counting numbers, the FHS checker */

.gcs-count { padding: 30px 0 34px; }
.gcs-line {
  font-size: 15px;
  line-height: 1.4;
  color: var(--gcs-muted);
  margin: 0;
  min-height: 21px;
}
.gcs-figs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-bottom: 18px;
}
.gcs-figs[data-n="1"] { grid-template-columns: minmax(0, 1fr); max-width: 440px; }
.gcs-fig {
  position: relative;
  background: var(--gcs-plate);
  border-radius: 16px;
  padding: 12px 15px 13px;
  box-shadow: 0 6px 20px rgba(40, 18, 12, .07);
  min-height: 96px;
}
.gcs-fig-title {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--gcs-muted);
  margin-bottom: 6px;
}
.gcs-fig-n {
  display: block;
  color: var(--gcs-flare);
  font-family: "Borna", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(34px, 3.6vw, 44px);
  font-weight: 500;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.gcs-fig-sub {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--gcs-muted);
}
.gcs-skel {
  position: absolute;
  left: 15px;
  right: 15px;
  top: 30px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(90deg,
    rgba(120, 96, 86, .13) 0%,
    rgba(120, 96, 86, .22) 45%,
    rgba(120, 96, 86, .13) 90%);
  background-size: 220% 100%;
  animation: gcs-shimmer 1.15s ease-in-out infinite;
}
.gcs-fig.is-skel .gcs-fig-n,
.gcs-fig.is-skel .gcs-fig-sub { visibility: hidden; }
.gcs-fig:not(.is-skel) .gcs-skel { display: none; }

@keyframes gcs-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}

/* The result rises in once, on the frame after the state leaves. */

.gcs-in > * { animation: gcs-rise .32s ease both; }

@keyframes gcs-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .gl-plate { padding: 2px 15px 6px; border-radius: 16px; }
  .gl-row { gap: 10px; grid-template-columns: minmax(0, 1fr) auto 18px; }
  .gl-lab { font-size: 13.5px; }
  .gl-val { font-size: 15px; }
  .gl-tick { width: 14px; height: 14px; }
  .gl-row.is-head .gl-val { font-size: 30px; }
  .gcs-count { padding: 22px 0 26px; }
  .gcs-figs { grid-template-columns: minmax(0, 1fr); }
  .gcs-fig { min-height: 84px; }
  .gcs-fig-n { font-size: 32px; }
  .gcs-skel { top: 28px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .gl-activity { animation: none; }
  .gcs, .gcs.is-going, .gl-row, .gl-tick { transition: none; }
  .gcs-skel { animation: none; background: rgba(120, 96, 86, .16); }
  .gcs-in > * { animation: none; }
}
