/* Number Theory L1: Factor Quarry */

.factor-page {
  --factor-ink: #25221d;
  --factor-paper: #f7edd8;
  --factor-stone: #8e8b7d;
  --factor-slate: #4d5360;
  --factor-gold: #d5a84b;
  --factor-moss: #5d8b67;
  --factor-rust: #a85a3d;
  color: var(--factor-ink);
}

.factor-topbar {
  border-color: rgba(142, 139, 125, 0.32);
}

.factor-progressbar {
  background: rgba(247, 237, 216, 0.76);
  border: 1px solid rgba(77, 83, 96, 0.2);
  border-radius: 999px;
  height: 8px;
  margin: 0 auto 10px;
  max-width: 1180px;
  overflow: hidden;
}

.factor-progressbar span {
  background: linear-gradient(90deg, var(--factor-slate), var(--factor-gold), var(--factor-moss));
  display: block;
  height: 100%;
  transition: width 320ms ease;
}

.factor-progress {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin: 0 auto 12px;
}

.factor-progress__dot {
  background: rgba(37, 34, 29, 0.34);
  border: 1px solid rgba(247, 237, 216, 0.7);
  border-radius: 50%;
  height: 10px;
  width: 10px;
}

.factor-progress__dot.is-current {
  background: var(--factor-paper);
  box-shadow: 0 0 0 3px rgba(213, 168, 75, 0.22);
}

.factor-progress__dot.is-filled {
  background: var(--factor-gold);
  box-shadow: 0 0 12px rgba(213, 168, 75, 0.44);
}

.factor-room {
  margin: 0 auto;
  max-width: 1180px;
}

.factor-room__scene {
  background:
    radial-gradient(circle at 24% 18%, rgba(213, 168, 75, 0.26), transparent 24%),
    radial-gradient(circle at 82% 30%, rgba(93, 139, 103, 0.22), transparent 24%),
    linear-gradient(180deg, rgba(247, 237, 216, 0.1), rgba(37, 34, 29, 0.18)),
    url("../img/arena-numbertheory.jpg") center center / cover no-repeat;
  border: 1px solid rgba(247, 237, 216, 0.28);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(37, 34, 29, 0.34);
  height: min(740px, calc(100vh - 130px));
  min-height: 680px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.factor-room__scene::before {
  background:
    repeating-linear-gradient(90deg, rgba(247, 237, 216, 0.06) 0 1px, transparent 1px 72px),
    linear-gradient(180deg, rgba(20, 20, 20, 0.08), transparent 46%);
  content: "";
  inset: 0;
  position: absolute;
  z-index: 1;
}

.factor-room__scene::after {
  background:
    repeating-linear-gradient(90deg, rgba(37, 34, 29, 0.16) 0 4px, transparent 4px 44px),
    linear-gradient(180deg, #756a56, #3e372f);
  border-top: 1px solid rgba(247, 237, 216, 0.2);
  bottom: -58px;
  box-shadow: 0 -20px 45px rgba(37, 34, 29, 0.3);
  content: "";
  height: 210px;
  left: -3%;
  position: absolute;
  right: -3%;
  transform: skewY(-2deg);
  z-index: -1;
}

.factor-room__arches {
  display: flex;
  gap: 18px;
  left: 6%;
  position: absolute;
  top: 28px;
  z-index: 2;
}

.factor-room__arches span {
  background: linear-gradient(180deg, rgba(247, 237, 216, 0.52), rgba(77, 83, 96, 0.5));
  border: 1px solid rgba(255, 247, 228, 0.28);
  border-radius: 28px 28px 4px 4px;
  height: 90px;
  width: 44px;
}

.factor-room__lamps {
  inset: auto 5% 72px 5%;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.factor-room__lamps span {
  background: radial-gradient(circle, #fff6ca 0 35%, var(--factor-gold) 36% 58%, rgba(213, 168, 75, 0.08) 59%);
  border-radius: 50%;
  bottom: 0;
  box-shadow: 0 0 40px rgba(213, 168, 75, 0.5);
  height: 54px;
  position: absolute;
  width: 54px;
}

.factor-room__lamps span:first-child { left: 0; }
.factor-room__lamps span:last-child { right: 0; }

.factor-room__prompt {
  left: 50%;
  max-width: min(720px, 66%);
  position: absolute;
  text-align: center;
  text-shadow: 0 3px 10px rgba(20, 18, 16, 0.56);
  top: 3%;
  transform: translateX(-50%);
  z-index: 5;
}

.factor-room__prompt span,
.factor-shelf__title span,
.factor-stone-card > span,
.factor-tray__title span,
.factor-running-set span,
.factor-why span {
  color: rgba(255, 248, 228, 0.84);
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.factor-room__prompt h1 {
  color: #fff7df;
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 2.35vw, 2rem);
  line-height: 1.04;
  margin: 3px 0 0;
}

.factor-shelf {
  background: linear-gradient(180deg, rgba(37, 34, 29, 0.9), rgba(44, 40, 34, 0.88));
  border: 2px solid rgba(247, 237, 216, 0.32);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(28, 26, 22, 0.28);
  left: 4%;
  padding: 9px 12px;
  position: absolute;
  right: 4%;
  top: 13%;
  z-index: 4;
}

.factor-shelf__title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.factor-shelf__title strong {
  color: #fff2c8;
  font-size: 0.82rem;
}

.factor-shelf__rail {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.factor-shelf__slot {
  background: rgba(247, 237, 216, 0.08);
  border: 1px dashed rgba(247, 237, 216, 0.28);
  border-radius: 6px;
  display: grid;
  min-height: 74px;
  padding: 6px;
  place-items: center;
}

.factor-shelf__slot.is-current {
  border-color: rgba(213, 168, 75, 0.62);
}

.factor-shelf__slot.is-filled {
  animation: factorStoneArrive 420ms ease both;
  background: rgba(247, 237, 216, 0.16);
  border-style: solid;
}

.factor-snapshot {
  background:
    radial-gradient(circle at 50% 26%, rgba(255, 247, 212, 0.38) 0 18%, transparent 19%),
    linear-gradient(180deg, #b6b09d, #777365);
  border: 1px solid rgba(55, 48, 38, 0.34);
  border-radius: 6px 10px 7px 9px;
  box-shadow: 0 8px 14px rgba(28, 26, 22, 0.22);
  color: var(--factor-ink);
  display: grid;
  gap: 2px;
  min-height: 56px;
  min-width: 0;
  padding: 7px;
  text-align: center;
  width: 100%;
}

.factor-shelf__slot:not(.is-filled) .factor-snapshot {
  background: rgba(247, 237, 216, 0.08);
  box-shadow: none;
  color: rgba(255, 242, 212, 0.5);
}

.factor-snapshot span {
  font-size: 0.56rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.factor-snapshot strong {
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 1vw, 1rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.factor-steps {
  display: flex;
  gap: 8px;
  justify-content: center;
  left: 50%;
  position: absolute;
  top: 26%;
  transform: translateX(-50%);
  width: min(760px, 78%);
  z-index: 5;
}

.factor-step {
  background: rgba(247, 237, 216, 0.13);
  border: 1px solid rgba(247, 237, 216, 0.24);
  border-radius: 999px;
  color: rgba(255, 248, 228, 0.74);
  flex: 1;
  font-size: 0.66rem;
  font-weight: 900;
  min-height: 34px;
  padding: 9px 10px;
  text-align: center;
  text-transform: uppercase;
}

.factor-step--active {
  background: rgba(213, 168, 75, 0.92);
  color: #2b241d;
}

.factor-step--complete {
  background: rgba(93, 139, 103, 0.88);
  color: #f8f2df;
}

.factor-step--pending {
  opacity: 0.58;
}

.factor-workbench {
  bottom: 9%;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(210px, 0.82fr) minmax(0, 2.2fr) minmax(190px, 0.72fr);
  left: 5%;
  position: absolute;
  right: 5%;
  top: 33%;
  z-index: 5;
}

.factor-stone-card,
.factor-tray,
.factor-running-set {
  background: rgba(37, 34, 29, 0.82);
  border: 1px solid rgba(247, 237, 216, 0.24);
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(28, 26, 22, 0.28);
}

.factor-stone-card {
  align-content: start;
  color: #fff7df;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.factor-stone-card h1 {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  line-height: 1;
  margin: 0;
}

.factor-stone-card p {
  color: rgba(255, 248, 228, 0.82);
  line-height: 1.35;
  margin: 0;
}

.factor-number-stone {
  background:
    radial-gradient(circle at 45% 25%, rgba(255, 247, 212, 0.36) 0 17%, transparent 18%),
    linear-gradient(180deg, #b7b2a4, #6d695f);
  border: 3px solid rgba(255, 247, 212, 0.22);
  border-radius: 34% 42% 38% 36% / 32% 36% 42% 38%;
  box-shadow: inset 0 -16px 22px rgba(37, 34, 29, 0.22), 0 18px 26px rgba(28, 26, 22, 0.3);
  color: #26231e;
  display: grid;
  min-height: 170px;
  padding: 16px;
  place-items: center;
  text-align: center;
}

.factor-number-stone span {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.factor-number-stone strong {
  font-family: var(--font-display);
  font-size: clamp(4rem, 7vw, 6.5rem);
  line-height: 0.8;
}

.factor-main-panel {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 220px;
  min-height: 0;
}

.factor-tray {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  padding: 13px;
}

.factor-tray__title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.factor-tray__title strong {
  color: #fff2c8;
  font-size: 0.82rem;
}

.factor-tray__tiles {
  align-content: start;
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow-y: auto;
  padding-right: 4px;
}

.factor-tile {
  background: linear-gradient(180deg, #ede1c6, #b6ab93);
  border: 2px solid rgba(37, 34, 29, 0.22);
  border-radius: 7px;
  box-shadow: 0 7px 10px rgba(27, 25, 22, 0.22);
  color: var(--factor-ink);
  cursor: pointer;
  display: grid;
  min-height: 48px;
  padding: 6px;
  place-items: center;
  position: relative;
  transition: transform 140ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.factor-tile:hover:not(:disabled) {
  transform: translateY(-2px);
}

.factor-tile:disabled {
  cursor: default;
}

.factor-tile strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1;
}

.factor-tile span {
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.factor-tile.is-factor {
  background: linear-gradient(180deg, #f3d77f, #b9872c);
  border-color: rgba(255, 247, 212, 0.72);
  box-shadow: 0 8px 12px rgba(27, 25, 22, 0.24), 0 0 16px rgba(213, 168, 75, 0.36);
}

.factor-tile.is-crumble {
  background:
    linear-gradient(140deg, transparent 0 48%, rgba(110, 45, 31, 0.7) 49% 51%, transparent 52%),
    linear-gradient(180deg, #c99a86, #82513f);
  border-color: rgba(168, 90, 61, 0.8);
  color: #fff2e5;
}

.factor-side-panel {
  display: grid;
  gap: 12px;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
}

.factor-running-set {
  color: #fff7df;
  min-height: 0;
  padding: 14px;
}

.factor-running-set strong {
  color: #ffe29b;
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 1.8vw, 1.65rem);
  line-height: 1.08;
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.factor-running-set p,
.factor-running-set em {
  color: rgba(255, 248, 228, 0.84);
  display: block;
  font-size: 0.86rem;
  line-height: 1.28;
  margin: 0;
}

.factor-running-set em {
  color: #ffc3a9;
  font-style: normal;
  font-weight: 900;
  margin-top: 8px;
}

.factor-lock-panel {
  display: grid;
}

.factor-lock {
  background: linear-gradient(180deg, #6b665b, #34312c);
  border: 2px solid rgba(247, 237, 216, 0.28);
  border-radius: 8px;
  color: rgba(255, 248, 228, 0.7);
  cursor: default;
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 12px;
  place-items: center;
  text-align: center;
}

.factor-lock.is-ready {
  background: linear-gradient(180deg, #e4bc59, #785b22);
  border-color: rgba(255, 247, 212, 0.76);
  box-shadow: 0 0 20px rgba(213, 168, 75, 0.38);
  color: #241e18;
  cursor: pointer;
}

.factor-lock span {
  background:
    linear-gradient(90deg, transparent 0 42%, currentColor 43% 57%, transparent 58%),
    linear-gradient(0deg, transparent 0 42%, currentColor 43% 57%, transparent 58%);
  border: 2px solid currentColor;
  border-radius: 50%;
  height: 42px;
  opacity: 0.72;
  width: 42px;
}

.factor-lock strong {
  font-family: var(--font-display);
  font-size: 1rem;
}

.factor-solen {
  align-self: end;
  color: #fff7df;
  min-height: 260px;
  position: relative;
}

.factor-solen__head {
  background: #bd815c;
  border-radius: 42% 42% 48% 48%;
  height: 50px;
  left: 50%;
  position: absolute;
  top: 38px;
  transform: translateX(-50%);
  width: 44px;
  z-index: 3;
}

.factor-solen__head span {
  background: #3d3027;
  border-radius: 12px 12px 5px 5px;
  height: 16px;
  left: -2px;
  position: absolute;
  right: -2px;
  top: -4px;
}

.factor-solen__body {
  background: linear-gradient(180deg, #705f43, #3f362e);
  border-radius: 24px 24px 10px 10px;
  height: 110px;
  left: 50%;
  position: absolute;
  top: 84px;
  transform: translateX(-50%);
  width: 68px;
  z-index: 2;
}

.factor-solen__arm {
  background: rgba(255, 235, 198, 0.86);
  border-radius: 999px;
  height: 9px;
  position: absolute;
  top: 118px;
  width: 58px;
  z-index: 3;
}

.factor-solen__arm--left {
  left: 44px;
  transform: rotate(-26deg);
}

.factor-solen__arm--right {
  right: 44px;
  transform: rotate(28deg);
}

.factor-solen__mallet {
  background: linear-gradient(180deg, #7b5133, #3d271b);
  border-radius: 7px;
  height: 24px;
  left: 24px;
  position: absolute;
  top: 94px;
  transform: rotate(-20deg);
  width: 58px;
  z-index: 4;
}

.factor-solen__mallet::after {
  background: #5c432e;
  border-radius: 999px;
  content: "";
  height: 70px;
  left: 30px;
  position: absolute;
  top: 16px;
  width: 8px;
}

.factor-solen__bubble {
  background: rgba(255, 248, 228, 0.96);
  border: 1px solid rgba(213, 168, 75, 0.32);
  border-radius: 8px;
  box-shadow: 0 14px 26px rgba(26, 23, 20, 0.26);
  color: var(--factor-ink);
  font-weight: 800;
  line-height: 1.25;
  padding: 12px 14px;
  position: absolute;
  right: 0;
  top: 0;
  width: min(230px, 100%);
  z-index: 5;
}

.factor-why {
  background: rgba(255, 248, 228, 0.13);
  border: 1px solid rgba(255, 248, 228, 0.18);
  border-radius: 8px;
  margin: 10px 0;
  padding: 10px 12px;
}

.factor-why p {
  color: #fff7df;
  line-height: 1.32;
  margin: 3px 0 0;
}

.factor-celebration {
  background: rgba(37, 34, 29, 0.92);
  border: 1px solid rgba(213, 168, 75, 0.42);
  border-radius: 8px;
  bottom: 22px;
  box-shadow: 0 18px 34px rgba(26, 23, 20, 0.38);
  color: #fff7df;
  left: 50%;
  max-width: min(720px, 78%);
  padding: 14px 18px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  z-index: 14;
}

.factor-celebration > strong {
  color: #ffe29b;
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  line-height: 1.05;
}

.factor-celebration > span {
  color: rgba(255, 248, 228, 0.78);
  display: block;
  font-size: 0.82rem;
  font-weight: 900;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.factor-reward {
  display: grid;
  inset: 0;
  padding: 26px;
  place-items: center;
  position: absolute;
  z-index: 10;
}

.factor-reward__card {
  background: linear-gradient(180deg, rgba(37, 34, 29, 0.94), rgba(52, 47, 39, 0.94));
  border: 1px solid rgba(213, 168, 75, 0.42);
  border-radius: 8px;
  box-shadow: 0 24px 50px rgba(26, 23, 20, 0.4);
  color: #fff7df;
  display: grid;
  gap: 16px;
  max-height: 100%;
  max-width: 900px;
  overflow-y: auto;
  padding: 24px;
  text-align: center;
  width: min(900px, 100%);
}

.factor-reward__copy span {
  color: rgba(255, 248, 228, 0.7);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.factor-reward__copy h2 {
  color: #ffe29b;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.96;
  margin: 4px 0 6px;
}

.factor-reward__copy p {
  margin: 0;
}

.factor-reward__stones {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.factor-reward__stones .factor-snapshot {
  min-height: 90px;
}

.factor-reward__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.factor-reward__badges span {
  background: rgba(255, 248, 228, 0.12);
  border: 1px solid rgba(255, 248, 228, 0.18);
  border-radius: 999px;
  color: #fff2c8;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 8px 11px;
}

.factor-reward__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.factor-reward .reward-stars {
  color: rgba(255, 255, 255, 0.28);
  font-size: 1.8rem;
}

.factor-reward .reward-stars span.is-filled {
  color: var(--factor-gold);
}

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

@media (max-width: 980px) {
  .factor-room__scene {
    height: auto;
    min-height: 900px;
    overflow-y: auto;
  }

  .factor-workbench {
    grid-template-columns: 1fr;
    position: relative;
    inset: auto;
    margin: 250px 20px 30px;
  }

  .factor-main-panel {
    grid-template-columns: 1fr;
  }

  .factor-solen {
    display: none;
  }
}

@media (max-width: 720px) {
  .factor-shelf__rail,
  .factor-reward__stones {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .factor-steps {
    flex-direction: column;
    top: 24%;
  }

  .factor-tray__tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .factor-room__prompt {
    max-width: calc(100% - 28px);
  }
}
