/* ==========================================================================
   Pooch Meme Lab — page + editor styles. Builds on the shared design system
   in styles.css (colors, fonts, buttons, header, footer, mobile menu, modal).

   Responsive strategy (canvas is the priority surface):
     • base rules            = compact desktop (1100–1359px): asset toolbar +
                               horizontal thumbnail tray above a large canvas,
                               export row under it, properties in a drawer.
     • @media (min-width:1360px) = optional wide 3-column layout.
     • @media (max-width:1099px) = editor hidden, mobile coming-soon shown.
   ========================================================================== */

.memeLabBody {
  background: var(--cream);
}

.memeLabMobile {
  display: none;
}

#memeLabMain {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 24px 32px;
}

/* ------------------------------- hero row ------------------------------- */
.labHero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 4px 18px;
}
.labHero__copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 20px;
  row-gap: 2px;
}
.labHero__title {
  margin: 0;
  font-size: clamp(2.4rem, 4.4vw, 3.6rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  transform: rotate(-2deg);
}
.labHero__accent {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-script);
  font-weight: 700;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  color: #7a9e00;
  transform: rotate(-3deg);
}
.labHero__accent .heroPaw {
  width: 1em;
  height: 1em;
  margin-left: 0.3em;
  fill: currentColor;
  rotate: 12deg;
}
.labHero__sub {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: 1.02rem;
  color: var(--muted);
}

/* ----------------------------- editor shell ----------------------------- */
.editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(28, 24, 13, 0.06);
  overflow: hidden;
}

.panelHeading {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.panelHeading--sub {
  margin-top: 18px;
}

/* --------------------------- asset library ----------------------------- */
.assetBody {
  display: flex;
  flex-direction: column;
}
.catList {
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.catBtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.catBtn:hover {
  background: rgba(28, 24, 13, 0.05);
}
.catBtn.is-active {
  background: rgba(204, 255, 0, 0.28);
  border-color: rgba(111, 143, 20, 0.5);
}
.catBtn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #6f8f14;
}

.assetMain {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 14px;
}
.assetMain__title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.assetGrid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
/* horizontal thumbnail tray (compact) — square thumbnails */
.assetGrid--tray {
  flex-direction: row;
  flex-wrap: nowrap;
  height: 128px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: center;
}
.assetGrid--tray .assetCard {
  width: 100px;
  height: 100px;
  flex: 0 0 auto;
}

.assetCard {
  position: relative;
  aspect-ratio: 1;
  padding: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #faf7ee;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.assetCard:hover {
  transform: translateY(-2px);
  border-color: rgba(28, 24, 13, 0.35);
  box-shadow: 0 6px 16px rgba(28, 24, 13, 0.1);
}
/* currently-applied fitted overlay (single-select, like the background) */
.assetCard--active {
  border-color: #6f8f14;
  box-shadow: 0 0 0 2px #6f8f14 inset;
}
.assetCard img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.assetCard--bg {
  padding: 0;
  overflow: hidden;
}
.assetCard--bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.assetCard--bg.assetCard--gradient {
  background: radial-gradient(circle at 50% 35%, var(--accent), #7a9e00 75%);
}
.assetCard__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  opacity: 0;
  transition: opacity 0.12s ease;
}
.assetCard--bg:hover .assetCard__name {
  opacity: 1;
}

.assetEmpty {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #faf7ee;
  color: var(--muted);
  font-size: 0.82rem;
}
.assetEmpty strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.95rem;
}

/* upload dropzone */
.uploadZone {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 2px dashed rgba(28, 24, 13, 0.3);
  border-radius: 14px;
  background: rgba(204, 255, 0, 0.06);
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}
.uploadZone.is-drag {
  border-color: var(--accent);
  background: rgba(204, 255, 0, 0.16);
}
.uploadZone strong {
  color: var(--text);
  font-family: var(--font-display);
}
.uploadZone svg {
  width: 30px;
  height: 30px;
  color: #6f8f14;
}
.uploadError {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #c23b2b;
  font-weight: 600;
}
.textAddBtn {
  align-self: start;
}

/* ------------------------------- center -------------------------------- */
.stageWrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stageBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
/* canvas (fixed size) on the left, controls + export stacked on the right */
.stageMain {
  display: grid;
  grid-template-columns: minmax(0, 448px) minmax(200px, 1fr);
  gap: 16px;
  align-items: start;
}
.stageSide {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stageControls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}
.hint {
  font-size: 0.82rem;
  color: var(--muted);
}
.iconBtn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.iconBtn:hover {
  background: rgba(28, 24, 13, 0.05);
}
.iconBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.iconBtn svg {
  width: 18px;
  height: 18px;
}
.iconBtn--danger {
  color: #c23b2b;
  border-color: rgba(194, 59, 43, 0.4);
}
.pillBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.pillBtn:hover {
  background: rgba(28, 24, 13, 0.05);
}
.pillBtn svg {
  width: 16px;
  height: 16px;
}
.pillBtn--accent {
  background: var(--accent);
  border-color: rgba(28, 24, 13, 0.12);
  box-shadow: 0 6px 16px rgba(159, 200, 0, 0.35);
}
.pillBtn--accent:hover {
  background: #c2f000;
}
.propsToggle {
  display: inline-flex;
}

.stageScroll {
  padding: 2px;
}
.canvasStage {
  container-type: inline-size;
  position: relative;
  /* fixed width (not a percentage) so the square doesn't collapse to 0 inside
     the auto-sized grid column — its children are all absolutely positioned. */
  width: 448px;
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #eefcc6, #d6f07a);
  box-shadow: 0 18px 44px rgba(28, 24, 13, 0.18);
  user-select: none;
  touch-action: none;
}
.canvasBg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.canvasBg.is-gradient {
  background: radial-gradient(circle at 50% 35%, var(--accent), #7a9e00 78%);
}
.poochBase {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  height: 92%;
  width: auto;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

/* fitted overlays (clothes, eyes): locked, full-canvas, above the dog and
   below the movable sticker objects (which get z-index 10+). */
.fittedLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.fittedLayer[hidden] {
  display: none;
}
.fittedLayer--clothes {
  z-index: 2;
}
.fittedLayer--eyes {
  z-index: 3;
}

/* canvas objects */
.mlObj {
  position: absolute;
  transform-origin: center center;
  cursor: grab;
  touch-action: none;
}
.mlObj img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.mlObj--text {
  white-space: pre;
  line-height: 1.05;
  padding: 2px 4px;
}
.mlObj.is-selected {
  outline: 2px dashed #6f8f14;
  outline-offset: 2px;
}
.mlHandle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #6f8f14;
  border-radius: 50%;
  z-index: 5;
}
.mlHandle--resize {
  right: -9px;
  bottom: -9px;
  cursor: nwse-resize;
  border-radius: 3px;
}
.mlHandle--rotate {
  left: 50%;
  top: -30px;
  transform: translateX(-50%);
  cursor: grab;
}
.mlHandle--rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 14px;
  width: 2px;
  height: 16px;
  background: #6f8f14;
  transform: translateX(-50%);
}

/* export / share row (always under the canvas) */
.export {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.exportBtns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.btnWide {
  width: 100%;
  min-height: 48px;
  gap: 8px;
}
.btnWide svg {
  width: 18px;
  height: 18px;
}
.tweetBox {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #faf7ee;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  resize: vertical;
  min-height: 52px;
}
.charCount {
  margin: 4px 2px 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}
.exportHelp {
  margin: 8px 2px 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.exportHelp.is-ok {
  color: #6f8f14;
  font-weight: 600;
}

/* ---------------------------- properties ------------------------------- */
.panel--right {
  /* default (compact): off-canvas drawer */
  position: fixed;
  top: 0;
  right: 0;
  width: min(90vw, 360px);
  height: 100%;
  border-radius: 0;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 80;
}
.panel--right.is-open {
  transform: none;
}
.drawerBackdrop {
  position: fixed;
  inset: 0;
  z-index: 79;
  background: rgba(28, 24, 13, 0.5);
}
.drawerBackdrop[hidden] {
  display: none;
}
.propsScroll {
  height: 100%;
  padding: 18px;
  overflow-y: auto;
}
.propsTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.propsClose {
  font-size: 1.4rem;
}
.props__empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  color: var(--muted);
  background: #faf7ee;
}
.props__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.props__name {
  font-family: var(--font-display);
  font-size: 1.1rem;
}
.ctrl {
  display: grid;
  grid-template-columns: 62px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ctrl__label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.ctrl__val {
  font-size: 0.78rem;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.slider {
  width: 100%;
  accent-color: #6f8f14;
}
.btnGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.miniBtn {
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.miniBtn:hover {
  background: rgba(28, 24, 13, 0.05);
}
.miniBtn.is-on {
  background: rgba(204, 255, 0, 0.28);
  border-color: rgba(111, 143, 20, 0.6);
}
.miniBtn--danger {
  color: #c23b2b;
  border-color: rgba(194, 59, 43, 0.4);
}
.miniBtn--danger:hover {
  background: rgba(194, 59, 43, 0.08);
}
.textField,
.selectField {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #faf7ee;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
}
.textRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.textRow--tools .miniBtn {
  width: 42px;
  padding: 8px 0;
  text-align: center;
}
.colorField {
  display: inline-flex;
}
.colorField input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.checkRow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* --------------------------- how it works modal ------------------------ */
.howtoOverlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 24, 13, 0.6);
}
.howtoOverlay[hidden] {
  display: none;
}
.howto {
  position: relative;
  width: min(100%, 460px);
  padding: 30px 34px;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}
.howto h2 {
  margin: 0 0 16px;
  font-size: 1.7rem;
}
.howtoList {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 10px;
  font-size: 1rem;
  color: #3a352a;
}

/* reset confirmation dialog */
.confirmDialog__text {
  margin: 0 0 22px;
  font-size: 1rem;
  line-height: 1.55;
  color: #3a352a;
}
.confirmDialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.btnDanger {
  background: #c23b2b;
  color: #fff;
  border: 1px solid #a52f22;
}
.btnDanger:hover {
  background: #a52f22;
}

/* ------------------------------ btn variants --------------------------- */
.btnGhost {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  gap: 8px;
}
.btnGhost:hover {
  background: rgba(28, 24, 13, 0.05);
}
.btnGhost__icon {
  width: 18px;
  height: 18px;
}

/* ========================= WIDE 3-COLUMN LAYOUT ======================== */
@media (min-width: 1360px) {
  .editor {
    display: grid;
    grid-template-columns: 288px minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
  }
  .panel--left {
    height: 648px;
    display: flex;
    flex-direction: column;
  }
  .assetBody {
    display: grid;
    grid-template-columns: 104px 1fr;
    flex: 1;
    min-height: 0;
  }
  .catList {
    flex-direction: column;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    overflow-x: visible;
    overflow-y: auto;
    padding: 12px 8px;
  }
  .catBtn {
    border: 0;
    border-radius: 10px;
    text-align: left;
  }
  .catBtn.is-active {
    border-color: transparent;
    background: rgba(204, 255, 0, 0.22);
  }
  .assetGrid,
  .assetGrid--tray {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
    gap: 8px;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    align-content: start;
  }
  .assetGrid--tray .assetCard {
    width: auto;
  }
  /* properties becomes a static right column */
  .panel--right {
    position: static;
    transform: none;
    width: auto;
    height: 648px;
    border-radius: 20px;
    z-index: auto;
    display: flex;
    flex-direction: column;
  }
  .propsClose,
  .propsToggle {
    display: none;
  }
  .drawerBackdrop {
    display: none !important;
  }
  /* center column stacks: canvas, then controls + export below it */
  .stageMain {
    display: block;
  }
  .stageScroll {
    display: grid;
    place-items: center;
  }
  .stageSide {
    margin-top: 14px;
  }
  .stageControls {
    justify-content: center;
  }
  .exportBtns {
    grid-template-columns: 1fr 1fr;
  }
}

/* ========================= MOBILE COMING SOON ==========================
   Mirrors the nav's hamburger breakpoint (<=768px): whenever the full nav is
   visible (>=769px) the editor renders; below that we show coming-soon. */
@media (max-width: 768px) {
  .memeLab {
    display: none;
  }
  .memeLabMobile {
    display: grid;
    place-items: center;
    min-height: 64vh;
    padding: 40px 22px;
  }
  .memeLabMobile__card {
    max-width: 440px;
    text-align: center;
  }
  .memeLabMobile__emoji {
    font-size: 3rem;
  }
  .memeLabMobile__card h1 {
    margin: 10px 0 14px;
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    line-height: 1.05;
  }
  .memeLabMobile__card p {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 1.05rem;
  }
  .memeLabMobile__soon {
    font-family: var(--font-script);
    font-weight: 700;
    color: #7a9e00 !important;
    font-size: 1.3rem !important;
  }
  .memeLabMobile__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 22px;
  }
}
