/* =============================================================
   CrafterzSMP – Skin Studio
   ============================================================= */

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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #14141f;
  --bg-card: #16162a;
  --bg-surface: #1e1e35;
  --bg-sunken: #101020;
  --accent: #5eead4;
  --accent-dim: #2dd4bf;
  --accent-glow: rgba(94, 234, 212, 0.14);
  --text-primary: #e6ecf5;
  --text-secondary: #98a6bf;
  --text-muted: #64718c;
  --border: #272742;
  --border-soft: #1f1f36;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  --max-width: 1240px;
  --nav-height: 64px;
}

html { scroll-behavior: smooth; scroll-padding-top: var(--nav-height); }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- utilities ---------------------------------------------- */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.text-accent { color: var(--accent); }
.section-title { font-size: 2.25rem; font-weight: 800; text-align: center; margin-bottom: 1rem; letter-spacing: -0.02em; }
.section-subtitle { font-size: 1.0625rem; color: var(--text-secondary); text-align: center; max-width: 620px; margin: 0 auto 3rem; }

/* --- buttons ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; font-family: var(--font-sans);
  text-decoration: none; cursor: pointer; border: 2px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #0b0b14; border-color: var(--accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-dim); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--text-primary); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn--small { padding: 7px 14px; font-size: .875rem; border-radius: var(--radius-sm); }

/* --- nav ---------------------------------------------------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
  background: rgba(15, 15, 26, .86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft); z-index: 100;
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.nav__logo { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.nav__logo-icon { font-size: 1.4rem; }
.nav__links { display: flex; gap: 4px; }
.nav__link { padding: 8px 14px; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-weight: 500; font-size: .9375rem; transition: color .18s, background .18s; }
.nav__link:hover { color: var(--accent); background: var(--accent-glow); }

/* --- hero --------------------------------------------------- */
.hero { position: relative; min-height: 82vh; display: flex; align-items: center; overflow: hidden; }
.hero__bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(94,234,212,.08), transparent),
    radial-gradient(ellipse 60% 50% at 82% 78%, rgba(45,212,191,.06), transparent);
}
.hero__inner { position: relative; padding-top: var(--nav-height); }
.hero__content { max-width: 720px; }
.hero__title { font-size: clamp(2.4rem, 6vw, 4.25rem); font-weight: 900; line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 1.25rem; }
.hero__subtitle { font-size: 1.0625rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 2rem; max-width: 600px; }
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* --- features ----------------------------------------------- */
.features { padding: 88px 0; background: var(--bg-secondary); }
.features__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-top: 2.5rem; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 28px 22px; transition: border-color .25s, transform .25s; }
.feature-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.feature-card__icon { font-size: 2.25rem; margin-bottom: .75rem; }
.feature-card__title { font-size: 1.125rem; font-weight: 700; margin-bottom: .4rem; }
.feature-card__desc { color: var(--text-secondary); font-size: .9375rem; }

/* =============================================================
   Skin Studio
   ============================================================= */
.studio { padding: 88px 0; }

.studio__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.panel__head h3 { font-size: .9375rem; font-weight: 700; letter-spacing: .01em; }
.panel__head-tools { display: flex; align-items: center; gap: 6px; }

.panel__foot { padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.panel__foot--split { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* --- 3D viewport -------------------------------------------- */
.viewport {
  position: relative;
  min-height: 430px;
  background: radial-gradient(circle at 50% 42%, #1c1c33 0%, #0d0d18 100%);
  cursor: crosshair;
  touch-action: none;
  flex: 1;
}
.viewport canvas { display: block; }
.viewport__hint {
  position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; font-size: .75rem; color: var(--text-muted);
  pointer-events: none; letter-spacing: .02em;
}

/* --- segmented controls ------------------------------------- */
.segmented {
  display: inline-flex; background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px; gap: 2px;
}
.seg {
  appearance: none; border: 0; background: transparent;
  color: var(--text-muted); font-family: var(--font-sans);
  font-size: .8125rem; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  transition: background .16s, color .16s;
}
.seg:hover { color: var(--text-secondary); }
.seg--on { background: var(--bg-surface); color: var(--accent); }

/* --- texture editor ----------------------------------------- */
.texture-scroll {
  overflow: auto;
  max-height: 430px;
  min-height: 320px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-sunken);
}
#skinCanvas {
  image-rendering: pixelated;
  cursor: crosshair;
  border-radius: 4px;
  touch-action: none;
  flex: 0 0 auto;
}
.zoom-label { font-size: .75rem; color: var(--text-muted); min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }

/* --- tool buttons ------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.toolbar__sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.tool-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  cursor: pointer; font-size: .9375rem; line-height: 1;
  transition: border-color .16s, background .16s, opacity .16s;
}
.tool-btn:hover:not(:disabled) { border-color: var(--accent); }
.tool-btn:disabled { opacity: .35; cursor: not-allowed; }
.tool-btn--active { border-color: var(--accent); background: var(--accent-glow); }

/* --- brush / palette ---------------------------------------- */
.brush-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.brush-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.brush-row input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.brush-value { font-size: .75rem; color: var(--text-secondary); min-width: 30px; font-variant-numeric: tabular-nums; }

.palette { margin-top: 12px; }
.palette__swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 4px; }
.swatch {
  aspect-ratio: 1 / 1; width: 100%; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.10); cursor: pointer; padding: 0;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.14); border-color: var(--accent); }

.palette__custom { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.palette__custom label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.palette__custom input[type=color] {
  width: 38px; height: 30px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-surface); cursor: pointer;
}
.color-text {
  width: 92px; padding: 5px 8px; font-family: var(--font-mono); font-size: .8125rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary); text-transform: lowercase;
}
.color-text:focus { outline: none; border-color: var(--accent); }

/* --- grab / presets / export bar ---------------------------- */
.studio__bar {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.studio__bar label {
  display: block; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted); font-weight: 700; margin-bottom: 8px;
}
.grab__row { display: flex; gap: 8px; flex-wrap: wrap; }
.grab__row input[type=text] {
  flex: 1 1 160px; min-width: 0;
  padding: 8px 12px; font-family: var(--font-sans); font-size: .9375rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
}
.grab__row input[type=text]:focus { outline: none; border-color: var(--accent); }
.grab__status { font-size: .8125rem; color: var(--text-secondary); margin-top: 8px; min-height: 1.2em; }
.grab__status--error { color: var(--danger); }

.presets__row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn {
  padding: 7px 14px; font-size: .8125rem; font-family: var(--font-sans);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  cursor: pointer; transition: border-color .16s, color .16s;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }

.export { align-self: center; }

/* --- join --------------------------------------------------- */
.join { padding: 88px 0; background: var(--bg-secondary); }
.join__card { max-width: 620px; margin: 2.5rem auto 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; text-align: center; }
.join__ip { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 1.75rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--border-soft); }
.join__label { font-size: .8125rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.join__address { font-family: var(--font-mono); font-size: 1.125rem; color: var(--accent); font-weight: 700; background: var(--bg-surface); padding: 8px 18px; border-radius: var(--radius-sm); }
.join__steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 1.75rem; text-align: left; }
.join__step { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--bg-surface); border-radius: var(--radius-sm); }
.join__step-num { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #0b0b14; font-weight: 800; border-radius: 50%; flex-shrink: 0; font-size: .875rem; }
.join__step p { font-size: .9375rem; color: var(--text-secondary); }
.join__note { font-size: .875rem; color: var(--text-muted); }

/* --- footer ------------------------------------------------- */
.footer { padding: 36px 0; border-top: 1px solid var(--border-soft); }
.footer__inner { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.footer__brand { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 700; }
.footer__copy { font-size: .8125rem; color: var(--text-muted); }

/* --- toast -------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--bg-card); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 24px;
  color: var(--accent); font-weight: 600; opacity: 0;
  transition: all .28s ease; z-index: 200; pointer-events: none;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { border-color: var(--danger); color: var(--danger); }

/* --- responsive --------------------------------------------- */
@media (max-width: 1000px) {
  .studio__layout { grid-template-columns: minmax(0, 1fr); }
  .studio__bar { grid-template-columns: minmax(0, 1fr); }
  .export { align-self: stretch; }
  .export .btn { width: 100%; }
}

@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .section-title { font-size: 1.75rem; }
  .section-subtitle { font-size: .9375rem; margin-bottom: 2rem; }
  .features, .studio, .join { padding: 60px 0; }
  .nav__logo { font-size: 1.05rem; }
  .nav__logo-icon { font-size: 1.2rem; }
  .nav__link { padding: 6px 10px; font-size: .8125rem; }
  .viewport { min-height: 340px; }
  .texture-scroll { max-height: 360px; min-height: 260px; }
  .join__card { padding: 24px 18px; }
  .join__address { font-size: .9375rem; padding: 6px 12px; }
  .panel__foot--split { justify-content: center; }
  .hero__actions .btn { padding: 10px 20px; font-size: .9375rem; }
}

@media (max-width: 460px) {
  .nav__links .nav__link:first-child { display: none; }
  .nav__link { padding: 6px 8px; font-size: .75rem; }
  .toolbar { gap: 4px; }
  .tool-btn { width: 31px; height: 31px; font-size: .875rem; }
}
