/* ==========================================================
   ToyKit — Main Workbench Layout (Desktop + Tablet Responsive)
   ========================================================== */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: var(--border);
  box-shadow: 0 3px 0 rgba(30, 36, 48, 0.08);
  z-index: 40;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--yellow);
  border: var(--border-thin);
  border-radius: var(--radius-md);
  padding: 5px 11px 5px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-weight: 900;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  transition: transform 0.08s;
}
.brand-logo:active { transform: translate(2px, 2px); box-shadow: none; }

.logo-badge {
  display: inline-flex;
  align-items: center;
}

.project-title-input {
  width: 155px;
  padding: 6px 10px;
  border: 2px dashed #C7BCA6;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-weight: 800;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.project-title-input:focus {
  border-style: solid;
  border-color: var(--ink);
  background: #fff;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-desk);
  padding: 4px;
  border: var(--border-thin);
  border-radius: var(--radius-md);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.8px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.12s;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.mode-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.tab-pill {
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  font-size: 0.75rem;
  font-weight: 800;
}

/* Topbar Right Actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-divider {
  width: 2px;
  height: 26px;
  background: #D8CEB8;
  margin: 0 2px;
}

.lang-select {
  min-height: 40px;
  padding: 6px 8px;
  border: var(--border-thin);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  font-weight: 800;
  font-size: 0.84rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  outline: none;
}
.lang-select:hover {
  background: var(--yellow-light);
}

/* ========== WORKSPACE & VIEWS ========== */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.editor-view {
  display: none;
  width: 100%;
  height: 100%;
}

.editor-view.is-active {
  display: flex;
}

/* ========== STAGE EDITOR 3-COLUMN LAYOUT ========== */
#view-stage {
  position: relative;
  gap: 0;
  overflow: hidden;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 36, 48, 0.42);
  z-index: 25;
  backdrop-filter: blur(1px);
  animation: fadeBackdrop 0.16s ease;
}

@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.side-panel {
  width: 270px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  z-index: 10;
}

.side-panel.is-collapsed {
  display: none;
}

.library-panel {
  border-inline-end: var(--border);
}

.inspector-panel {
  width: 288px;
  border-inline-start: var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-bottom: var(--border-thin);
  flex-shrink: 0;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-close-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 8px;
  font-size: 0.95rem;
  background: #fff;
}
.panel-close-btn:hover {
  background: var(--coral-light);
}

.panel-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
}

.stage-center {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 7px 10px;
  background: rgba(255, 253, 248, 0.88);
  border-bottom: 1.5px solid #DED5C2;
  flex-shrink: 0;
}

.stage-toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
}

.stage-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 7px 14px;
  background: var(--surface);
  border-top: 1.5px solid #DED5C2;
  flex-shrink: 0;
}

/* ========== STORYBOARD & EVENTS FULL-WIDTH VIEWS ========== */
#view-storyboard, #view-events {
  flex-direction: column;
  padding: 18px 22px;
  overflow-y: auto;
}

.storyboard-header, .events-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.section-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 900;
}

.section-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.storyboard-controls, .events-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ========== RESPONSIVE TABLET & SMALL SCREEN SUPPORT ========== */
.show-tablet-only {
  display: none;
}

/* The full top bar needs ~1700px in the longest language (Spanish): below that the file buttons go icon-only (titles keep
   their labels), and below 1320px the mode tabs move to their own row so nothing overlaps
   the brand pill on laptops and iPad landscape. */
@media (max-width: 1700px) {
  .hide-sm {
    display: none;
  }
}

@media (max-width: 1320px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .mode-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .mode-tab {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 1080px) {
  .project-title-input {
    width: 115px;
  }
  .side-panel {
    width: 240px;
  }
  .inspector-panel {
    width: 256px;
  }
}

@media (max-width: 960px) {
  .topbar {
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 8px;
  }
  .mode-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .mode-tab {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.85rem;
  }
  .show-tablet-only {
    display: inline-flex;
  }
  .library-panel, .inspector-panel {
    display: flex !important;
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(310px, 84vw);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease;
    z-index: 30;
  }
  /* RTL drawer edges: Library on right, Inspector on left */
  html[dir="rtl"] .library-panel {
    right: 0; left: auto;
    transform: translateX(108%);
  }
  html[dir="rtl"] .inspector-panel {
    left: 0; right: auto;
    transform: translateX(-108%);
  }
  /* LTR drawer edges: Library on left, Inspector on right */
  html[dir="ltr"] .library-panel {
    left: 0; right: auto;
    transform: translateX(-108%);
  }
  html[dir="ltr"] .inspector-panel {
    right: 0; left: auto;
    transform: translateX(108%);
  }
  html[dir="rtl"] .side-panel.is-open,
  html[dir="ltr"] .side-panel.is-open {
    transform: translateX(0);
  }
  /* The Install button keeps only its emoji, so the action row still fits on small tablets. */
  #btn-pwa-install {
    font-size: 0;
    gap: 0;
  }
  #btn-pwa-install::before {
    content: '📲';
    font-size: 1.05rem;
  }
}

/* Phones (portrait ≤600px wide, landscape ≤500px tall) are handled at the end of editors.css,
   the last stylesheet, so those rules win over both files. */

/* ========== FIRST-VISIT WELCOME ========== */
.welcome-backdrop {
  background: var(--bg-desk);
  background-image: radial-gradient(var(--bg-desk-dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.welcome-card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 18px;
}
.welcome-kit {
  display: block;
  width: 112px;
  height: auto;
  margin: 0 auto 8px;
  overflow: visible;
  transform-origin: 50% 100%;
  animation: kit-drop 0.62s cubic-bezier(0.3, 0.7, 0.4, 1) both;
}
.welcome-kit .kit-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: kit-blink 5s 1.1s infinite;
}
.welcome-wordmark {
  margin: 4px 0 0;
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}
.welcome-tagline { margin: 8px 0 4px; font-weight: 800; font-size: 1.05rem; }
.welcome-lead { margin: 0 0 18px; color: var(--ink-soft); font-weight: 600; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; }
.welcome-actions .btn { width: 100%; min-height: 48px; font-size: 1.08rem; white-space: normal; }
.welcome-langs { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.welcome-lang {
  background: none;
  border: 1.8px solid transparent;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
}
.welcome-lang:hover { background: var(--surface-hover); }
.welcome-lang.is-active { border-color: var(--ink); background: var(--yellow-light); color: var(--ink); }
.welcome-privacy { display: inline-block; margin-top: 12px; font-size: 0.82rem; font-weight: 700; color: var(--ink-muted); }

@keyframes kit-drop {
  0% { transform: translateY(-70px) scale(0.9); opacity: 0; }
  55% { transform: translateY(0) scale(1.08, 0.88); opacity: 1; }
  75% { transform: translateY(0) scale(0.96, 1.05); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes kit-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
@media (prefers-reduced-motion: reduce) {
  .welcome-kit, .welcome-kit .kit-eyes { animation: none; }
}
