/* ==========================================================================
   Bold Design Studio
   Colours, type and component styling mirror the Bold Padel brand style guide
   used on bold-padel.com (see tailwind.config.ts / globals.css there).
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('./fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Poppins';
  src: url('./fonts/poppins-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bold-red: #CC3333;
  --bold-red-hover: #E64545;
  --bold-brown: #663534;
  --bold-black: #000000;
  --bold-white: #FFFFFF;
  --bold-gold: #F5DB4F;

  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-800: #1F2937;
  --gray-900: #111827;

  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.1);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Poppins', system-ui, -apple-system, sans-serif;

  --sidebar-width: 380px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--gray-900);
  color: var(--bold-white);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  margin: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  padding: 28px 24px 32px;
  background-color: var(--bold-black);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

#sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.studio-header {
  margin-bottom: 28px;
}

.studio-logo {
  display: block;
  width: 132px;
  height: auto;
  margin-bottom: 14px;
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--bold-red);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.studio-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--bold-red);
}

/* ── Action buttons ──────────────────────────────────────────────────────── */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--bold-white);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s, transform 0.3s;
}

.action:hover {
  background-color: var(--surface-hover);
  border-color: rgba(204, 51, 51, 0.5);
}

.action:active {
  transform: scale(0.98);
}

.action.is-open {
  background-color: rgba(204, 51, 51, 0.12);
  border-color: var(--bold-red);
}

.action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(204, 51, 51, 0.2) 0%, rgba(204, 51, 51, 0.05) 100%);
  color: var(--bold-red);
}

.action-icon svg {
  width: 18px;
  height: 18px;
}

.action-label {
  flex: 1;
}

.action-chevron {
  display: flex;
  color: var(--gray-400);
  transition: transform 0.3s;
}

.action-chevron svg {
  width: 18px;
  height: 18px;
}

.action.is-open .action-chevron {
  transform: rotate(180deg);
}

/* Momentary confirmation after the design link lands on the clipboard */
.action.is-copied {
  background-color: rgba(245, 219, 79, 0.12);
  border-color: rgba(245, 219, 79, 0.5);
  color: var(--bold-gold);
}

.action.is-copied .action-icon {
  background: linear-gradient(135deg, rgba(245, 219, 79, 0.2) 0%, rgba(245, 219, 79, 0.05) 100%);
  color: var(--bold-gold);
}

/* Colour swatch — the native colour input sits invisibly on top of the chip
   so the OS picker anchors to it. */
.swatch {
  position: relative;
  display: block;
  width: 34px;
  height: 24px;
}

.swatch-chip {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  /* The colour the model is painted in, so the chip starts truthful */
  background-color: #216cb8;
}

.swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  opacity: 0;
  cursor: pointer;
}

/* ── Expandable panels ───────────────────────────────────────────────────── */

.panel {
  padding: 16px;
  margin-top: -4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.02);
  animation: panel-in 0.25s ease-out;
}

.panel[hidden] {
  display: none;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--gray-400);
  font-size: 12px;
  font-weight: 500;
}

.field-hint {
  margin: -4px 0 10px;
  color: var(--gray-500);
  font-size: 11px;
  line-height: 1.5;
}

.textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.4);
  color: var(--bold-white);
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.textarea::placeholder {
  color: var(--gray-500);
}

.textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--bold-red);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  padding: 11px 24px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s;
}

.btn-red {
  background-color: var(--bold-red);
  color: var(--bold-white);
}

.btn-red:hover {
  background-color: rgba(204, 51, 51, 0.9);
}

.btn:active {
  transform: scale(0.95);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  color: var(--gray-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--line);
}

.filepicker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s;
}

.filepicker:hover {
  border-color: var(--bold-red);
  background-color: rgba(204, 51, 51, 0.08);
}

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

.filepicker-cta {
  color: var(--bold-white);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.filepicker-name {
  overflow: hidden;
  color: var(--gray-400);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Renders ─────────────────────────────────────────────────────────────── */

.renders {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.renders-title {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.renders-hint {
  margin: 4px 0 16px;
  color: var(--gray-500);
  font-size: 12px;
}

.renders-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.renders-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--gray-500);
  font-size: 12px;
  font-style: italic;
}

.render {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: border-color 0.3s, transform 0.3s;
}

.render:hover {
  border-color: var(--bold-red);
  transform: translateY(-2px);
}

.render-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background-color: rgba(0, 0, 0, 0.35);
}

.render-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Which part of the racket this design belongs to */
.render-tag {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.render-tag--overgrip {
  background-color: rgba(204, 51, 51, 0.22);
  color: #f0a0a0;
}

.render-tag--tape {
  background-color: rgba(245, 219, 79, 0.18);
  color: var(--bold-gold);
}

/* ── Shared design mode ──────────────────────────────────────────────────── */

/* Opened from a design link: the racket is already dressed, so everything that
   changes or exports a design steps aside and only the colour picker remains. */

.shared-note {
  display: none;
  margin: 16px 2px 0;
  color: var(--gray-500);
  font-size: 12px;
  line-height: 1.5;
}

.is-shared #action-overgrip,
.is-shared #panel-overgrip,
.is-shared #action-tape,
.is-shared #panel-tape,
.is-shared #action-share,
.is-shared .renders {
  display: none;
}

.is-shared .shared-note {
  display: block;
}

/* ── 3D viewport ─────────────────────────────────────────────────────────── */

#container {
  position: relative;
  flex: 1;
  height: 100vh;
  min-width: 0;
  background: linear-gradient(135deg, var(--bold-black) 0%, var(--gray-900) 50%, var(--bold-black) 100%);
}

#container canvas {
  display: block;
}

#loading-bar-container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#loading-bar {
  width: 0%;
  height: 4px;
  margin-bottom: 10px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--bold-red) 0%, var(--bold-gold) 100%);
  transition: width 0.3s ease;
}

#loading-text {
  color: var(--gray-400);
  font-size: 13px;
}

#controls-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  padding: 7px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 9999px;
  background-color: rgba(0, 0, 0, 0.5);
  color: var(--gray-400);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  body {
    flex-direction: column;
  }

  #sidebar {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: 55vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  #container {
    height: auto;
  }
}
