/* GIF Studio page layout. Shared colors, typography, controls, cards, buttons,
 * navigation, icons, and footer come from the canonical fb-ui.css. */

[hidden] {
  display: none !important;
}

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: var(--s-4) max(var(--s-6), env(safe-area-inset-right)) 140px max(var(--s-6), env(safe-area-inset-left));
}

.hero {
  max-width: 760px;
}

.gg-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: var(--s-6);
  align-items: start;
}

.gg-builder,
.gg-sidebar {
  min-width: 0;
}

.gg-sidebar {
  display: grid;
  gap: var(--s-5);
  position: sticky;
  top: calc(var(--page-nav-h) + var(--s-4));
}

.gg-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.gg-section-head.compact {
  margin-bottom: var(--s-5);
}

.gg-section-head .eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.gg-section-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.gg-count,
.gg-result-badge {
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gg-upload-card {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-4);
}

.gg-drop {
  width: 100%;
  min-height: 154px;
  padding: var(--s-6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  border: 1px dashed var(--control-border);
  border-radius: var(--radius-card);
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.gg-drop:hover,
.gg-drop.is-over {
  border-color: var(--accent);
  background: var(--control-bg-hover);
}

.gg-drop:active {
  transform: scale(0.995);
}

.gg-drop-icon {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.gg-drop-icon .icon {
  --icon-size: 22px;
}

.gg-drop-copy {
  display: grid;
  gap: 5px;
}

.gg-drop-copy strong {
  font-size: 15px;
  font-weight: 500;
}

.gg-drop-copy small {
  color: var(--text-muted);
  font-size: 12px;
}

.gg-upload-actions,
.gg-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.gg-upload-actions .btn,
.gg-result-actions .btn {
  flex: 1 1 auto;
}

.gg-empty {
  min-height: 210px;
  margin-top: var(--s-4);
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--s-3);
  border: 1px dashed var(--control-border);
  border-radius: var(--radius-card);
  color: var(--text-muted);
  text-align: center;
}

.gg-empty .icon {
  --icon-size: 30px;
  color: var(--text-faint);
}

.gg-empty p {
  margin: 0;
  font-size: 13px;
}

.gg-frames {
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--s-3);
}

.gg-frame {
  display: grid;
  grid-template-columns: 20px 82px minmax(0, 1fr);
  align-items: start;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--glass-bg);
  border-radius: var(--radius-glass);
  box-shadow: var(--glass-shadow);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.gg-frame.is-dragging {
  opacity: 0.45;
  transform: scale(0.99);
}

.gg-frame.is-drop-target {
  box-shadow: var(--glass-shadow), 0 0 0 2px var(--accent);
}

.gg-frame-index {
  display: block;
  align-self: start;
  justify-self: start;
  margin-top: 6px;
  margin-left: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.16em;
  cursor: grab;
}

.gg-frame-thumb {
  width: 82px;
  height: 68px;
  display: block;
  object-fit: cover;
  border-radius: var(--radius-control);
  background: var(--canvas-bg);
}

.gg-frame-copy {
  min-width: 0;
}

.gg-frame-name {
  margin: 0 0 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gg-frame-dimensions {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.gg-frame-tools {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-3);
  align-items: end;
  width: 100%;
}

.gg-duration {
  display: grid;
  gap: 3px;
}

.gg-duration label {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.gg-duration .text-input {
  width: 100%;
}

.gg-frame-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.gg-frame-action {
  flex: 0 0 var(--s-9);
  background: var(--control-bg);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.14);
}

.gg-frame-action .icon {
  --icon-size: 18px;
}

.gg-frame-action:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.gg-frame-action:disabled:hover {
  background: var(--control-bg);
  color: var(--text);
  transform: none;
}

.gg-frame-action.remove {
  color: var(--accent);
}

.gg-settings,
.gg-result {
  display: grid;
  gap: var(--s-4);
}

.gg-settings {
  position: relative;
  z-index: 2;
}

.gg-result {
  position: relative;
  z-index: 1;
}

.gg-size-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.gg-select {
  display: block;
  width: 100%;
}

.gg-select-trigger {
  display: flex;
  align-items: center;
  text-align: left;
}

.gg-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gg-select-menu {
  width: 100%;
  min-width: 100%;
  max-width: none;
  background: var(--canvas-bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.gg-select-menu .gg-select-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.gg-select-menu .gg-select-option:hover,
.gg-select-menu .gg-select-option:focus-visible {
  background: var(--accent);
  color: var(--on-danger);
}

.gg-select-check {
  --icon-size: 16px;
  flex: 0 0 16px;
}

.gg-select-option[aria-selected="false"] .gg-select-check {
  opacity: 0;
}

.gg-generate {
  width: 100%;
}

.gg-generate:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.gg-progress {
  display: grid;
  gap: var(--s-2);
}

.gg-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--control-bg);
}

.gg-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.gg-progress p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.gg-private {
  margin: 0;
  padding-top: var(--s-3);
  border-top: 1px solid rgba(0,0,0,0.08);
}

.gg-private strong {
  color: var(--text);
  font-weight: 500;
}

.gg-stage {
  position: relative;
  min-height: 330px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-card);
  background:
    linear-gradient(45deg, var(--control-bg) 25%, transparent 25%),
    linear-gradient(-45deg, var(--control-bg) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--control-bg) 75%),
    linear-gradient(-45deg, transparent 75%, var(--control-bg) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.gg-stage-empty {
  display: grid;
  place-items: center;
  gap: var(--s-3);
  padding: var(--s-6);
  color: var(--text-muted);
  text-align: center;
}

.gg-stage-empty .icon {
  --icon-size: 34px;
  color: var(--text-faint);
}

.gg-stage-empty p {
  margin: 0;
  font-size: 13px;
}

.gg-stage img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.gg-result-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
}

.gg-result-meta div {
  min-width: 0;
  padding: var(--s-3);
  border-radius: var(--radius-control);
  background: var(--control-bg);
}

.gg-result-meta dt {
  color: var(--text-muted);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gg-result-meta dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

@media (max-width: 960px) {
  .gg-workspace {
    grid-template-columns: 1fr;
  }

  .gg-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page {
    padding-inline: max(var(--s-4), env(safe-area-inset-left));
  }

  .gg-sidebar {
    grid-template-columns: 1fr;
  }

  .gg-frame {
    grid-template-columns: 20px 64px minmax(0, 1fr);
  }

  .gg-frame-thumb {
    width: 64px;
    height: 58px;
  }

  .gg-frame-tools {
    grid-template-columns: minmax(92px, 1fr) auto;
  }
}

@media (max-width: 460px) {
  .gg-drop {
    min-height: 172px;
    flex-direction: column;
    text-align: center;
  }

  .gg-size-grid {
    grid-template-columns: 1fr;
  }

  .gg-frame-tools {
    gap: var(--s-2);
  }
}
