:root {
  --ink: #0a0806;
  --ink-2: #140f0a;
  --amber: #c9a961;
  --amber-dim: #8b6f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #050403;
  overflow: hidden;
  color: #e8ddc8;
}

body {
  font-family: "Vazirmatn", sans-serif;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

/* ---- Stage ---- */
.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, #1a130c 0%, #0a0705 60%, #030201 100%);
}

/* ---- Hero image ---- */
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 1.4s ease;
  z-index: 1;
}

.kenburns {
  animation: kenburns 34s ease-in-out infinite alternate;
  transform-origin: 55% 45%;
}

@keyframes kenburns {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.09) translate(-1.5%, -1%);
  }
}

/* ---- Overlays ---- */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(3, 2, 1, 0.55) 0%, rgba(3, 2, 1, 0.05) 30%, rgba(3, 2, 1, 0.15) 55%, rgba(3, 2, 1, 0.85) 100%),
    radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(3, 2, 1, 0.7) 100%);
}

.grain {
  position: absolute;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(3) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -2%); }
  100% { transform: translate(0, 0); }
}

/* ---- Loading ---- */
.loading-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #120d08 0%, #050403 80%);
}

.ember-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(201, 169, 97, 0.15);
  border-top-color: var(--amber);
  animation: spin 1.1s linear infinite;
  box-shadow: 0 0 20px rgba(201, 169, 97, 0.3);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Poem overlay ---- */
.poem-overlay {
  position: absolute;
  z-index: 4;
  bottom: 12vh;
  right: 7vw;
  left: 7vw;
  text-align: right;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 2s ease, transform 2s ease;
  pointer-events: none;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.8);
}

.poem-in {
  opacity: 1;
  transform: translateY(0);
}

.poem-title {
  font-family: "Noto Nastaliq Urdu", "Amiri", serif;
  font-size: clamp(2.8rem, 9vw, 6.5rem);
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.2em;
}

.poem-translit {
  font-family: "Vazirmatn", sans-serif;
  font-weight: 100;
  font-size: clamp(0.7rem, 2vw, 1rem);
  letter-spacing: 0.35em;
  color: rgba(232, 221, 200, 0.55);
  text-transform: uppercase;
  direction: ltr;
  text-align: right;
  margin-bottom: 1.6em;
}

.poem-verses {
  max-width: 40ch;
  margin-right: 0;
}

.verse {
  font-family: "Amiri", serif;
  font-size: clamp(1rem, 2.6vw, 1.55rem);
  line-height: 2.1;
  color: rgba(232, 221, 200, 0.9);
  margin: 0;
  opacity: 0;
  transform: translateY(14px);
  animation: verseIn 1.6s ease forwards;
}

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

/* ---- Control panel ---- */
.panel {
  position: absolute;
  z-index: 6;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.panel-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(201, 169, 97, 0.4);
  background: rgba(20, 15, 10, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-toggle:hover {
  background: rgba(30, 22, 14, 0.9);
  box-shadow: 0 0 18px rgba(201, 169, 97, 0.25);
}

.panel-body {
  background: rgba(14, 10, 6, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(201, 169, 97, 0.18);
  border-radius: 14px;
  padding: 18px;
  width: 240px;
  animation: panelIn 0.5s ease;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: rgba(232, 221, 200, 0.5);
  margin-bottom: 10px;
  font-weight: 300;
}

.mood-row {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.mood-pill {
  flex: 1;
  padding: 7px 4px;
  font-family: "Vazirmatn", sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  border-radius: 8px;
  border: 1px solid rgba(232, 221, 200, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: rgba(232, 221, 200, 0.65);
  cursor: pointer;
  transition: all 0.35s ease;
}

.mood-pill:hover {
  border-color: rgba(201, 169, 97, 0.5);
  color: var(--amber);
}

.mood-active {
  background: rgba(201, 169, 97, 0.12);
  font-weight: 700;
}

.btn-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl-btn {
  font-family: "Vazirmatn", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid rgba(201, 169, 97, 0.45);
  background: linear-gradient(180deg, rgba(201, 169, 97, 0.16), rgba(201, 169, 97, 0.06));
  color: var(--amber);
  cursor: pointer;
  transition: all 0.35s ease;
}

.ctrl-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(201, 169, 97, 0.3), rgba(201, 169, 97, 0.12));
  box-shadow: 0 0 20px rgba(201, 169, 97, 0.25);
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ctrl-btn.ghost {
  border-color: rgba(232, 221, 200, 0.18);
  background: transparent;
  color: rgba(232, 221, 200, 0.6);
}

.ctrl-btn.ghost:hover:not(:disabled) {
  color: var(--amber);
  border-color: rgba(201, 169, 97, 0.4);
  box-shadow: none;
}

.ctrl-btn.small {
  font-size: 0.75rem;
  padding: 7px 10px;
}

.prompt-box {
  margin-top: 12px;
  font-family: "Vazirmatn", monospace;
  direction: ltr;
  text-align: left;
  font-size: 0.62rem;
  line-height: 1.6;
  color: rgba(232, 221, 200, 0.45);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(201, 169, 97, 0.1);
  border-radius: 8px;
  padding: 10px;
  max-height: 130px;
  overflow-y: auto;
}

/* ---- Toast ---- */
.toast {
  position: absolute;
  z-index: 8;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Amiri", serif;
  font-size: 1.05rem;
  padding: 12px 26px;
  border-radius: 30px;
  background: rgba(14, 10, 6, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(201, 169, 97, 0.4);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.5s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---- Footer ---- */
.footer {
  position: absolute;
  z-index: 6;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  font-size: 0.68rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: rgba(232, 221, 200, 0.35);
  direction: rtl;
}

.remix-link {
  color: rgba(201, 169, 97, 0.55);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.3s ease;
  direction: ltr;
}

.remix-link:hover {
  color: var(--amber);
  border-bottom-color: rgba(201, 169, 97, 0.5);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .poem-overlay {
    bottom: 15vh;
    right: 6vw;
    left: 6vw;
  }
  .poem-verses {
    max-width: none;
  }
  .footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    bottom: 8px;
  }
  .panel {
    top: 16px;
    left: 16px;
  }
  .panel-body {
    width: 210px;
  }
}