/* ==========================================================================
   Demo page (Coffee Beans) – on top of common.css tokens
   ========================================================================== */
.demo-card{
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  padding: 16px 16px 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,.08);
}

.demo-hero{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.demo-hero h1{
  margin: 0 0 6px 0;
}

.demo-sub{
  margin: 0;
  color: rgba(0,0,63,.85);
  font-size: 1rem;
  line-height: 1.55;
}

.demo-badges{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 2px;
}

.demo-badge{
  font-size: .9rem;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(30,144,255,.09);
  border: 1px solid rgba(30,144,255,.20);
  color: var(--brand-700);
  font-weight: 600;
  white-space: nowrap;
}

.demo-actions{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.demo-btn{
  appearance: none;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-outer) 100%);
  color: #fff;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(30,144,255,.18), 0 2px 6px rgba(0,0,0,.08);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.demo-btn.secondary{
  background: linear-gradient(135deg, #2bb3ff 0%, var(--brand) 100%);
  box-shadow: 0 10px 24px rgba(43,179,255,.16), 0 2px 6px rgba(0,0,0,.08);
}

.demo-btn:hover{
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 14px 30px rgba(30,144,255,.22), 0 3px 10px rgba(0,0,0,.10);
}

.demo-btn:active{
  transform: translateY(0);
  filter: brightness(.99);
  box-shadow: 0 8px 18px rgba(30,144,255,.16), 0 2px 6px rgba(0,0,0,.08);
}

.demo-btn:disabled{
  opacity: .6;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

.demo-btn:focus-visible{
  outline: 3px solid rgba(30,144,255,.35);
  outline-offset: 2px;
}

.demo-samples{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sampleBtn{
  width: 100%;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.12);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.sampleBtn:hover{ transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0,0,0,.10); }
.sampleBtn:active{ transform: translateY(0); box-shadow: 0 6px 14px rgba(0,0,0,.10); }

.sampleBtn img{
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.10);
  background: #fff;
}

.sampleBtn span{
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.demo-status{
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

#loading{
  display: none;
  font-weight: 600;
  opacity: .85;
}

#meta{
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
  font-size: 1rem;
  font-weight: 500;
  width: fit-content;
}

#meta .meta-mini{
  font-size: .85rem;
  opacity: .8;
  white-space: nowrap;
}

#progressContainer{
  width: 100%;
  max-width: 520px;
}

#progressBar{
  width: 100%;
  height: 22px;
  background: rgba(15,23,42,.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

#progressBar::before{
  content: '';
  position: absolute;
  inset: 0;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--brand), var(--brand-outer));
  transition: width .25s ease;
}

#progressText{
  margin-top: 6px;
  font-size: .95rem;
  opacity: .85;
}

#error{
  display: none;
  margin-top: 10px;
  color: #a40000;
  font-weight: 600;
  white-space: pre-wrap;
  background: rgba(164,0,0,.06);
  border: 1px solid rgba(164,0,0,.18);
  border-radius: 12px;
  padding: 10px 12px;
}

#canvas{
  display: none;
  width: 100%;
  height: auto;
  margin-top: 14px;
  border: 1px solid rgba(15,23,42,.16);
  border-radius: 12px;
  background: #fff;
}

/* Overlay (fullscreen) */
#overlay{
  position: fixed;
  inset: 0;
  background: rgba(247,248,251,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease, visibility .12s ease;
}

body.is-loading #overlay,
#overlay.is-visible{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-box{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 18px 44px rgba(0,0,0,.14);
}

.spinner{
  width: 42px;
  height: 42px;
  border: 4px solid rgba(15,23,42,.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

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

.overlay-text{ font-weight: 700; color: var(--text); }
.overlay-sub{ margin-top: 2px; font-size: .95rem; font-weight: 500; opacity: .85; }

/* Mobile */
@media (max-width: 760px){
  .demo-actions{ grid-template-columns: 1fr; }
  .demo-samples{ grid-template-columns: 1fr; }
  .sampleBtn img{ height: 140px; }
}
