/* ==========================================================================
   Lê Văn Hùng — Image Tools Stylesheet (css/tools.css)
   ========================================================================== */

:root {
  --ink: #080D18;
  --panel: #0F1830;
  --panel-2: #131E3D;
  --line: #22304F;
  --blue: #2F6FED;
  --blue-deep: #1B3E9E;
  --cyan: #4DD8FF;
  --text: #E9EEFB;
  --muted: #8695B7;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Space Grotesk', sans-serif;
  --body: 'Inter', sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#bg3dCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  display: block;
}

main {
  position: relative;
  z-index: 1;
}

.tilt-3d {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.18s cubic-bezier(0.03, 0.98, 0.52, 0.99), box-shadow 0.3s ease, border-color 0.3s ease;
}

.tilt-3d.is-resetting {
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease, border-color 0.3s ease;
}

.tilt-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(
    360px circle at var(--glare-x, 50%) var(--glare-y, 50%),
    rgba(77, 216, 255, 0.18),
    rgba(47, 111, 237, 0.06) 40%,
    transparent 80%
  );
  mix-blend-mode: screen;
}

.tilt-3d:hover .tilt-glare {
  opacity: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(8, 13, 24, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar .back {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cyan);
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar .tc {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 24px 100px;
}

.page-head {
  margin-bottom: 48px;
}

.page-head .eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.page-head h1 {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  margin-bottom: 12px;
}

.page-head p {
  color: var(--muted);
  max-width: 560px;
}

.tool-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.25);
}

.tool-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.tool-head .tc-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
}

.tool-head h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
}

.tool-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  margin-bottom: 24px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.dropzone:hover,
.dropzone.drag {
  border-color: var(--cyan);
  background: rgba(77, 216, 255, 0.05);
  color: var(--text);
}

.dropzone strong {
  color: var(--cyan);
}

input[type="file"] {
  display: none;
}

.workspace {
  display: none;
  gap: 32px;
  grid-template-columns: 1fr 260px;
}

.workspace.active {
  display: grid;
}

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

.canvas-frame {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
  position: relative;
  min-height: 380px;
}

.canvas-frame.grabbing {
  cursor: grabbing;
}

.canvas-frame canvas {
  display: block;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

select,
.field input[type="range"] {
  width: 100%;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

select:focus {
  border-color: var(--cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(77, 216, 255, 0.6);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
  margin-top: 6px;
}

.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--ease-out);
  background: transparent;
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-deep);
  box-shadow: 0 0 20px rgba(47, 111, 237, 0.4);
}

.btn-ghost:hover {
  border-color: var(--cyan);
  background: rgba(77, 216, 255, 0.06);
}

.hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.sharpen-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .sharpen-preview {
    grid-template-columns: 1fr;
  }
}

.preview-box {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.preview-box .lbl {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.preview-box canvas {
  display: block;
  width: 100%;
  height: auto;
}

footer {
  text-align: center;
  padding: 24px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ===== HAMBURGER + DRAWER MENU ===== */
.hamburger-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s ease;
}

.hamburger-btn:hover {
  border-color: var(--cyan);
}

.hamburger-btn span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 200;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease-out);
  z-index: 201;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-head .tc {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 1px;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.menu-item {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.menu-item:hover {
  background: rgba(77, 216, 255, 0.08);
  color: var(--cyan);
}

.menu-group-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 18px 0 6px;
  padding: 0 14px;
}

.sub-item {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.sub-item::before {
  content: '›';
  position: absolute;
  left: 14px;
  color: var(--blue);
}

.sub-item:hover {
  background: rgba(77, 216, 255, 0.08);
  color: var(--text);
}

/* ===== TOOL ICON MARQUEE (Smooth GPU CSS Animation) ===== */
.marquee-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 24px 0;
  margin-bottom: 48px;
  position: relative;
}

.marquee-wrap::before,
.marquee-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}

.marquee-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--panel), transparent);
}

.marquee-wrap::after {
  right: 0;
  background: linear-gradient(270deg, var(--panel), transparent);
}

.marquee-track {
  display: flex;
  gap: 16px;
  width: max-content;
  padding-left: 16px;
  animation: marquee-scroll 24s linear infinite;
  will-change: transform;
}

.marquee-wrap:hover .marquee-track {
  animation-play-state: paused;
}

@keyframes marquee-scroll {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.icon-badge {
  flex: 0 0 auto;
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.icon-badge:hover {
  border-color: rgba(77, 216, 255, 0.4);
  transform: translateY(-2px);
}

.icon-badge img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.icon-badge .fallback {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.icon-badge .name {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}
