/* ==========================================================================
   Sburb Captchalogue Alchemy Calculator - Skaia Ethereal Light Theme
   ========================================================================== */

@font-face {
  font-family: 'Fontstuck Extended';
  src: url('fonts/fontstuck-extended/fontstuck-extended.woff2') format('woff2'),
       url('fonts/fontstuck-extended/fontstuck-extended.woff') format('woff'),
       url('fonts/fontstuck-extended/fontstuck-extended.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Monostuck';
  src: url('fonts/monostuck.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

:root {
  --skaia-sky-top: #e0f2fe;
  --skaia-sky-mid: #dbeafe;
  --skaia-sky-bottom: #f0f9ff;
  --skaia-blue-accent: #0284c7;
  --skaia-blue-glow: #38bdf8;
  --skaia-gold: #d97706;
  --skaia-gold-light: #fbbf24;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --card-bg: rgba(255, 255, 255, 0.82);
  --panel-bg: rgba(248, 250, 252, 0.75);
  --border-glass: rgba(186, 230, 253, 0.8);
  --shadow-cloud: 0 12px 36px rgba(14, 165, 233, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius-panel: 18px;
  --radius-card: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  font-family: 'Fontstuck Extended', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: linear-gradient(170deg, var(--skaia-sky-top) 0%, var(--skaia-sky-mid) 50%, var(--skaia-sky-bottom) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Atmospheric Skaia Cloud & Grid Background Layer */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.7) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(255, 255, 255, 0.6) 0%, transparent 45%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  z-index: 0;
  opacity: 0.85;
}

/* Rotating Background Skaia Orb */
.skaiaBgOrb {
  position: fixed;
  bottom: -40px;
  right: -40px;
  width: 320px;
  height: 320px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  user-select: none;
  animation: skaiaRotate 120s linear infinite;
  filter: drop-shadow(0 0 24px rgba(56, 189, 248, 0.3));
}

@keyframes skaiaRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .skaiaBgOrb {
    animation: none;
  }
}

@media (max-width: 600px) {
  .skaiaBgOrb {
    width: 200px;
    height: 200px;
    bottom: -20px;
    right: -20px;
    opacity: 0.25;
  }
}

/* Image Preloader */
body::after {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  z-index: -1;
  content: url(img/btn/and-01.png) url(img/btn/or-01.png) url(img/btn/xor-01.png) url(img/btn/abj-01.png) url(img/btn/alchemize-01.png) url(img/btn/alchemize-02.png);
}

#appRoot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 24px 16px 40px 16px;
}

/* ==========================================================================
   Header & App Branding
   ========================================================================== */
.appHeader {
  text-align: center;
  margin-bottom: 24px;
  max-width: 900px;
  width: 100%;
}

.appTitle {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0c4a6e;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.appSubtitle {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ==========================================================================
   Workbench & Card Layout
   ========================================================================== */
.workbenchPanel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--border-glass);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-cloud);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 1100px;
  width: 100%;
}

.cardsContainer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  width: 100%;
}

.cardColumn {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 10;
  overflow: visible !important;
}

.cardColumn:focus-within,
.cardColumn:hover,
.cardColumn.has-open-suggestions {
  z-index: 999999 !important;
}

.cardLabel {
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* Captchalogue Card Rendering */
.card {
  position: relative;
  width: 148px;
  height: 188px;
  background-image: url(img/empty-card.png);
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 6px 14px rgba(14, 165, 233, 0.2));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  filter: drop-shadow(0 10px 20px rgba(14, 165, 233, 0.35));
}

.card.alchemy-flash {
  animation: cardGlowFlash 0.6s ease-out;
}

@keyframes cardGlowFlash {
  0% { transform: scale(1.05); filter: drop-shadow(0 0 24px #38bdf8); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 36px #fbbf24); }
  100% { transform: scale(1); filter: drop-shadow(0 6px 14px rgba(14, 165, 233, 0.2)); }
}

.item {
  position: absolute;
  width: 102px;
  height: 144px;
  top: 18px;
  left: 14px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
}

/* 48-Hole Punch Grid */
.holesGrid {
  position: absolute;
  top: 38px;
  left: 20px;
  width: 76px;
  height: 115px;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(12, 1fr);
  row-gap: 5px;
  column-gap: 4px;
}

.hole {
  width: 14px;
  height: 3px;
  background-color: #0369a1;
  border: 1px solid #082f49;
  visibility: hidden;
  border-radius: 1px;
}

.hole.punched {
  visibility: visible;
  box-shadow: 0 0 4px rgba(3, 105, 161, 0.6);
}

/* Text Box Input */
.textBoxWrap {
  position: relative;
  z-index: 50;
  overflow: visible !important;
  width: 192px;
  height: 46px;
  margin-top: 14px;
  background-image: url(img/text-box.png);
  background-repeat: no-repeat;
  background-position: center center;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.08));
}

.textBoxWrap:focus-within {
  z-index: 999999 !important;
}

.textPut {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  width: 164px;
  height: 34px;
  background: none;
  border: none;
  font-family: 'Monostuck', monospace;
  font-size: 32px;
  text-align: left;
  line-height: 34px;
  color: #000000;
  outline: none;
  letter-spacing: 1px;
  padding: 0;
  margin: 0;
}

.textPut:read-only {
  color: #0c4a6e;
  cursor: default;
}

/* Autocomplete Suggestions */
.suggestions {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  max-height: 220px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background: #ffffff !important;
  border: 2px solid #0284c7 !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.35) !important;
  z-index: 999999 !important;
  display: none;
  font-family: system-ui, sans-serif;
  padding: 4px 0;
}

.suggestions.active {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: #1e293b;
  transition: background 0.15s ease;
}

.suggestion-item:hover, .suggestion-item.highlight {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 600;
}

.suggestion-code {
  font-family: 'Monostuck', monospace;
  font-size: 0.92rem;
  color: #0284c7;
  background: #f0f9ff;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.suggestion-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.suggestion-item:hover .suggestion-title,
.suggestion-item.highlight .suggestion-title {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}

/* Operator Selector Grid */
.opGrid {
  display: grid;
  grid-template-columns: repeat(2, 81px);
  grid-template-rows: repeat(2, 68px);
  gap: 8px;
  margin: 0 4px;
}

.radioWrap {
  display: block;
  position: relative;
  width: 81px;
  height: 68px;
  cursor: pointer;
  user-select: none;
}

.radioWrap input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.opBtn {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-position: center bottom;
  background-repeat: no-repeat;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.radioWrap:hover .opBtn {
  transform: scale(1.04);
  filter: drop-shadow(0 4px 10px rgba(2, 132, 199, 0.3));
}

.andBtn { background-image: url(img/btn/and-00.png); }
.radioWrap input:checked ~ .andBtn { background-image: url(img/btn/and-01.png); }

.orBtn { background-image: url(img/btn/or-00.png); }
.radioWrap input:checked ~ .orBtn { background-image: url(img/btn/or-01.png); }

.xorBtn { background-image: url(img/btn/xor-00.png); }
.radioWrap input:checked ~ .xorBtn { background-image: url(img/btn/xor-01.png); }

.abjBtn { background-image: url(img/btn/abj-00.png); }
.radioWrap input:checked ~ .abjBtn { background-image: url(img/btn/abj-01.png); }

.eqSign {
  width: 19px;
  height: 11px;
  background-image: url("img/equals.png");
  background-repeat: no-repeat;
  background-size: contain;
}

/* Alchemize Action Button */
.alchemizeRow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.eqBtn {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 4px 12px rgba(14, 165, 233, 0.25));
}

.eqBtn:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 6px 18px rgba(14, 165, 233, 0.45));
}

.eqBtn.disabled {
  cursor: not-allowed;
  opacity: 0.6;
  filter: grayscale(0.4);
  pointer-events: none;
  transform: none !important;
}

/* ==========================================================================
   Result Card Meta & Quick Controls
   ========================================================================== */
.resultMetaCard {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.1);
  font-family: system-ui, sans-serif;
  flex-wrap: wrap;
}

.resultInfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.resultTitle {
  font-weight: 700;
  font-size: 1.05rem;
  color: #0369a1;
}

.resultCode {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.actionBtn {
  font-family: system-ui, sans-serif;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.actionBtn:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.actionBtn.copied {
  background: #10b981;
}

/* ==========================================================================
   Preset Recipes & Item Catalog Drawer
   ========================================================================== */
.sectionBlock {
  width: 100%;
  max-width: 1100px;
  margin-top: 24px;
}

.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-family: system-ui, sans-serif;
}

.sectionTitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0c4a6e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.presetList {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-pill {
  font-family: system-ui, sans-serif;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #bae6fd;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: #0369a1;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.08);
}

.preset-pill:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.preset-pill span {
  color: #64748b;
  font-size: 0.75rem;
  margin-left: 4px;
}

/* Modal / Drawer for Catalog */
.modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modalOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modalCard {
  background: #f8fafc;
  border: 1.5px solid #bae6fd;
  border-radius: 20px;
  width: 90%;
  max-width: 960px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modalHeader {
  padding: 20px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modalTitle {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0c4a6e;
  font-family: system-ui, sans-serif;
}

.modalCloseBtn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
}

.modalBody {
  padding: 24px;
  overflow-y: auto;
}

.catalogGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.catalog-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.catalog-card:hover {
  border-color: #38bdf8;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.15);
}

.catalog-thumb {
  width: 80px;
  height: 100px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.catalog-info {
  text-align: center;
  font-family: system-ui, sans-serif;
}

.catalog-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
}

.catalog-code code {
  font-family: 'Monostuck', monospace;
  font-size: 0.95rem;
  color: #0284c7;
  background: #f0f9ff;
  padding: 2px 6px;
  border-radius: 4px;
}

.catalog-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.load-card-btn {
  flex: 1;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  background: #f0f9ff;
  color: #0369a1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.load-card-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.appFooter {
  margin-top: 36px;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: #64748b;
  text-align: center;
}

.appFooter a {
  color: var(--skaia-blue-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.appFooter a:hover {
  color: #0369a1;
}

/* Responsive Breakpoints */
@media (max-width: 860px) {
  .cardsContainer {
    flex-direction: column;
    gap: 18px;
  }
  .opGrid {
    grid-template-columns: repeat(4, 81px);
    grid-template-rows: 68px;
    margin-left: -6px;
  }
  .eqSign {
    margin: 8px 0;
  }
  .alchemizeRow {
    margin-left: -6px;
  }
}
