/* =========================================================
   Elemental W — Panel unificado de resultados
   ========================================================= */

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;

  background: var(--ew-color-background);
  color: var(--ew-color-text);
}

[hidden] {
  display: none !important;
}

/* ---------- Main ---------- */

.results-main {
  padding-block: clamp(2rem, 6vw, 4.5rem);
}

/* ---------- Shared headings ---------- */

.results-eyebrow {
  color: var(--ew-theme-accent);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.results-section-heading {
  margin-bottom: var(--ew-space-5);
}

.results-section-heading h2 {
  margin: var(--ew-space-1) 0 0;

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 400;
  line-height: 1.05;
}

/* ---------- Hero ---------- */

.results-hero {
  position: relative;

  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(300px, 0.72fr);

  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;

  overflow: hidden;

  margin-bottom: var(--ew-space-6);
  padding: clamp(2rem, 5vw, 4rem);

  border-radius: var(--ew-radius-xl);

  background: color-mix(in srgb, var(--ew-theme-background) 54%, white);
}

.results-hero::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;

  width: 6px;

  background: var(--ew-theme-accent);

  content: "";
}

.results-hero__copy {
  position: relative;
  z-index: 1;

  max-width: 660px;
}

.results-hero h1 {
  margin: var(--ew-space-2) 0 var(--ew-space-4);

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 400;
  line-height: 0.96;
}

.results-hero__copy > p {
  max-width: 610px;
  margin: 0;

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-lg);
  line-height: 1.65;
}

/* ---------- Mascot + score ---------- */

.results-hero__visual {
  position: relative;

  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: var(--ew-space-3);
  align-items: end;

  min-height: 250px;
}

.results-mascot {
  position: relative;

  display: grid;
  min-height: 230px;
  place-items: end center;

  transition: transform var(--ew-transition-base);
}

.results-mascot:hover {
  transform: translateY(-3px) rotate(1deg);
}

.results-mascot::before {
  position: absolute;

  width: 190px;
  height: 190px;

  border-radius: 46% 54% 61% 39% / 42% 38% 62% 58%;

  background: color-mix(in srgb, var(--ew-theme-surface) 34%, white);

  content: "";
}

.results-mascot img {
  position: relative;
  z-index: 1;

  width: min(100%, 190px);
  max-height: 220px;

  object-fit: contain;
}

/* ---------- Score ---------- */

.results-score {
  position: relative;
  z-index: 2;

  align-self: center;
}

.results-score__ring {
  --result-percentage: 0%;

  display: grid;
  width: 164px;
  height: 164px;
  place-items: center;

  border-radius: 50%;

  transition:
    transform var(--ew-transition-base),
    box-shadow var(--ew-transition-base);

  background: conic-gradient(
    var(--ew-theme-accent) var(--result-percentage),
    color-mix(in srgb, var(--ew-theme-surface) 24%, white) 0
  );

  box-shadow: var(--ew-shadow-md);
}

.results-score:hover .results-score__ring {
  transform: scale(1.025);
  box-shadow: var(--ew-shadow-sm);
}

.results-score__inside {
  display: grid;
  width: 128px;
  height: 128px;
  place-content: center;

  border-radius: 50%;

  background: var(--ew-color-surface);

  text-align: center;
}

.results-score__inside strong {
  color: var(--ew-theme-ink);

  font-family: var(--ew-font-display);
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 400;
  line-height: 1;
}

.results-score__inside span {
  margin-top: var(--ew-space-1);

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
  font-weight: 700;
}

/* ---------- Academic summary ---------- */

.results-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));

  margin-bottom: clamp(2.5rem, 6vw, 4.5rem);

  border-top: 1px solid var(--ew-color-border);
  border-bottom: 1px solid var(--ew-color-border);
}

.results-summary__item {
  display: grid;
  gap: var(--ew-space-2);

  min-width: 0;

  padding: var(--ew-space-5);
}

.results-summary__item + .results-summary__item {
  border-left: 1px solid var(--ew-color-border);
}

.results-summary__item > span {
  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.results-summary__item strong {
  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(1.75rem, 3.5vw, 2.6rem);
  font-weight: 400;
  line-height: 1;
}

.results-summary__item small {
  color: var(--ew-color-text-muted);
  font-size: var(--ew-text-xs);
}

.results-summary__item .results-summary__level {
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
  line-height: 1.15;
}

/* ---------- Detail layout ---------- */

.results-details {
  display: grid;
  grid-template-columns:
    minmax(0, 1.12fr)
    minmax(300px, 0.88fr);

  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

/* ---------- Attempt information ---------- */

.results-attempt {
  padding-block: var(--ew-space-4);
}

.results-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--ew-space-6);

  margin: 0;
}

.results-info div {
  padding-block: var(--ew-space-4);

  border-bottom: 1px solid var(--ew-color-border);
}

.results-info dt {
  margin-bottom: var(--ew-space-1);

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.results-info dd {
  margin: 0;

  color: var(--ew-color-text);

  font-weight: 700;
  line-height: 1.45;
}

/* ---------- Topics ---------- */

.results-topics {
  margin-top: var(--ew-space-5);
}

.results-topics__title {
  display: block;

  margin-bottom: var(--ew-space-3);

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.results-topics__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ew-space-2);
}

.results-topic {
  padding: 0.5rem 0.8rem;

  transition:
    transform var(--ew-transition-fast),
    background-color var(--ew-transition-fast),
    border-color var(--ew-transition-fast);

  border: 1px solid color-mix(in srgb, var(--ew-theme-accent) 24%, transparent);

  border-radius: var(--ew-radius-pill);

  background: color-mix(in srgb, var(--ew-theme-surface) 16%, white);

  color: var(--ew-theme-ink);

  font-size: var(--ew-text-xs);
  font-weight: 800;
}

.results-topic:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ew-theme-accent) 42%, transparent);
  background: color-mix(in srgb, var(--ew-theme-surface) 26%, white);
}

/* ---------- What next ---------- */

.results-next {
  padding: clamp(1.5rem, 4vw, 2.4rem);

  border-radius: var(--ew-radius-xl);

  background: color-mix(in srgb, var(--ew-theme-surface) 18%, white);
}

.results-feedback__block {
  padding-left: var(--ew-space-4);

  border-left: 3px solid
    color-mix(in srgb, var(--ew-theme-accent) 60%, transparent);
}

.results-feedback__block + .results-feedback__block {
  margin-top: var(--ew-space-5);
}

.results-feedback__block span {
  color: var(--ew-theme-accent);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.results-feedback__block p {
  margin: var(--ew-space-2) 0 0;

  color: var(--ew-color-text);

  line-height: 1.7;
}

/* ---------- Actions ---------- */

.results-actions {
  display: flex;
  justify-content: flex-end;

  margin-top: var(--ew-space-7);
}

/* ---------- Empty state ---------- */

.results-empty {
  display: grid;
  grid-template-columns: minmax(180px, 0.6fr) minmax(0, 1fr);
  gap: clamp(2rem, 7vw, 5rem);
  align-items: center;

  max-width: var(--ew-container-md);

  padding-block: var(--ew-space-8);
}

.results-empty__mascot {
  position: relative;

  display: grid;
  min-height: 270px;
  place-items: center;
}

.results-empty__mascot::before {
  position: absolute;

  width: 230px;
  height: 230px;

  border-radius: 48% 52% 42% 58% / 54% 43% 57% 46%;

  background: color-mix(in srgb, var(--ew-theme-surface) 28%, white);

  content: "";
}

.results-empty__mascot img {
  position: relative;
  z-index: 1;

  width: min(100%, 220px);
  max-height: 260px;

  object-fit: contain;
}

.results-empty h1 {
  max-width: 620px;

  margin: var(--ew-space-2) 0 var(--ew-space-4);

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 400;
  line-height: 0.98;
}

.results-empty p {
  max-width: 560px;

  margin: 0 0 var(--ew-space-5);

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-lg);
  line-height: 1.65;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .results-hero {
    grid-template-columns: 1fr;
  }

  .results-hero__visual {
    width: min(100%, 430px);
  }

  .results-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .results-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .results-summary__item:nth-child(3) {
    border-left: 0;
  }

  .results-summary__item:nth-child(n + 3) {
    border-top: 1px solid var(--ew-color-border);
  }

  .results-empty {
    grid-template-columns: 1fr;

    padding-block: var(--ew-space-6);

    text-align: center;
  }

  .results-empty__mascot {
    min-height: 220px;
  }

  .results-empty__copy {
    display: grid;
    justify-items: center;
  }
}

@media (max-width: 520px) {
  .results-main {
    padding-block: var(--ew-space-5);
  }

  .results-hero {
    padding: var(--ew-space-4);
  }

  .results-hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
  }

  .results-hero__visual {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--ew-space-4);

    min-height: auto;
  }

  .results-mascot {
    min-height: auto;
  }

  .results-mascot::before {
    width: 120px;
    height: 120px;
  }

  .results-mascot img {
    width: min(100%, 120px);
    max-height: 140px;
  }

  .results-score__ring {
    width: 120px;
    height: 120px;
  }

  .results-score__inside {
    width: 94px;
    height: 94px;
  }

  .results-score__inside strong {
    font-size: 1.7rem;
  }

  .results-summary__item {
    padding: var(--ew-space-3) var(--ew-space-4);
  }

  .results-summary__item strong {
    font-size: clamp(1.4rem, 6vw, 1.8rem);
  }

  .results-info {
    grid-template-columns: 1fr;
  }

  .results-actions {
    justify-content: stretch;
  }

  .results-actions .ew-button {
    width: 100%;
  }

  .results-next {
    padding: var(--ew-space-4);
  }

  .results-feedback__block {
    padding-left: var(--ew-space-3);
  }

  .results-empty {
    padding-block: var(--ew-space-5);
  }

  .results-empty__mascot {
    min-height: 160px;
  }

  .results-empty__mascot::before {
    width: 150px;
    height: 150px;
  }

  .results-empty__mascot img {
    width: min(100%, 140px);
    max-height: 160px;
  }

  .results-empty h1 {
    font-size: clamp(1.8rem, 8vw, 2.8rem);
  }
}

.results-mascot.is-entering img,
.results-empty__mascot.is-entering img {
  animation: ew-mascot-enter 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.results-mascot.is-idle img {
  animation: ew-mascot-float 3.4s ease-in-out 800ms infinite;
}

@media (prefers-reduced-motion: reduce) {
  .results-mascot.is-entering img,
  .results-empty__mascot.is-entering img,
  .results-mascot.is-idle img {
    animation: none;
  }

  .results-mascot,
  .results-score__ring,
  .results-topic {
    transition: none;
  }

  .results-mascot:hover,
  .results-score:hover .results-score__ring,
  .results-topic:hover {
    transform: none;
  }
}

.resultados-acciones {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ew-space-3);

  margin-top: var(--ew-space-6);
}

.resultados-volver {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ew-space-2);
}

.resultados-inicio {
  display: grid;
  place-items: center;

  width: 44px;
  height: 44px;

  color: var(--ew-theme-accent);

  background: color-mix(in srgb, var(--ew-theme-accent) 8%, white);

  border: 1px solid color-mix(in srgb, var(--ew-theme-accent) 35%, transparent);

  border-radius: 50%;

  text-decoration: none;

  transition:
    background-color var(--ew-transition-fast),
    border-color var(--ew-transition-fast),
    color var(--ew-transition-fast),
    transform var(--ew-transition-fast),
    box-shadow var(--ew-transition-fast);
}

.resultados-inicio:hover {
  transform: translateY(-1px);

  background: color-mix(in srgb, var(--ew-theme-accent) 14%, white);

  box-shadow: var(--ew-shadow-sm);
}

.resultados-inicio:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-theme-accent) 30%, transparent);

  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (max-width: 520px) {
  .resultados-acciones {
    justify-content: center;
  }

  .resultados-volver {
    flex: 1;
  }

  .resultados-inicio {
    flex: 0 0 44px;
  }
}

/* =========================================================
   Historial personal
   ========================================================= */

.results-history {
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
}

.results-history__navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ew-space-4);
}

.results-history__back {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;

  min-height: 38px;
  padding: 0.45rem 0.7rem;

  border: 0;
  border-radius: var(--ew-radius-pill);

  background: transparent;
  color: var(--ew-color-text-muted);

  font: inherit;
  font-size: var(--ew-text-sm);
  font-weight: 700;

  text-decoration: none;
  cursor: pointer;

  transition:
    color var(--ew-transition-fast),
    background-color var(--ew-transition-fast),
    transform var(--ew-transition-fast);
}

.results-history__back:hover {
  background: color-mix(in srgb, var(--ew-theme-surface) 28%, transparent);

  color: var(--ew-theme-accent);
}

.results-history__back:hover {
  transform: translateX(-2px);
}

.results-history__back:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 24%, transparent);

  outline-offset: 3px;
}

.results-history__intro {
  position: relative;

  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: end;

  padding-bottom: clamp(1.75rem, 4vw, 3rem);

  border-bottom: 1px solid var(--ew-color-border);
}

.results-history__intro > div {
  max-width: 720px;
}

.results-history__intro h1 {
  margin: var(--ew-space-2) 0 var(--ew-space-3);

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-display);
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 400;
  line-height: 0.96;
}

.results-history__intro p {
  max-width: 620px;
  margin: 0;

  color: var(--ew-color-text-muted);

  font-family: var(--ew-font-heading);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.55;
}

.results-history__mascot {
  width: clamp(90px, 12vw, 150px);
  height: auto;

  animation: results-history-float 4s ease-in-out infinite;
}

@keyframes results-history-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

/* ---------- Rows ---------- */

.results-history__list {
  display: grid;
}

.results-history-item {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto
    auto;

  gap: clamp(1rem, 4vw, 3rem);
  align-items: center;

  min-width: 0;
  padding: clamp(1.25rem, 3vw, 1.8rem) var(--ew-space-2);

  border-bottom: 1px solid var(--ew-color-border);

  color: inherit;
  text-decoration: none;

  transition:
    padding-inline var(--ew-transition-fast),
    background-color var(--ew-transition-fast);
}

.results-history-item:first-child {
  border-top: 1px solid var(--ew-color-border);
}

.results-history-item:hover {
  padding-inline: var(--ew-space-4);

  background: color-mix(in srgb, var(--ew-theme-background) 38%, transparent);
}

.results-history-item:focus-visible {
  border-radius: var(--ew-radius-sm);

  outline: 3px solid color-mix(in srgb, var(--ew-color-focus) 25%, transparent);

  outline-offset: 3px;
}

.results-history-item__content {
  display: grid;
  gap: 0.3rem;

  min-width: 0;
}

.results-history-item__module {
  color: var(--ew-theme-accent);

  font-size: var(--ew-text-xs);
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.results-history-item__title {
  overflow: hidden;

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  font-weight: 400;
  line-height: 1.15;

  text-overflow: ellipsis;
}

.results-history-item__score {
  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-sm);
}

.results-history-item__result {
  display: grid;
  gap: 0.15rem;

  min-width: 150px;

  text-align: right;
}

.results-history-item__percentage {
  color: var(--ew-theme-ink);

  font-family: var(--ew-font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 400;
}

.results-history-item__level {
  color: var(--ew-theme-accent);

  font-size: var(--ew-text-sm);
  font-weight: 700;
}

.results-history-item__date {
  margin-top: var(--ew-space-1);

  color: var(--ew-color-text-muted);

  font-size: var(--ew-text-xs);
}

.results-history-item__arrow {
  color: var(--ew-theme-accent);

  font-family: var(--ew-font-heading);
  font-size: 1.7rem;

  transition: transform var(--ew-transition-fast);
}

.results-history-item:hover .results-history-item__arrow {
  transform: translateX(4px);
}

/* ---------- Empty / auth / error state ---------- */

.results-history__state {
  display: grid;
  grid-template-columns:
    minmax(100px, 170px)
    minmax(0, 560px);

  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;

  max-width: 820px;
  margin-inline: auto;
  padding-block: clamp(2rem, 6vw, 4.5rem);
}

.results-history__state img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
}

.results-history__state h2 {
  margin: var(--ew-space-2) 0 var(--ew-space-3);

  color: var(--ew-theme-ink);

  font-family: var(--ew-font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 1;
}

.results-history__state p {
  margin: 0 0 var(--ew-space-5);

  color: var(--ew-color-text-muted);

  line-height: 1.65;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .results-history__intro {
    grid-template-columns: 1fr;
  }

  .results-history__intro h1 {
    font-size: clamp(2.5rem, 12vw, 3.8rem);
  }

  .results-history__mascot {
    display: none;
  }

  .results-history-item {
    grid-template-columns:
      minmax(0, 1fr)
      auto;

    gap: var(--ew-space-3);
  }

  .results-history-item__result {
    min-width: 0;
  }

  .results-history-item__date {
    display: none;
  }

  .results-history-item__arrow {
    display: none;
  }

  .results-history-item__score {
    font-size: var(--ew-text-xs);
  }

  .results-history__state {
    grid-template-columns:
      90px
      minmax(0, 1fr);

    align-items: start;
  }
}

@media (max-width: 520px) {
  .results-history__intro {
    grid-template-columns: 1fr;
  }

  .results-history__mascot {
    width: 76px;
  }

  .results-history-item {
    grid-template-columns: 1fr;
  }

  .results-history-item__result {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem var(--ew-space-2);
    align-items: baseline;

    text-align: left;
  }

  .results-history-item__percentage {
    font-size: 1.6rem;
  }

  .results-history__state {
    grid-template-columns: 1fr;
  }

  .results-history__state img {
    width: 88px;
  }

  .results-history__navigation {
    align-items: center;
  }

  .results-history__back {
    min-height: 36px;
    padding-inline: 0.5rem;
    font-size: var(--ew-text-xs);
  }
}

@media (prefers-reduced-motion: reduce) {
  .results-history__mascot {
    animation: none;
  }
}
