/* ==========================================================
   support.css - Full Revisi Responsive Lebih Besar
   Untuk halaman lucky wheel / spin
   Responsive Desktop, Tablet, Mobile tanpa bantuan JS - ukuran wheel diperbesar
   ========================================================== */

:root {
  --page-bg: #000;
  --text: #ffffff;
  --gold: #ffd85a;
  --gold-2: #ffb300;
  --gold-soft: rgba(255, 216, 90, 0.35);
  --panel-bg: rgba(0, 0, 0, 0.42);
  --panel-border: rgba(255, 215, 0, 0.55);
  --shadow-dark: rgba(0, 0, 0, 0.45);
  --shadow-gold: rgba(255, 180, 0, 0.25);

  /* Ukuran utama akan otomatis menyesuaikan viewport */
  --stage-padding-x: clamp(8px, 2vw, 24px);
  --stage-padding-y: clamp(8px, 2vh, 22px);
  --container-width: clamp(340px, 96vw, 680px);
  --container-radius: clamp(12px, 2vw, 22px);
  --container-padding: clamp(12px, 2.4vw, 28px);
  --wheel-size: clamp(320px, min(88vw, 70svh), 580px);
  --input-height: clamp(42px, 4.8vw, 48px);
  --spin-size: clamp(92px, 15vw, 130px);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: auto !important;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  height: auto !important;
  min-height: 100svh;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  color: var(--text);
  background-color: var(--page-bg);
  background-image: url('./background1.jpg');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

img,
canvas {
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* Wrapper utama halaman */
.desktop-stage {
  width: 100% !important;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--stage-padding-y) var(--stage-padding-x);

  /* Override aman jika autoZoom.js masih termuat di index.php */
  position: relative !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  transform-origin: center !important;
  will-change: auto !important;
}

/* Container utama wheel */
.wheel-container {
  width: var(--container-width);
  max-width: calc(100vw - (var(--stage-padding-x) * 2));
  margin: 0 auto;
  padding: var(--container-padding);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.8vh, 16px);
  position: relative;
  isolation: isolate;
  border-radius: var(--container-radius);
  background-color: rgba(0, 0, 0, 0.74);
  background-image: url('./bginti1.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.52),
    inset 0 0 28px rgba(255, 255, 255, 0.06);
}

.neon-container {
  width: var(--container-width);
  max-width: calc(100vw - (var(--stage-padding-x) * 2));
}

/* Neon border */
.neon-container::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--container-radius) + 2px);
  background: linear-gradient(45deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
  background-size: 400%;
  z-index: -1;
  animation: neon-border 8s linear infinite;
  filter: blur(5px);
  opacity: 0.68;
  pointer-events: none;
}

.neon-container::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--container-radius);
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

@keyframes neon-border {
  0% {
    background-position: 0 0;
  }
  50% {
    background-position: 300% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.neon-text {
  text-shadow:
    0 0 5px #fff,
    0 0 10px #fff,
    0 0 20px #ff00ff,
    0 0 30px #ff00ff;
}

/* Form username dan tiket */
.form-on-hero {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
}

.ticket-panel {
  width: min(100%, 390px);
  padding: clamp(10px, 2.4vw, 14px);
  border-radius: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 8px 20px var(--shadow-dark),
    0 0 30px var(--shadow-gold);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  text-align: center;
}

.ticket-input {
  display: block;
  width: 100%;
  height: var(--input-height);
  margin: 8px auto;
  padding: 0 clamp(12px, 3vw, 16px);
  border-radius: 999px;
  border: 1.5px solid rgba(255, 196, 0, 0.9);
  outline: none;
  background:
    linear-gradient(180deg, rgba(255, 220, 120, 0.18), rgba(255, 160, 0, 0.08)),
    rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.15),
    0 2px 10px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 170, 0, 0.6);
  color: #fff;
  font: 700 clamp(14px, 2vw, 15px)/1.2 Arial, Helvetica, sans-serif;
  text-align: center;
}

.ticket-input::placeholder {
  color: rgba(255, 255, 255, 0.82);
}

.ticket-input:focus {
  border-color: var(--gold);
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.2),
    0 6px 16px rgba(0, 0, 0, 0.45),
    0 0 0 3px var(--gold-soft);
}

input[type='hidden'].ticket-input {
  display: none;
}

/* Pesan validasi / informasi */
.message {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 10px 12px;
  border-radius: 10px;
  display: none;
  font-size: clamp(13px, 2vw, 14px);
  line-height: 1.4;
}

.error {
  background-color: #ffebee;
  color: #d32f2f;
  border: 1px solid #ef9a9a;
}

.info {
  background-color: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

/* Area wheel */
.canvas-container {
  position: relative;
  width: var(--wheel-size);
  height: var(--wheel-size);
  margin: 0 auto;
  flex: 0 0 auto;
}

.canvas-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url('./wheel_back2.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 3;
  pointer-events: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 6.5%;
  position: relative;
  z-index: 2;
  background-color: transparent;
}

/* Tombol spin */
#spin_button {
  width: var(--spin-size);
  height: auto;
  display: block;
  flex: 0 0 auto;
  cursor: pointer;
  margin: clamp(2px, 1vh, 10px) auto 0;
  transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-drag: none;
}

#spin_button:hover {
  transform: scale(1.05);
  filter: brightness(1.06);
}

#spin_button:active {
  transform: scale(0.96);
}

#spin_button[disabled] {
  opacity: 0.8;
}

.clickable {
  cursor: pointer;
}

.prize-display {
  width: min(100%, 520px);
  margin: 0 auto;
  color: #fff;
  font-size: clamp(14px, 2.2vw, 16px);
  line-height: 1.45;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.debug {
  width: min(100%, 520px);
  margin-top: 8px;
  padding: 10px;
  border-radius: 8px;
  display: none;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  background-color: rgba(245, 245, 245, 0.94);
  color: #111;
  overflow-x: auto;
}

/* Popup overlay */
.popup-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-container {
  width: min(100%, 760px);
  animation: popupScale 0.4s ease-out;
}

.popup-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 90svh;
  margin: 0 auto;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

@keyframes popupScale {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================
   Desktop besar
   ========================= */
@media (min-width: 1200px) {
  :root {
    --container-width: min(94vw, 700px);
    --wheel-size: clamp(520px, min(46vw, 72svh), 610px);
    --spin-size: clamp(118px, 9vw, 138px);
  }
}

@media (min-width: 1440px) {
  :root {
    --container-width: min(92vw, 760px);
    --wheel-size: clamp(580px, min(43vw, 74svh), 660px);
    --spin-size: clamp(126px, 8vw, 148px);
  }
}

/* =========================
   Desktop kecil / laptop
   ========================= */
@media (min-width: 1025px) and (max-width: 1199px) {
  :root {
    --container-width: min(94vw, 650px);
    --wheel-size: clamp(500px, min(50vw, 70svh), 560px);
    --spin-size: clamp(110px, 10vw, 130px);
  }
}

/* =========================
   Tablet landscape / portrait
   ========================= */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --stage-padding-x: 14px;
    --stage-padding-y: 14px;
    --container-width: min(96vw, 640px);
    --container-padding: clamp(14px, 2.6vw, 24px);
    --wheel-size: clamp(460px, min(82vw, 66svh), 560px);
    --spin-size: clamp(104px, 13vw, 126px);
  }

  .ticket-panel {
    width: min(100%, 370px);
  }
}

/* =========================
   Mobile besar
   ========================= */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --stage-padding-x: 8px;
    --stage-padding-y: 10px;
    --container-width: min(98vw, 560px);
    --container-padding: clamp(10px, 2.8vw, 16px);
    --wheel-size: min(92vw, 62svh, 500px);
    --input-height: 44px;
    --spin-size: clamp(96px, 19vw, 116px);
  }

  body {
    background-position: center top;
  }

  .wheel-container {
    gap: 9px;
  }

  .ticket-panel {
    width: min(100%, 360px);
  }
}

/* =========================
   Mobile kecil
   ========================= */
@media (max-width: 480px) {
  :root {
    --stage-padding-x: 4px;
    --stage-padding-y: 6px;
    --container-width: calc(100vw - 8px);
    --container-padding: 8px;
    --container-radius: 14px;
    --wheel-size: min(92vw, 60svh, 430px);
    --input-height: 41px;
    --spin-size: clamp(86px, 22vw, 104px);
  }

  body {
    background-position: center top;
  }

  .desktop-stage {
    align-items: start;
  }

  .wheel-container {
    gap: 7px;
    min-height: auto;
  }

  .ticket-panel {
    width: min(100%, 350px);
    padding: 9px 10px;
    border-radius: 15px;
  }

  .ticket-input {
    margin: 6px auto;
    font-size: 14px;
  }

  .message,
  .prize-display {
    font-size: 13px;
  }
}

/* =========================
   Layar sangat kecil
   ========================= */
@media (max-width: 360px) {
  :root {
    --wheel-size: min(92vw, 58svh, 338px);
    --spin-size: 82px;
  }

  .ticket-panel {
    width: min(100%, 320px);
  }

  .ticket-input {
    height: 38px;
    padding-inline: 10px;
  }
}

/* =========================
   Perbaikan untuk layar pendek
   ========================= */
@media (max-height: 720px) {
  :root {
    --stage-padding-y: 6px;
    --container-padding: clamp(8px, 1.8vh, 14px);
    --wheel-size: min(88vw, 66svh, 540px);
    --spin-size: clamp(84px, 18vh, 118px);
  }

  .wheel-container {
    gap: 6px;
  }

  .ticket-panel {
    padding-block: 8px;
  }

  .ticket-input {
    margin-block: 5px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  :root {
    --container-width: min(98vw, 920px);
    --wheel-size: clamp(270px, 68vh, 420px);
    --spin-size: clamp(80px, 17vh, 104px);
  }

  .wheel-container {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    grid-template-areas:
      'form wheel'
      'message wheel'
      'spin wheel'
      'result wheel'
      'debug wheel';
    column-gap: clamp(12px, 3vw, 30px);
    row-gap: 6px;
    align-items: center;
  }

  .form-on-hero {
    grid-area: form;
  }

  .message {
    grid-area: message;
  }

  .canvas-container {
    grid-area: wheel;
  }

  #spin_button {
    grid-area: spin;
  }

  .prize-display {
    grid-area: result;
  }

  .debug {
    grid-area: debug;
  }
}

/* Aksesibilitas: kurangi animasi jika user mengaktifkan reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
