/* Light */
@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-LightItalic.otf') format('opentype');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

/* Regular */
@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-RegularItalic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* Medium */
@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-MediumItalic.otf') format('opentype');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

/* Bold */
@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'LemonMilk';
  src: url('./lemon_milk/LEMONMILK-BoldItalic.otf') format('opentype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --hud-bg: rgba(255, 255, 255, 0.75);
  --hud-bg-pressed: rgba(205, 205, 205, 0.75);
  --hud-border: rgba(255, 255, 255, 0.3);
}

.noselect {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html,
body {
  font-family: 'LemonMilk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.4;
}

html,
body {
  margin: 0;
  padding: 0;
  /* no scrollbars */
  height: 100%;
}

canvas {
  display: block;
  /* remove inline spacing */
  width: 100%;
  height: 100%;
}

h1,
h2,
h3 {
  font-weight: 700;
  /* Bold */
}

.small-text {
  font-weight: 300;
  /* Light */
}

em {
  font-style: italic;
}

strong em {
  font-weight: 700;
  font-style: italic;
}

#hud-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(60, 60, 60, 0.85);
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 0 5px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.25s ease, transform 0.3s ease;
  font-size: 24px;
  color: #f5f5f5;
}

#hud-toggle:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 10px rgba(0, 200, 255, 0.4), inset 0 0 6px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

#hud-toggle:active {
  transform: scale(0.95);
  background: rgba(70, 70, 70, 0.95);
}

#hud-toggle.open {
  transform: rotate(90deg);
}

@media (min-width: 768px) {
  #hud-toggle {
    bottom: inherit;
    right: inherit;
    top: 26px;
    left: 26px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}

/* HUD Panel Backdrop */
#hud-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#hud-panel.open~#hud-backdrop {
  opacity: 1;
  pointer-events: all;
}

@media (min-width: 768px) {
  #hud-toggle {
    transition: transform 0.075s ease-in;
  }

  #hud-toggle.open {
    transform: translateX(221px) rotate(90deg);

    transition: transform 0.325s ease 0.175s;
  }
}

/* HUD Panel */
#hud-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  padding: 24px;
  background: rgba(50, 50, 50, 0.85);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(100%);
  transition: transform 0.5s ease, box-shadow 0.5s ease;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 0 8px rgba(255, 255, 255, 0.05);
  color: white;
}

#hud-panel.open {
  transform: translateY(0);
}

/* Desktop Version */
@media (min-width: 768px) {
  #hud-panel {
    transform: translateX(-220%);
    max-height: 90vh;
    width: 220px;
    top: 20px;
    left: 20px;
    right: auto;
    bottom: auto;
    border-radius: 16px;
    overflow-x: auto;
    border: solid thin rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(255, 255, 255, 0.08);
  }

  #hud-panel.open {
    transform: translateX(0);
  }
}

/* HUD Grabber */
#hud-grabber {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  margin: 8px auto 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease;
}

#hud-grabber:hover {
  background: rgba(255, 255, 255, 0.35);
}

@media (min-width: 768px) {
  #hud-grabber {
    display: none;
  }
}

/* HUD Content Styling */
#hud-panel h2 {
  margin: 0 0 16px;
  font-size: 20px;
  color: #f5f5f5;
}

section label {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  font-size: 14px;
  color: #f8f8f8;
}

input[type="range"] {
  height: 44px;
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.material-section,
.light-section {
  display: flex;
  flex-direction: column;
  gap: 0px;
  padding: 20px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.material-section {
  font-size: 0.6em;
  background: rgba(255, 255, 255, 0.05);
}

.light-section {
  font-size: 0.8em;
  background: rgba(255, 255, 255, 0.08);
}

.section-title {
  font-weight: bold;
  font-size: 1.4em;
  margin-bottom: 10px;
}

input.compressed-slider {
  height: 20px;
}

#hud-toggle .icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#hud-toggle .close {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-90deg);
}

#hud-toggle.open .menu {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

@media (min-width: 768px) {
  #hud-toggle .icon {
    transform: translate(-50%, calc(-50% - 2px));
  }
}

#hud-toggle.open .close {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(0deg);
}

@media (min-width: 768px) {
  #hud-toggle.open .close {
    transform: translate(calc(-50% + 0px), calc(-50% - 1.5px)) rotate(0deg);
  }
}

#hud-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

@media (min-width: 768px) {
  #hud-backdrop {
    backdrop-filter: inherit;
  }
}

#hud-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.attribute-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.grid-item-label {
  min-width: 100px;
  font-weight: 500;
}

.falloff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  grid-column: 1 / -1;
}

.grid-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (min-width: 768px) {
  .attribute-grid {
    grid-template-columns: 1fr;
  }

  .grid-item-label {
    min-width: 80px;
    font-size: 0.75em;
  }

  .falloff-grid {
    grid-template-columns: 1fr;
    grid-column: inherit;
  }

  .grid-row {
    max-width: 90%;
  }
}

#ml-denoise-toggle {
  position: fixed;
  right: 16px;
  top: 16px;

  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;

  border: none;
  background: rgba(60, 60, 60, 0.8);
  /* brighter for black bg */
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 0 5px rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  cursor: pointer;
  padding: 0 14px;

  height: 44px;
  width: 220px;

  font-size: 16px;
  color: #f5f5f5;
  transition: all 0.25s ease;
}

#ml-denoise-toggle:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 10px rgba(57, 193, 23, 0.5), inset 0 0 6px rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

#ml-denoise-toggle:active {
  background: rgba(70, 70, 70, 0.9);
  transform: scale(0.97);
}

#ml-denoise-toggle .text {
  flex: 1;
  font-size: 0.95em;
  transition: opacity 0.3s ease;
  color: #f8f8f8;
}

#ml-denoise-toggle .text.enabled {
  display: none;
}

#ml-denoise-toggle.enabled .text.enabled {
  display: block;
}

#ml-denoise-toggle.enabled .text.disabled {
  display: none;
}

#ml-denoise-toggle .checkmark {
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  font-weight: bold;
  color: #39C117;
  text-shadow: 0 0 6px #39C117;
  background: rgba(80, 80, 80, 0.6);
  box-shadow: inset 0px 0px 6px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
  opacity: 0;
}

#ml-denoise-toggle.enabled .checkmark {
  opacity: 1;
}

@media (min-width: 768px) {
  #ml-denoise-toggle {
    right: 26px;
    top: 26px;
  }
}

.dropdown {
  display: flex;
  flex-direction: column;
  font-family: sans-serif;
  font-size: 14px;
  color: #f5f5f5;
  margin-bottom: 16px;

  position: fixed;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  /* make sure it’s above HUD panel */
}

.dropdown label {
  margin-bottom: 6px;
  font-weight: bold;
  font-size: 0.9em;
}

/* Dropdown Select Box */
.dropdown-select {
  position: fixed;
  width: 220px;
  top: 40px;
  left: -16px;
  background: rgba(60, 60, 60, 0.85);
  backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 0 6px rgba(255, 255, 255, 0.05);
  transition: all 0.25s ease, transform 0.2s ease;

  display: flex;
  align-items: center;
  /* vertical centering */
  justify-content: space-between;
  /* text left, arrow right */
}

@media (min-width: 768px) {
  .dropdown-select {
    position: relative;
    top: initial;
    left: initial;
  }
}

.dropdown-select:hover {
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(57, 193, 23, 0.4),
    inset 0 0 8px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* Selected text */
.dropdown-select .selected {
  flex: 1;
  /* expand to full width */
  user-select: none;
  /* prevent text selection on click */
}

/* Arrow indicator */
.dropdown-select::after {
  content: "▾";
  margin-left: 8px;
  font-size: 0.8em;
  color: #f5f5f5;
  pointer-events: none;
  /* allow clicks through arrow */
}

/* Options Panel */
.dropdown-select .options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(50, 50, 50, 0.9);
  backdrop-filter: blur(16px);
  border-radius: 14px;
  margin-top: 6px;
  list-style: none;
  padding: 4px;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.25s ease;
  z-index: 300;
}

/* Show options */
.dropdown-select.open .options {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Option Items */
.dropdown-select .options li {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  border-radius: 12px;
}

.dropdown-select .options li:hover {
  background: rgba(57, 193, 23, 0.25);
  box-shadow: 0 0 3px rgba(57, 193, 23, 0.5);
}

/* Selected glow when dropdown is open */
.dropdown-select.open .selected {
  box-shadow: 0 0 6px rgba(57, 193, 23, 0.5);
  border-radius: 16px;
}

a {
  color: rgb(42, 121, 22);
  text-decoration: underline;
  transition: all 0.2s ease;
}

/* Keep the same color when hovered or visited */
a:visited {
  color: rgb(42, 121, 22);
}

a:hover {
  color: rgb(60, 169, 32);
}

a:active {
  color: rgb(28, 77, 16);
}

a.credits-link {
  position: fixed;
  bottom: 10px;
  left: 10px;
  font-weight: normal;
  font-family: 'LEMONMILK', sans-serif;
  font-size: 10px;
  z-index: 1000;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(40, 40, 40, 0.85);
  /* semi-transparent dark */
  backdrop-filter: blur(12px);
  /* HUD-like blur */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(57, 193, 23, 0.15);
  z-index: 1000;
  transition: all 0.25s ease, transform 0.2s ease;
}

#download-button {
  border: none;
  color: rgb(42, 121, 22);
  position: fixed;
  bottom: 10px;
  left: 100px;
  font-weight: normal;
  font-family: 'LEMONMILK', sans-serif;
  font-size: 10px;
  z-index: 1000;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(40, 40, 40, 0.85);
  /* semi-transparent dark */
  backdrop-filter: blur(12px);
  /* HUD-like blur */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(57, 193, 23, 0.15);
  z-index: 1000;
  transition: all 0.25s ease, transform 0.2s ease;
}

@media (min-width: 768px) {
  a.credits-link {
    left: inherit;
    right: 10px;
  }

  #download-button {
    left: inherit;
    right: 100px;
  }
}

a.credits-link:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 12px rgba(57, 193, 23, 0.6), inset 0 0 6px rgba(57, 193, 23, 0.2);
  transform: translateY(-2px);
}

#download-button:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 12px rgba(57, 193, 23, 0.6), inset 0 0 6px rgba(57, 193, 23, 0.2);
  transform: translateY(-2px);
  color: rgb(60, 169, 32);
}

#download-button:active {
  color: rgb(28, 77, 16);
}

.credits-container {
  max-width: 600px;
  width: 90%;
  padding: 24px;
  border-radius: 20px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(57, 193, 23, 0.1);
  text-align: left;
  color: #f5f5f5;
}

a.back-button {
  font-weight: normal;
  font-family: 'LEMONMILK', sans-serif;
  font-size: 10px;
  z-index: 1000;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(40, 40, 40, 0.85);
  /* semi-transparent dark */
  backdrop-filter: blur(12px);
  /* HUD-like blur */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(57, 193, 23, 0.15);
  z-index: 1000;
  transition: all 0.25s ease, transform 0.2s ease;
}

a.back-button:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 12px rgba(57, 193, 23, 0.6), inset 0 0 6px rgba(57, 193, 23, 0.2);
  transform: translateY(-2px);
}

:root {
  --ring-circumference: 138.23;
  /* 2 * PI * 22 */
}

.hud-spinner {
  /* Positioning & Glassmorphism */
  position: absolute;
  bottom: 16px;
  right: 88px;
  width: 56px;
  height: 56px;
  background: rgba(40, 40, 40, 0.75);
  backdrop-filter: blur(12px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Visibility State */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.hud-spinner.is-active {
  opacity: 1;
  visibility: visible;
}

.ring-svg {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 4;
}

.ring-arc {
  fill: none;
  stroke: #39c117;
  stroke-width: 4;
  stroke-linecap: round;

  /* Progress Math */
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: calc(var(--ring-circumference) - (var(--progress, 0) * var(--ring-circumference)));
  transition: stroke-dashoffset 0.3s ease, stroke-dasharray 0.3s ease;
}

/* Indeterminate "Winning" State */
.hud-spinner.is-indeterminate .ring-arc {
  animation: hud-chase 1.5s ease-in-out infinite;
  transition: none;
  /* Prevents stutter when switching from progress to spin */
}

@keyframes hud-chase {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -138;
  }
}

@media (min-width: 768px) {
  .hud-spinner {
    bottom: inherit;
    right: inherit;
    top: 26px;
    left: 78px;
    width: 36px;
    height: 36px;
  }
}

img-compare {
  display: block;
  position: relative;
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  background: #ddd;
  margin: 0 auto;
}

img-compare img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

img-compare .ic-after {
  position: absolute;
  inset: 0;
}

img-compare .ic-before {
  position: relative;
  z-index: 1;
  clip-path: inset(0 50% 0 0);
}

img-compare .ic-line {
  position: absolute;
  inset: 0;
  left: 50%;
  width: 1px;
  background: #fff;
  z-index: 2;
  pointer-events: none;
  transform: translateX(-50%);
}

img-compare .ic-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}