@import url(./styles/reset.css);
@import url(./styles/fonts.css);
@import url(./styles/helpers.css);
@import url(./styles/button.css);
@import url(./styles/inputs.css);
@import url(./styles/palette.css);
@import url(./styles/patterns/patterns.css);
@import url(./styles/animations.css);
@import url(./styles/debug-panel.css);

@import url(./styles/question-list.css);
@import url(./styles/buton.css);

@import url(./styles/chart.css);

:root {
  --body-bg-color: #fefefe;
  --accent-color: #2196f3;

  --debug-color: black;
  --debug-bg: greenyellow;

  --input-color: hsl(from var(--accent-color) h s calc(l * 1.5) / 1);

  --hr-color: #0000002b;
  --section-radius: 16px;
  --section-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --section-border: 1px solid #0000001a;
  --gap-section: 10px;
}

::selection {
  background-color: var(--yellow);
}

html {
  min-height: 100%;
  background-color: var(--body-bg-color);
}

body {
  max-width: 800px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 10px;
}

section {
  background-color: #fff;
  border-radius: var(--section-radius);
  border: var(--section-border);
  box-shadow: var(--section-shadow);
}

h1 {
  font-size: min(6cqw, 40px);
  margin: 10px 0;
}

b.highlight {
  color: #23c541;
}

hr {
  padding: 0;
  margin: 0;
  /* width: 100%; */
  border-width: 1px;
  /* border-style: dashed; */
  box-sizing: border-box;
  align-self: stretch;
  border-color: var(--hr-color);
}

/* ===== Animations ===== */

@keyframes updown {
  from {
    transform: translateY(-5%);
  }
  to {
    transform: translateY(5%);
  }
}

@keyframes rotleftright {
  from {
    rotate: -5deg;
  }
  to {
    rotate: 5deg;
  }
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ===== Common Components ===== */

.empty-loader {
  &:empty::after {
    content: "...";
    color: black;
    animation: fadeIn 400ms alternate infinite;
  }
}

.stat-sub {
  font-size: 13px;
  opacity: 0.5;
  font-style: italic;
  text-align: center;
}

.info-icon {
  color: #0000003d;
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
}

.result-stat {
  --color: white;

  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 600ms ease forwards;
  animation-delay: var(--delay, 0s);

  color: hsl(from var(--color) h s calc(l - 80));
  text-transform: capitalize;
  background-color: var(--color);
  border: 1px solid hsl(from var(--color) h s calc(l - 10));
  border-radius: 12px;
  box-shadow:
    0 2px 3px hsla(from var(--color) h s calc(l - 80) / 0.1),
    inset 0px 1px 2px 0px white;

  img.stat-icon {
    aspect-ratio: 1 / 1;
    width: 60px;
    object-fit: contain;
  }

  .stat-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.5;
    letter-spacing: 0.5px;
    opacity: 0.75;
  }

  .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.5;

    &.stat-revealed {
      animation: statReveal 400ms ease forwards;
    }
  }
}

/* ===== Feedback Section ===== */

.feedback-section {
  --pw: 15px;
  --red: #f44336;
  --white: #f2f2f2;
  --blue: #2196f3;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 30px 20px;
  margin-top: 30px;
  position: relative;

  background:
    linear-gradient(white, white),
    repeating-linear-gradient(
      -45deg,
      var(--red) calc(var(--pw) * 0),
      var(--red) calc(var(--pw) * 1),
      var(--white) calc(var(--pw) * 1),
      var(--white) calc(var(--pw) * 2),
      var(--blue) calc(var(--pw) * 2),
      var(--blue) calc(var(--pw) * 3),
      var(--white) calc(var(--pw) * 3),
      var(--white) calc(var(--pw) * 4)
    );
  background-origin: padding-box, border-box;
  background-repeat: no-repeat;
  border: 5px solid transparent;
  border-radius: var(--section-radius, 10px);
  box-shadow: var(--section-shadow);
  position: relative;

  fieldset {
    border: none;
    padding: 0;
    margin: 0;
    width: 100%;
    align-items: center;
  }
}

.feedback-bubble {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% -50%;
  display: flex;
  align-items: center;
  justify-content: center;
  img {
    width: 70px;
  }
}

.feedback-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.feedback-subtitle {
  font-size: 14px;
  opacity: 0.6;
  margin: 0;
}

.feedback-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.feedback-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: 12px;
  border: 2px solid #dde0e6;
  background: #f5f6f8;
  cursor: pointer;
  transition:
    border-color 150ms,
    background 150ms,
    translate 150ms,
    box-shadow 150ms;

  &:hover {
    translate: 0 -2px;
    background: #eceef2;
    box-shadow: 0 4px 10px #00000010;
  }

  &:has(input:checked) {
    border-color: var(--accent-color, #4a90d9);
    background: #e4ecfa;
    box-shadow: 0 0 0 2px hsl(from var(--accent-color, #4a90d9) h s l / 0.25);
  }

  input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
}

.feedback-option-emoji {
  font-size: 42px;
  line-height: 1;
}

.feedback-option-label {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.feedback-extra {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  animation: fadeInUp 300ms ease-out;

  textarea {
    width: 100%;
    border: 2px solid #e8eaf0;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;

    &:focus {
      outline: none;
      border-color: var(--accent-color, #4a90d9);
    }
  }
}

.feedback-send {
  align-self: flex-end;
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent-color, #4a90d9);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms;

  &:hover {
    opacity: 0.85;
  }
}

/* ===== Hero Section ===== */

.hero-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-section);
  margin: 0 0 var(--gap-section);
}

.result-hero {
  grid-column: span 3;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 30px;
}

.hero-brain {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;

  transition: filter 500ms ease-out;

  &.blurred {
    filter: blur(15px);
  }

  img {
    height: 100%;
    width: auto;
    max-width: 300px;
    object-fit: contain;
    animation:
      updown 2s ease-in-out infinite alternate,
      rotleftright 3s ease-in-out infinite alternate;
    transform-origin: center;
    filter: drop-shadow(0px 20px 9px #00000033);
  }

  .brain-label {
    position: absolute;
    width: 100px;
    text-align: center;
    rotate: -10deg;
    bottom: 0;
    opacity: 0.7;
    animation: updown 2s ease-in-out infinite alternate;

    &::after {
      content: "";
      width: 50px;
      height: 50px;
      display: block;
      position: absolute;
      top: 0;
      left: 80%;
      /* taken from: https://thenounproject.com/icon/up-hand-drawn-arrow-1563367/ */
      background-image: url(./images/up-hand-drawn-arrow.png);
      background-size: contain;
    }
  }
}

.hero-score {
  text-align: center;
}

.iq-score-text {
  position: relative;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.7;

  &::before,
  &::after {
    content: "✨";
    position: absolute;
    font-size: 2em;
  }

  &::before {
    right: 100%;
  }

  &::after {
    left: 100%;
  }
}

.iq-score-value {
  font-size: 100px;
  font-weight: 700;
  line-height: 1;
  margin: 4px 0;
}

.iq-score-cognitive {
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;

  --color: var(--green);
  color: hsl(from var(--color) h s calc(l - 20));
  background-color: hsl(from var(--color) h calc(s / 1.2) calc(l + 20));
}

.hero-description {
  font-size: 16px;
  opacity: 0.7;
  margin-top: 6px;
  text-align: center;
}

/* ===== Percentile Gauge ===== */

.percentile-gauge {
  width: 100%;
  max-width: 160px;
  margin: 0 auto;
}

.gauge-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 8;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: #4caf50;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 800ms ease;
}

.gauge-dot {
  fill: #7c4dff;
  transition:
    cx 800ms ease,
    cy 800ms ease;
}

.gauge-labels {
  font-size: 11px;
  opacity: 0.5;
  margin-top: -4px;
}

/* ===== Stats Row ===== */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-section);
  margin: 0 0 var(--gap-section);
  padding: 0;
  background: none;
  box-shadow: none;
  border: none;

  .result-stat {
    display: flex;
  }
}

/* ===== Chart + Type Row ===== */

#\$chartMain {
  height: 200px;
}

.chart-type-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-section);
  margin: 0 0 var(--gap-section);
}

.type-section {
  overflow: visible;
}

.type-illustration {
  flex-shrink: 0;
  align-self: flex-start;
  /* margin-top: -40px; */
  margin-right: -10px;

  img {
    width: 200px;
    height: auto;
  }
}

.type-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-color);
  line-height: 1.2;
}

.type-desc {
  font-size: 15px;
  line-height: 1.6;
  color: #444;
}

.type-body {
  flex: 1;
}

.type-motto {
  font-size: 15px;
  font-style: italic;
  color: var(--accent-color);
}

.type-tags {
  margin-top: auto;

  .tag {
    padding: 5px 14px;
    border: 2px solid;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    background-color: var(--color);
    border-color: hsl(from var(--color) h s calc(l - 10));
    color: hsl(from var(--color) h s calc(l - 60));
  }
}

/* ===== Smarter Section ===== */

.smarter-section {
  margin: 0 0 var(--gap-section);

  h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0 0 4px;
  }
}

.smarter-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-section);
  margin-top: 10px;
}

.smarter-card {
  position: relative;

  img {
    width: 60px;
  }

  .stat-value {
    font-size: 28px;
    font-weight: 700;
  }
}

.smarter-note {
  position: absolute;
  bottom: 105%;
  right: 10%;

  opacity: 0.7;

  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
  text-transform: none;
  text-shadow: none;

  &::after {
    content: "";
    width: 50px;
    height: 50px;
    display: block;
    position: absolute;
    top: -15%;
    right: 85%;
    rotate: 140deg;
    background-image: url(./images/up-hand-drawn-arrow.png);
    background-size: contain;
  }
}

/* ===== Actions Row ===== */

.actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-section);
  padding-top: 30px;

  background: none;
  box-shadow: none;
  border: none;
}

button.action-btn {
  --color: gray;

  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  padding: 14px;
  transition:
    box-shadow 200ms,
    translate 200ms,
    background-color 200ms;

  background-color: var(--color);
  color: white;
  text-shadow: 1px 1px 2px hsl(from var(--color) h s calc(l - 35));
  border: 2px solid hsl(from var(--color) h s calc(l + 15));
  box-shadow:
    0 0 2px 2px #00000030,
    inset 0 0 0 2px white;

  box-sizing: border-box;

  &:hover {
    translate: 0 -2px;
    box-shadow:
      0 4px 12px hsl(from var(--color) h s l / 0.4),
      0 0 2px 2px #00000020,
      inset 0 0 0 2px white;
  }
  &:active {
    translate: 0 0;
    background-color: hsl(from var(--color) h calc(s - 10) calc(l - 15));
  }

  strong {
    font-size: 13px;
    letter-spacing: 0.3px;
    font-weight: 700;
  }

  span {
    font-size: 12px;
    opacity: 0.6;
  }

  .btn-arrow {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;

    background: #00000018;
    border-radius: 50%;
    border: 2px solid hsl(from var(--color) h calc(s * 0.6) calc(l - 15));
    box-shadow: inset 0 0 0 1px white;

    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    opacity: 1;
  }
}

/* ===== Toast ===== */

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  translate: -50% 0;
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 3;
  animation: fadeInUp 300ms ease-out;
  pointer-events: none;
}

/* ===== Footer ===== */

footer {
  margin-top: 10px;

  hr {
    padding: 0;
    margin: 0;
    border-width: 1px;
    border-style: dashed;
    align-self: stretch;
    border-color: var(--hr-color);
  }

  nav.menu a {
    display: flex;
    text-transform: capitalize;
    text-decoration: none;
    color: var(--inactive-color, #999);

    &:hover {
      color: var(--accent-color);
    }
  }
}

/* ===== Mobile ===== */

@media (max-width: 700px) {
  body {
    padding: 6px;
  }

  .hero-row {
    grid-template-columns: 1fr;
  }

  .result-hero {
    grid-column: span 1;
    grid-template-columns: auto 1fr;
    padding: 20px;
    gap: 15px;
  }

  .hero-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  #\$chartMain {
    height: 180px;
  }

  .chart-type-row {
    grid-template-columns: 1fr;
  }

  .smarter-row {
    grid-template-columns: 1fr;
  }

  .actions-row {
    grid-template-columns: 1fr;

    .action-btn {
      flex-direction: row;
    }
  }
}
