/*
 * Hero - CrUX: a centred title, a URL field with a button, and under it the
 * card the script fills with the answer: the verdict, the metrics and their
 * history.
 */

.hero-crux {
    position: relative;
    /* The same room above and below, whether or not there is an answer. */
    padding-top: clamp(36px, 7vw, 80px);
    padding-bottom: clamp(40px, 7vw, 80px);
    margin-bottom: var(--section-gap);
    overflow: hidden;
}

/* A class can set `display`, which would beat the attribute: hidden stays hidden. */
.hero-crux [hidden] {
    display: none !important;
}

.hero-crux__glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-crux__blob {
    position: absolute;
    border-radius: 999px;
    filter: blur(60px);
}

.hero-crux__blob--a {
    left: -6%;
    top: -40px;
    width: 440px;
    height: 440px;
    background: radial-gradient(circle, rgba(123, 108, 246, 0.42), transparent 68%);
    animation: hero-crux-blob-a 18s ease-in-out infinite;
}

.hero-crux__blob--b {
    right: -4%;
    top: 20px;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(242, 160, 184, 0.4), transparent 68%);
    animation: hero-crux-blob-b 22s ease-in-out infinite;
}

@keyframes hero-crux-blob-a {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(24px, -30px, 0) scale(1.06); }
}

@keyframes hero-crux-blob-b {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-28px, 24px, 0) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
    .hero-crux__blob { animation: none; }
    .hero-crux__button:disabled { animation: none; opacity: 0.75; }
    .hero-crux__status--error,
    .hero-crux__status--warning { animation: none; }
}

.hero-crux__inner {
    position: relative;
    margin-bottom: 28px;
    text-align: center;
}

.hero-crux__title {
    max-width: 860px;
    margin: 0 auto 22px;
    font-size: clamp(36px, 8vw, 60px);
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -0.045em;
    text-wrap: balance;
}

.hero-crux__title mark {
    background: linear-gradient(100deg, #6b5ef0, #c17be0 55%, #f2a0b8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-crux__tagline {
    max-width: 640px;
    margin: 0 auto 32px;
    font-size: clamp(16px, 2.2vw, 18px);
    line-height: 1.6;
    color: var(--ink-soft);
    text-wrap: pretty;
}

.hero-crux__title:has(+ .hero-crux__field) {
    margin-bottom: 32px;
}

/* The pill that holds the address and the button. */
.hero-crux__field {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto 14px;
    padding: 8px;
    border-radius: clamp(18px, 4vw, 999px);
    background: var(--surface);
    border: 1px solid rgba(22, 21, 28, 0.1);
    box-shadow: 0 30px 60px -40px rgba(70, 56, 180, 0.6);
}

.hero-crux__field:focus-within {
    border-color: var(--accent);
}

.hero-crux__field--invalid,
.hero-crux__field--invalid:focus-within {
    border-color: #d64550;
}

.hero-crux__field--warning,
.hero-crux__field--warning:focus-within {
    border-color: #d9901a;
}

.hero-crux__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.hero-crux__input {
    flex: 999 1 240px;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-family: inherit;
    /* 16px: smaller and iOS zooms the page when the field is focused. */
    font-size: 16px;
    color: var(--ink);
}

.hero-crux__input:focus {
    outline: none;
}

.hero-crux__button {
    flex: 1 0 auto;
    /* Wide enough for the busy label, so changing it never resizes the pill. */
    min-width: 200px;
    min-height: 48px;
    padding: 14px 26px;
    border: 0;
    border-radius: clamp(12px, 3vw, 999px);
    background: linear-gradient(135deg, #6b5ef0, #8f63e8);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.hero-crux__button:hover {
    filter: brightness(1.06);
}

.hero-crux__button:disabled {
    cursor: default;
    filter: none;
    animation: hero-crux-pulse 0.9s ease-in-out infinite;
}

@keyframes hero-crux-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.hero-crux__hint {
    max-width: 460px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-muted);
}

/* Right under the field; with no message it takes no room at all. */
.hero-crux__status {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 22px;
    color: var(--ink-soft);
}

.hero-crux__status:empty {
    display: none;
}

.hero-crux__status--error {
    color: #d64550;
    animation: hero-crux-message-in 0.25s ease-out both;
}

/* A suggestion, not a failure: amber like the field's border. */
.hero-crux__status--warning {
    max-width: 560px;
    margin-inline: auto;
    color: #8a5208;
    animation: hero-crux-message-in 0.25s ease-out both;
}

/* The suggested address reads as a link and is one. */
.hero-crux__suggestion {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.hero-crux__suggestion:hover {
    text-decoration-thickness: 2px;
}

@keyframes hero-crux-message-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* ---- the answer */

.hero-crux__results {
    position: relative;
}

.hero-crux__card {
    display: grid;
    /* minmax(0, ...): a wide child scrolls in its own box instead of widening the whole card. */
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding: 28px;
    border-radius: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 40px 80px -60px rgba(70, 56, 180, 0.45);
    text-align: left;
}

.hero-crux__summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 18px;
}

.hero-crux__verdict {
    flex: 1 1 320px;
    min-width: 0;
}

.hero-crux__verdict-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.hero-crux__verdict-title {
    font-size: clamp(28px, 4vw, 34px);
    font-weight: 600;
    letter-spacing: -0.035em;
}

.hero-crux__verdict-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-soft);
}

.hero-crux__devices-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.hero-crux__devices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hero-crux__meta {
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-muted);
}

.hero-crux__notice {
    margin: 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(250, 178, 25, 0.12);
    border: 1px solid rgba(250, 178, 25, 0.3);
    font-size: 14px;
    line-height: 1.5;
}

.hero-crux__data {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

/* A rating is a shape as well as a colour: circle, square, triangle. */
.hero-crux__mark {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
}

.hero-crux__mark--large {
    width: 14px;
    height: 14px;
}

.hero-crux__mark--good { border-radius: 999px; background: #0ca30c; }
.hero-crux__mark--ni { border-radius: 2px; background: #fab219; }
.hero-crux__mark--poor { background: #d03b3b; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.hero-crux__mark--none { border-radius: 999px; border: 2px solid #8b8894; }

/* ---- the metrics */

.hero-crux__metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 14px;
}

.hero-crux__metric {
    min-width: 0;
    padding: 20px;
    border-radius: 18px;
    border: 1px solid rgba(22, 21, 28, 0.08);
    background: var(--surface);
}

.hero-crux__metric--other {
    padding: 16px 20px;
    background: rgba(22, 21, 28, 0.025);
    border-color: rgba(22, 21, 28, 0.06);
}

.hero-crux__metric-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--ink-soft);
}

.hero-crux__metric-abbr {
    font-size: 12px;
    color: var(--ink-muted);
}

.hero-crux__metric-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.hero-crux__metric-value {
    font-size: 36px;
    font-weight: 600;
    letter-spacing: -0.035em;
}

.hero-crux__metric--other .hero-crux__metric-value {
    font-size: 24px;
    letter-spacing: -0.03em;
}

.hero-crux__badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.hero-crux__badge--good { background: rgba(12, 163, 12, 0.1); }
.hero-crux__badge--ni { background: rgba(250, 178, 25, 0.16); }
.hero-crux__badge--poor { background: rgba(208, 59, 59, 0.1); }

.hero-crux__share-bar {
    display: flex;
    gap: 2px;
    height: 10px;
    margin-bottom: 10px;
    border-radius: 999px;
    overflow: hidden;
}

.hero-crux__metric--other .hero-crux__share-bar {
    height: 8px;
}

.hero-crux__share-segment {
    flex: none;
    width: calc(var(--share) - 2px);
    min-width: 3px;
}

.hero-crux__share-segment--good { background: #0ca30c; }
.hero-crux__share-segment--ni { background: #fab219; }
.hero-crux__share-segment--poor { background: #d03b3b; }

.hero-crux__share-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--ink-soft);
}

.hero-crux__share-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hero-crux__metric-limits {
    font-size: 12.5px;
    color: var(--ink-muted);
}

/* ---- history */

.hero-crux__history {
    min-width: 0;
    padding: 22px;
    border-radius: 18px;
    border: 1px solid rgba(22, 21, 28, 0.08);
}

.hero-crux__section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.hero-crux__section-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.hero-crux__section-head .hero-crux__section-title {
    margin-bottom: 4px;
}

.hero-crux__section-note {
    margin: 0;
    font-size: 13px;
    color: var(--ink-muted);
}

.hero-crux__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hero-crux__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(22, 21, 28, 0.13);
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}

.hero-crux__pill--active {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

.hero-crux__pill-note {
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(22, 21, 28, 0.06);
    font-size: 11px;
}

.hero-crux__pill--active .hero-crux__pill-note {
    background: rgba(255, 255, 255, 0.18);
}

.hero-crux__readout {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-bottom: 16px;
}

.hero-crux__readout-value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.hero-crux__change {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.hero-crux__change--flat { background: rgba(22, 21, 28, 0.06); }
.hero-crux__change--good { background: rgba(12, 163, 12, 0.1); }
.hero-crux__change--bad { background: rgba(208, 59, 59, 0.1); }

.hero-crux__chart {
    position: relative;
    padding-left: 52px;
}

.hero-crux__y {
    position: absolute;
    left: 0;
    top: 0;
    width: 46px;
    height: 240px;
    font-size: 11.5px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.hero-crux__y-label {
    position: absolute;
    right: 0;
    top: var(--y);
    transform: translateY(-50%);
}

.hero-crux__y-label--zero {
    top: auto;
    bottom: 0;
    transform: translateY(50%);
}

.hero-crux__plot {
    position: relative;
    height: 240px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(22, 21, 28, 0.18);
    cursor: crosshair;
    /* Dragging along the chart reads it; going up and down still scrolls the page. */
    touch-action: pan-y;
}

.hero-crux__svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.hero-crux__zone--good { fill: #0ca30c; fill-opacity: 0.07; }
.hero-crux__zone--ni { fill: #fab219; fill-opacity: 0.12; }
.hero-crux__zone--poor { fill: #d03b3b; fill-opacity: 0.08; }

.hero-crux__area {
    fill: #6b5ef0;
    fill-opacity: 0.08;
}

.hero-crux__line {
    fill: none;
    stroke: #6b5ef0;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.hero-crux__limit {
    position: absolute;
    right: 8px;
    top: var(--y);
    transform: translateY(-120%);
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    pointer-events: none;
}

.hero-crux__limit--good { color: #1d6b2a; }
.hero-crux__limit--poor { color: #9e2525; }

.hero-crux__guide {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--x);
    width: 1px;
    background: rgba(22, 21, 28, 0.3);
    pointer-events: none;
}

.hero-crux__dot {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 999px;
    background: #6b5ef0;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
}

.hero-crux__tip {
    position: absolute;
    top: 8px;
    left: var(--x);
    z-index: 2;
    transform: translateX(-50%);
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
}

.hero-crux__tip-date {
    font-size: 12px;
    color: #b8b5c1;
}

.hero-crux__tip-value {
    font-size: 15px;
    font-weight: 600;
}

.hero-crux__x {
    position: relative;
    height: 22px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--ink-muted);
}

.hero-crux__x-label {
    position: absolute;
    top: 0;
    left: var(--x);
    transform: translateX(-50%);
    white-space: nowrap;
}

.hero-crux__x-label--first { transform: none; }
.hero-crux__x-label--last { left: auto; right: 0; transform: none; }

.hero-crux__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 14px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.hero-crux__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hero-crux__legend-line {
    width: 16px;
    height: 2px;
    background: #6b5ef0;
}

.hero-crux__legend-zone {
    width: 12px;
    height: 10px;
}

.hero-crux__legend-zone--good { background: rgba(12, 163, 12, 0.16); }
.hero-crux__legend-zone--ni { background: rgba(250, 178, 25, 0.24); }
.hero-crux__legend-zone--poor { background: rgba(208, 59, 59, 0.16); }

.hero-crux__details {
    font-size: 14px;
}

.hero-crux__summary-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    color: var(--accent);
    cursor: pointer;
}

.hero-crux__table-wrap {
    max-height: 280px;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid rgba(22, 21, 28, 0.08);
}

.hero-crux__details[open] .hero-crux__summary-toggle {
    margin-bottom: 8px;
}

.hero-crux__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.hero-crux__table th {
    padding: 8px 12px;
    background: rgba(22, 21, 28, 0.03);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    color: var(--ink-soft);
}

.hero-crux__table td {
    padding: 7px 12px;
    border-top: 1px solid rgba(22, 21, 28, 0.06);
}

.hero-crux__table th.hero-crux__cell--number,
.hero-crux__cell--number {
    text-align: right;
}

.hero-crux__cell--number {
    font-variant-numeric: tabular-nums;
}

.hero-crux__cell--soft {
    color: var(--ink-soft);
}

/* ---- what changed: the findings come from the API, not from this project; the styles wait for them */

.hero-crux__findings {
    display: grid;
    gap: 14px;
}

.hero-crux__finding-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 14px;
}

.hero-crux__finding {
    padding: 18px;
    border-radius: 16px;
    border: 1px solid transparent;
}

.hero-crux__finding--good { background: rgba(12, 163, 12, 0.05); border-color: rgba(12, 163, 12, 0.18); }
.hero-crux__finding--bad { background: rgba(208, 59, 59, 0.05); border-color: rgba(208, 59, 59, 0.18); }
.hero-crux__finding--warn { background: rgba(250, 178, 25, 0.08); border-color: rgba(250, 178, 25, 0.3); }
.hero-crux__finding--info { background: rgba(107, 94, 240, 0.06); border-color: rgba(107, 94, 240, 0.18); }

.hero-crux__finding-label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

.hero-crux__finding--good .hero-crux__finding-label { color: #1d6b2a; }
.hero-crux__finding--bad .hero-crux__finding-label { color: #9e2525; }
.hero-crux__finding--warn .hero-crux__finding-label { color: #7a5300; }
.hero-crux__finding--info .hero-crux__finding-label { color: #4a40c8; }

.hero-crux__finding-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
}

/* ---- narrow screens */

@media (max-width: 900px) {
    .hero-crux__card { padding: 20px; }
    .hero-crux__history { padding: 16px; }
}

@media (max-width: 767px) {
    .hero-crux__card { padding: 16px; gap: 22px; }
    .hero-crux__metric-value { font-size: 30px; }
    .hero-crux__y,
    .hero-crux__plot { height: 200px; }
    .hero-crux__chart { padding-left: 46px; }
    .hero-crux__y { width: 40px; }
}
