/* =====================================
   PixelForge — tools/pixelforge/css/style.css
   Builds on base.css / layout.css / tool.css.
   Mirrors PaletteForge's hero + workspace + compare structure (px-* namespace).
===================================== */

/* ============================================================
   Dedicated hero (self-contained px-hero-*, like PaletteForge)
   ============================================================ */
.px-hero-wrap { padding: 2rem 1.5rem 0.5rem; }
.px-hero-card {
  position: relative; max-width: 1100px; margin: 0 auto;
  border-radius: 28px; overflow: hidden; background: #0d1424;
}
.px-hero-card::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(8,14,28,.82) 0%, rgba(8,14,28,.55) 42%, rgba(8,14,28,.10) 68%, rgba(8,14,28,0) 100%),
    linear-gradient(180deg, rgba(31,111,255,.10) 0%, rgba(31,111,255,0) 45%);
}
.px-hero-media { position: relative; display: block; width: 100%; aspect-ratio: 2200 / 800; overflow: hidden; background: #11182b; }
.px-hero-media picture { display: contents; }
.px-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 60% 40%; display: block; }
.px-hero-badge {
  position: absolute; z-index: 2; top: 22px; left: 24px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(13,20,36,.55); border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #dbe4ff; font-size: .76rem; font-weight: 700; letter-spacing: .02em;
}
.px-hero-badge svg { color: #7aa2ff; }
.px-hero-copy {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 48px 55px; max-width: 640px;
}
.px-hero-title {
  margin: 0 0 14px; color: #fff; font-weight: 800;
  letter-spacing: -0.02em; font-size: clamp(1.9rem, 3.2vw, 2.45rem); line-height: 1.2;
  word-break: keep-all; overflow-wrap: anywhere; text-shadow: 0 2px 14px rgba(0,0,0,.35);
}
.px-hero-lead {
  margin: 0 0 24px; color: rgba(255,255,255,.92); line-height: 1.6;
  font-size: 0.98rem; max-width: 52ch; font-weight: 500; text-shadow: 0 1px 8px rgba(0,0,0,.35);
}
.px-hero-cta {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 26px;
  border-radius: 999px; text-decoration: none; background: var(--gz-accent, #1f6fff);
  color: #fff; font-weight: 700; font-size: 0.95rem; box-shadow: 0 8px 22px rgba(31,111,255,.35);
  transition: transform .18s ease, opacity .18s ease;
}
.px-hero-cta:hover { opacity: .94; transform: translateY(-1px); }
.px-hero-arrow { transition: transform .18s ease; }
.px-hero-cta:hover .px-hero-arrow { transform: translateX(4px); }
@media (min-width: 641px) {
  html[lang="ja"] .px-hero-title { font-size: clamp(1.8rem, 3vw, 2.25rem); }
}
@media (max-width: 640px) {
  .px-hero-wrap { padding: 0 0 25px; }
  .px-hero-card { border-radius: 22px; margin: 0 1.25rem; }
  .px-hero-card::before { display: none; }
  .px-hero-media { aspect-ratio: 1672 / 941; }
  .px-hero-copy { position: static; inset: auto; justify-content: flex-start; align-items: stretch; padding: 24px 22px 30px; max-width: none; }
  .px-hero-title { text-align: center; font-size: 1.7rem; margin-bottom: 10px; }
  .px-hero-lead { text-align: center; margin-bottom: 18px; }
  .px-hero-cta { width: 100%; justify-content: center; }
  .px-hero-badge { top: 14px; left: 14px; }
}

/* ============================================================
   Workspace: LEFT = stage (the dropzone) · RIGHT = control panel
   ============================================================ */
.px-workspace {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 20px; align-items: start;
}
.px-workspace:has(.px-panel[hidden]) { grid-template-columns: 1fr; }
@media (max-width: 960px) { .px-workspace { grid-template-columns: 1fr; gap: 16px; } }

.px-stage-area { align-self: start; }
@media (min-width: 961px) { .px-stage-area { position: sticky; top: 16px; } }

.px-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 440px; padding: 18px; background: #f4f5f7;
  border: 1.5px solid #e0e0e0; border-radius: 14px; overflow: hidden; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.px-stage.is-dragover { border-color: #1f6fff; box-shadow: 0 0 0 3px rgba(31,111,255,.15); }
.px-stage.has-img { background: #fff; padding: 0; min-height: 0; cursor: default; }

.px-drop-hint {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 30px; text-align: center; color: #9aa0a6;
}
.px-drop-hint svg { opacity: .5; }
.px-drop-hint span:first-of-type { color: #1f6fff; font-weight: 600; font-size: 15px; }
.px-drop-sub { font-size: 12px; color: #9aa0a6; }

.px-compare { width: 100%; }
.px-compare .px-compare-inner { margin: 0; border-radius: 0; }

/* readout chips */
.px-readouts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.px-readout { flex: 1 1 auto; min-width: 140px; background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 8px 12px; }
.px-readout b { display: block; font-size: 11px; font-weight: 600; color: #9aa0a6; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.px-readout span { font-size: 14px; font-weight: 700; color: #1f6fff; font-variant-numeric: tabular-nums; }

.px-stage-meta { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 10px; font-size: 0.8rem; color: #6b7280; }

/* ---- Compare slider ---- */
.px-compare-inner {
  position: relative; margin: 0 auto; display: block; overflow: hidden; border-radius: 14px;
  /* Plain white — a checkerboard reads as fake pixels in a pixelation tool and
     showed through letterboxed previews. Transparent source pixels fall back to
     this white, which matches the stage card behind it. */
  background: #ffffff;
}
.px-compare-img { display: block; width: 100%; height: auto; margin: 0 auto; user-select: none; -webkit-user-drag: none; image-rendering: pixelated; }
.px-compare-img--base { position: relative; z-index: 1; }
.px-compare-overlay { position: absolute; inset: 0; z-index: 2; clip-path: inset(0 50% 0 0); }
.px-compare-img--top { position: absolute; top: 0; left: 0; width: 100%; }
.px-compare-side-label {
  position: absolute; bottom: 8px; font-size: 0.75rem; line-height: 1.3; padding: 0.2rem 0.5rem;
  border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; z-index: 4;
}
.px-label-left { left: 10px; }
.px-label-right { right: 10px; }
.px-compare-handle { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 3; touch-action: none; width: 0; }
.px-compare-handle-line { position: absolute; top: 0; bottom: 0; left: 0; transform: translateX(-50%); width: 2px; background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgb(31 41 55 / 12%); }
.px-compare-handle-knob { position: absolute; top: 50%; left: 0; transform: translate(-50%,-50%); display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; pointer-events: auto; cursor: ew-resize; }
.px-compare-knob-dot { width: 26px; height: 26px; border-radius: 999px; background: #fff; border: 1px solid #d7d7d7; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .15s ease; }
.px-compare-handle-knob:hover .px-compare-knob-dot { transform: scale(1.08); }

/* ---- Busy indicator ---- */
.px-busy[hidden] { display: none; }
.px-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.6rem; background: rgba(255,255,255,.66); color: #1f2937; font-size: 0.9rem; z-index: 5; }
.px-spinner { width: 20px; height: 20px; border: 3px solid rgba(31,111,255,.25); border-top-color: #1f6fff; border-radius: 50%; animation: px-spin 0.8s linear infinite; }
@keyframes px-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Control panel
   ============================================================ */
.px-panel { display: flex; flex-direction: column; gap: 14px; }
.px-card { border: 1px solid #e8e8e8; border-radius: 12px; background: #fff; padding: 16px; }
.px-card-title { font-size: 12px; font-weight: 700; color: #374151; margin: 0 0 12px; letter-spacing: .04em; text-transform: uppercase; }
.px-hint { font-size: 0.78rem; color: #6b7280; margin: 8px 0 0; }

.px-panel[hidden], .px-readouts[hidden], .px-stage-meta[hidden], .px-card[hidden] { display: none; }

/* segmented preset group + custom input (shared by blocks & colours) */
.px-seg-control { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.px-seg { display: inline-flex; border: 1px solid #d7dbe0; border-radius: 10px; overflow: hidden; background: #f8fafc; }
.px-seg-btn { min-width: 48px; padding: 0.5rem 0.85rem; border: none; border-right: 1px solid #e3e7ec; background: transparent; font-weight: 700; color: #374151; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.px-seg-btn:last-child { border-right: none; }
.px-seg-btn:hover:not(.is-active) { background: #eef2ff; }
.px-seg-btn.is-active { background: #1f6fff; color: #fff; }
.px-custom { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: #4b5563; }
.px-custom input { width: 84px; padding: 0.45rem 0.55rem; border: 1px solid #d7dbe0; border-radius: 8px; font-size: 0.9rem; }
.px-custom input:focus { outline: none; border-color: #1f6fff; box-shadow: 0 0 0 2px rgba(31,111,255,.15); }

/* radio stacks (sampling / dithering / mode) */
.px-radio-group { display: flex; flex-direction: column; gap: 0.5rem; }
.px-radio { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid #d7dbe0; border-radius: 10px; cursor: pointer; }
.px-radio input { accent-color: #1f6fff; flex-shrink: 0; }
.px-radio-text { display: flex; flex-direction: column; line-height: 1.25; }
.px-radio-title { font-size: 0.85rem; font-weight: 600; color: #1a1a2e; }
.px-radio-desc { font-size: 0.72rem; color: #6b7280; }
.px-radio:has(input:checked) { border-color: #1f6fff; background: rgba(31,111,255,.06); }
.px-radio:has(input:checked) .px-radio-desc { color: #4b6fb0; }

/* mode toggle — two big segments (chart is the lead) */
.px-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.px-mode .px-radio { justify-content: center; text-align: center; }
.px-mode .px-radio-text { align-items: center; }

/* checkboxes */
.px-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: #374151; cursor: pointer; }
.px-chk input { width: 15px; height: 15px; accent-color: #1f6fff; cursor: pointer; }
.px-chk-row { display: flex; flex-wrap: wrap; gap: 14px; }

/* small inline fields (cell size / orientation) */
.px-field-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.px-field-row label { font-size: 0.8rem; color: #4b5563; }
.px-num { width: 72px; height: 30px; padding: 0 8px; font-size: 13px; text-align: center; border: 1.5px solid #e0e0e0; border-radius: 8px; background: #fafafa; color: #222; outline: none; }
.px-num:focus { border-color: #1f6fff; background: #fff; }
.px-sel { height: 30px; padding: 0 8px; font-size: 12px; border: 1.5px solid #e0e0e0; border-radius: 8px; background: #fafafa; color: #444; cursor: pointer; outline: none; }
.px-sel:focus { border-color: #1f6fff; }

/* legend (chart mode) */
.px-legend-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 320px; overflow: auto; }
.px-legend-row { display: grid; grid-template-columns: 30px 18px 1fr auto; align-items: center; gap: 0.5rem; font-size: 0.76rem; }
.px-legend-num { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 20px; padding: 0 4px; border-radius: 6px; background: #eef2ff; color: #1f4fd0; font-weight: 700; font-variant-numeric: tabular-nums; }
.px-legend-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); }
.px-legend-hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #374151; }
.px-legend-count { text-align: right; color: #6b7280; font-variant-numeric: tabular-nums; }

/* export */
.px-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.px-export-grid .px-export-btn {
  width: 100%; min-height: 40px; padding: 0 12px; border-radius: 10px;
  background: #f4f6f9; color: #374151; border: 1px solid #d7dbe0;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.px-export-grid .px-export-btn:hover:not(:disabled) { background: #eaeefc; border-color: #1f6fff; color: #1f4fd0; }
.px-export-grid .px-export-btn:disabled { opacity: .45; cursor: default; }
.px-export-btn--primary { grid-column: 1 / -1; background: #1f6fff !important; color: #fff !important; border-color: #1f6fff !important; box-shadow: 0 2px 8px rgba(31,111,255,.3); }
.px-export-btn--primary:hover:not(:disabled) { background: #1558d4 !important; }

/* Mode-aware visibility: chart-only vs game-only export blocks & cards */
.px-chart-only { display: block; }
.px-game-only  { display: none; }
body.px-mode-game .px-chart-only { display: none; }
body.px-mode-game .px-game-only  { display: block; }
/* In game mode the chart legend card hides itself via JS too. */

/* ============================================================
   Guide section (mirror PaletteForge / ArchitectLine)
   ============================================================ */
.gz-guide-section { background: transparent; padding-bottom: 80px; }
@media (max-width: 640px) { .gz-guide-section { padding-bottom: 56px; } }
.gz-guide-inner { max-width: 800px; margin: 0 auto; padding: 0 24px; }
.gz-guide-body { margin-top: 40px; }
.gz-guide-subheading { font-size: 1.15rem; font-weight: 700; color: #1a1a2e; margin: 32px 0 14px; }
.gz-guide-subheading:first-child { margin-top: 0; }
.gz-guide-steps { padding-left: 24px; margin: 0 0 8px; }
.gz-guide-step { font-size: 1rem; line-height: 1.75; color: #374151; margin-bottom: 16px; padding-left: 8px; }
.gz-guide-text { font-size: 1rem; line-height: 1.8; color: #374151; margin: 0 0 16px; }
.gz-guide-img { width: 100%; max-width: 720px; height: auto; border-radius: 12px; margin: 16px 0 24px; display: block; }
@media (max-width: 640px) {
  .gz-guide-inner { padding: 0 16px; }
  .gz-guide-subheading { font-size: 1.05rem; }
  .gz-guide-steps { padding-left: 20px; }
}

/* Toast */
.px-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: #111827; color: #fff; padding: 0.6rem 1rem; border-radius: 10px;
  font-size: 0.85rem; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; z-index: 9999;
}
.px-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* This tool has its own drop handling — suppress the shared full-screen overlay. */
#gzDropOverlay { display: none !important; }

/* ============================================================
   SP (smartphone): keep PixelForge consistent with the other
   tools — a plain single-column scroll (no sticky preview, no
   fixed footer, no accordion; those made this tool feel different
   and cramped). Only two invisible safety tweaks remain: let the
   long resolution preset row scroll sideways instead of overflowing
   the page, and use 16px fields so iOS doesn't zoom on focus.
   ============================================================ */
/* Hide the shared "Private by design" pill on this page only — it floats
   over the preview area. (It stays on every other page.) */
body.gz-tool-pixelforge #tlPrivacyWrap { display: none !important; }

@media (max-width: 640px) {
  .px-seg { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .px-seg::-webkit-scrollbar { display: none; }
  .px-custom input,
  .px-num { font-size: 16px; }

  /* Reclaim height under the preview: the readout chips (blocks/colours/
     mode) duplicate the panel and the auto-generated filename is just
     noise. Hide both on phones; keep only the "Change image" action. */
  .px-readouts { display: none; }
  #pxFileName { display: none; }
  .px-stage-meta { margin-top: 6px;justify-content: center; }

  /* Plain single-column scroll (no sticky preview — it jittered on iOS
     because Safari's collapsing toolbar keeps recomputing the sticky
     position). Cap the preview height and use object-fit so the
     before/after canvases stay pixel-aligned; any margin falls back to the
     white background (set above), not a checkerboard. */
  .px-compare-inner { max-height: 44vh; }
  .px-compare-img {
    width: 100%;
    height: auto;
    max-height: 44vh;
    object-fit: contain;
  }
  .px-compare-img--top {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
