/* ============================================================
   TIPÓ — Shared Design System
   ============================================================ */

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600;700&display=swap');

:root[data-theme="dark"] {
  --bg-0: #0C0C0A;
  --bg-1: #141412;
  --bg-2: #1C1C1A;
  --bg-3: #222220;
  --border-1: #222220;
  --border-2: #333330;
  --border-3: #4A4A44;
  --text-0: #E8E4E0;
  --text-1: #D8D4D0;
  --text-2: #AAA6A0;
  --text-3: #888480;
  --text-4: #666260;
  --text-5: #555250;
  --text-6: #444240;
  --accent: #2A8A7A;
  --accent-dim: rgba(42,138,122,0.06);
  --accent-brand: #99E0D2;
  --accent-warm: #D4A040;
  --red: #CC4840;
  --green: #3A7848;
}

:root, :root[data-theme="light"] {
  --bg-0: #F8F5F0;
  --bg-1: #EEEAE4;
  --bg-2: #E2DED6;
  --bg-3: #D8D4CC;
  --border-1: #D8D4CC;
  --border-2: #C4C0B8;
  --border-3: #AAA6A0;
  --text-0: #1A1818;
  --text-1: #2A2826;
  --text-2: #5A5650;
  --text-3: #7A7670;
  --text-4: #9A9690;
  --text-5: #AAA6A0;
  --text-6: #BAB6B0;
  --accent: #1B7A6A;
  --accent-dim: rgba(27,122,106,0.06);
  --accent-brand: #2A8A7A;
  --accent-warm: #B08830;
  --red: #BB3830;
  --green: #2E6838;
}

:root {
  --font-ui: 'IBM Plex Mono', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --panel-width: 320px;
}

/* Theme toggle button */
.tipo-theme-toggle {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 200;
  width: 32px; height: 32px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-ui);
  line-height: 1;
  padding: 0;
}
.tipo-theme-toggle:hover { border-color: var(--accent); color: var(--text-0); }

/* Back button (returns to landing-page menu) */
.tipo-back-btn {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  width: 32px; height: 32px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-ui);
  line-height: 1;
  text-decoration: none;
}
.tipo-back-btn:hover { border-color: var(--accent); color: var(--text-0); }

body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-ui);
  overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-3); border-radius: 3px; }

/* ============================================================
   CONTROL PANEL
   ============================================================ */
.tipo-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
}

.tipo-panel h1 {
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-0);
  padding-bottom: 10px;
  padding-left: 36px; /* clears the floating back button */
  border-bottom: 1px solid var(--border-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tipo-panel h1 a {
  font-size: 9px;
  color: var(--text-4);
  text-decoration: none;
  letter-spacing: 1px;
}
.tipo-panel h1 a:hover { color: var(--accent); }

/* Sections */
.section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-brand);
  font-weight: 600;
  margin-bottom: 4px;
}

.section-divider {
  border-top: 1px solid var(--border-1);
  padding-top: 16px;
  margin-top: 10px;
}

/* Labels */
label {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

label.checkbox-label {
  cursor: pointer;
  user-select: none;
}

label.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* Inputs */
select {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-ui);
  width: 100%;
  outline: none;
}
select:hover { border-color: var(--border-3); }

textarea, input[type="text"] {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text-0);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-mono);
  width: 100%;
  outline: none;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus { border-color: var(--accent); }

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text-0);
  border-radius: 50%;
  cursor: pointer;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-row input[type="range"] { flex: 1; }
.range-value {
  font-size: 11px;
  color: var(--text-4);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.range-label {
  font-size: 10px;
  color: var(--text-4);
  min-width: 80px;
}

/* Color picker */
input[type="color"] {
  -webkit-appearance: none;
  border: 1px solid var(--border-2);
  width: 40px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 2px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

/* Editable hex field next to each color picker (added by TipoUI.initHexInputs) */
.tipo-hex-input {
  width: 56px;
  flex: 0 1 56px;
  min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 5px;
  text-transform: lowercase;
}
.tipo-hex-input:focus { outline: none; border-color: var(--accent); color: var(--text-0); }

/* Let color rows wrap when the hex fields don't fit */
.color-section-row, .color-row, .color-level-row, .color-grid { flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  background: var(--text-0);
  color: var(--bg-0);
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  transition: background 0.15s;
}
.btn:hover { background: var(--text-2); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-0);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--border-2); }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* Preset chips */
.preset-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-2);
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s;
  font-family: var(--font-ui);
}
.preset-chip:hover { border-color: var(--accent); color: var(--text-0); }
.preset-chip.active { border-color: var(--accent); color: var(--accent); }

/* Swap button */
.swap-btn {
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 4px;
  color: var(--text-2); font-size: 14px; cursor: pointer; padding: 4px 10px;
  transition: all 0.15s; font-family: var(--font-ui); line-height: 1;
}
.swap-btn:hover { border-color: var(--accent); color: var(--text-0); }
.color-section-row {
  display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   CANVAS AREA
   ============================================================ */
.tipo-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  overflow: auto;
  position: relative;
}

/* Drop zone */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 2px dashed var(--border-2);
  margin: 20px;
  border-radius: 12px;
  color: var(--text-5);
  font-size: 14px;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.drop-zone.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.drop-zone.hidden { display: none; }

/* FPS counter */
.fps-counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.7);
  color: var(--green);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  display: none;
}

/* ============================================================
   OVERLAYS
   ============================================================ */

/* Toast notification */
.tipo-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 100;
  font-family: var(--font-ui);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.3, .9, .3, 1);
}
.tipo-toast.show { opacity: 1; transform: translateY(0); }

/* Progress overlay */
.tipo-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
}
.tipo-progress-overlay.open { display: flex; }

.progress-box {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 32px 40px;
  min-width: 360px;
  text-align: center;
}
.progress-title {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-0);
  margin-bottom: 16px;
}
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}
.progress-info {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* Record timer */
.record-timer {
  font-size: 11px;
  color: var(--red);
  text-align: center;
  display: none;
  font-family: var(--font-mono);
}

/* ============================================================
   MODAL
   ============================================================ */
.tipo-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
}
.tipo-modal.open { display: flex; }

.modal-content {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: 640px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-1);
}
.modal-header h2 {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-0);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-4);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text-0); }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-1);
  padding: 0 20px;
}
.modal-tab {
  padding: 10px 16px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-4);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.modal-tab:hover { color: var(--text-2); }
.modal-tab.active { color: var(--text-0); border-bottom-color: var(--accent); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.tipo-landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 40px;
  overflow-y: auto;
}

.tipo-logo {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text-0);
  margin-bottom: 8px;
}
.tipo-tagline {
  font-size: 13px;
  color: var(--text-4);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 60px;
}

.tipo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1200px;
}

.tipo-card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 10px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tipo-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.tipo-card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-0);
}
.tipo-card-desc {
  font-size: 11px;
  color: var(--text-4);
  line-height: 1.5;
}
.tipo-card-tag {
  font-size: 9px;
  color: var(--text-5);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 4px;
}

.tipo-section-title {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-5);
  margin-bottom: 16px;
  margin-top: 40px;
  width: 100%;
  max-width: 1200px;
}

/* ============================================================
   RESPONSIVE — Mobile bottom sheet (Fase 13.2)
   The side panel becomes a draggable bottom sheet: a 54px grip
   peeks at the bottom; tap or drag opens it over the canvas.
   TipoMobile (ui.js) injects the grip and wires the gestures.
   ============================================================ */
@media (max-width: 768px) {
  .tipo-panel, #controlPanel {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;     /* pages with their own panel CSS (dithering) set height:100vh */
    max-height: 68vh !important;
    z-index: 300;
    transform: translateY(calc(100% - 54px));
    transition: transform 0.28s cubic-bezier(.3, .9, .3, 1);
    border-right: none !important;
    border-top: 1px solid var(--border-2);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.28);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tipo-panel.sheet-open, #controlPanel.sheet-open {
    transform: translateY(0);
    height: 46vh !important;   /* half-sheet: canvas stays visible above */
    max-height: 46vh !important;
  }
  body.tipo-sheet-open #canvasContainer:not([data-tipo-fmt]),
  body.tipo-sheet-open #canvasWrap:not([data-tipo-fmt]),
  body.tipo-sheet-open #canvasArea:not([data-tipo-fmt]) {
    height: 54vh !important;
  }
  .tipo-panel.sheet-drag, #controlPanel.sheet-drag { transition: none; }
  #canvasContainer:not([data-tipo-fmt]), #canvasWrap:not([data-tipo-fmt]) { width: 100vw !important; }
  .tipo-panel h1 { padding-left: 0; }
  .tipo-eyebrow { padding-left: 0; }

  .tipo-sheet-grip {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 54px;
    margin: -20px -20px 10px;
    padding: 0 20px;
    background: var(--bg-1);
    cursor: grab;
    touch-action: none;
    z-index: 6;
    user-select: none;
    -webkit-user-select: none;
  }
  .tipo-sheet-bar {
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-2);
  }
  .tipo-sheet-label {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-5);
  }
  .sheet-open .tipo-sheet-label { color: var(--accent); }

  /* collapsible sections: everything starts folded except the essentials */
  .tipo-mobile .section > .section-title { cursor: pointer; position: relative; }
  .tipo-mobile .section > .section-title::after {
    content: '▾';
    position: absolute;
    right: 0;
    color: var(--text-5);
    font-size: 10px;
  }
  .tipo-mobile .section.sec-collapsed > .section-title::after { content: '▸'; }
  .tipo-mobile .section.sec-collapsed > *:not(.section-title) { display: none !important; }

  /* touch targets */
  .tipo-mobile .btn { min-height: 44px; }
  .tipo-mobile .preset-chip { padding: 10px 14px; }
  .tipo-mobile select { min-height: 40px; }
  .tipo-mobile input[type="text"] { min-height: 42px; font-size: 16px; } /* 16px kills iOS zoom-on-focus */
  .tipo-mobile input[type="range"] { height: 30px; }
  .tipo-mobile input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
  .tipo-mobile input[type="color"] { width: 36px; height: 32px; }
  .tipo-mobile .tipo-toast { bottom: 68px; }
  .tipo-mobile .tipo-back-btn { top: 12px; }

  /* mobile declutter: keyframes/behaviors/hex are desktop-grade tools */
  .tipo-mobile .tipo-tl-toggle, .tipo-mobile #tipoTL { display: none !important; }
  .tipo-mobile .tipo-bhv-btn { display: none !important; }
  .tipo-mobile .tipo-hex-input { display: none !important; }
  .tipo-mobile .tipo-fmt-btn { display: none !important; } /* replaced by chips in the sheet */
}

/* ============================================================
   MICRO-INTERACTIONS — tactile controls (2026-07-11)
   ============================================================ */
.preset-chip { transition: transform .15s ease, border-color .15s ease, color .15s ease, background .15s ease; }
.preset-chip:hover { transform: translateY(-1px); }
.preset-chip:active { transform: translateY(0) scale(.96); }
.btn { transition: transform .12s ease, border-color .15s ease, background .15s ease, color .15s ease; }
.btn:active { transform: scale(.97); }
input[type="range"]::-webkit-slider-thumb { transition: transform .12s ease; }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.2); }
@media (prefers-reduced-motion: reduce) {
  .preset-chip, .btn, input[type="range"]::-webkit-slider-thumb { transition: none; }
}

/* smooth theme swap: TipoUI adds .theme-anim to <html> for ~350ms on toggle */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease, box-shadow .25s ease !important;
}

/* gold dot signature after every tool title (echoes the TIPÓ• logo) */
.tipo-h1-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #D4A040;
  margin-left: 8px;
  margin-right: auto;
  align-self: center;
  animation: tipoDotPulse 3.2s ease-in-out infinite;
}
@keyframes tipoDotPulse {
  0%, 100% { transform: scale(1); opacity: .8; }
  50% { transform: scale(1.5); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .tipo-h1-dot { animation: none; } }

/* ============================================================
   Fase 20 — identidade da página da ferramenta
   Eyebrow de categoria (contexto no topo esquerdo do painel)
   + crédito discreto no rodapé da área de trabalho
   ============================================================ */
.tipo-eyebrow {
  display: flex; align-items: baseline; gap: 7px;
  font-family: var(--font-ui, 'IBM Plex Mono', monospace);
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-5); margin: 0 0 6px;
  padding-left: 36px; /* alinha com o h1, livre do botão ← flutuante */
}
.tipo-eyebrow a { color: var(--text-5); text-decoration: none; transition: color 0.2s; }
.tipo-eyebrow a:hover { color: var(--accent); }
.tipo-eyebrow span { color: var(--text-6); }
.tipo-eyebrow a.cat {
  color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: 2.5px;
}

.tipo-made {
  position: fixed; right: 16px; bottom: 12px; z-index: 40;
  font-family: var(--font-ui, 'IBM Plex Mono', monospace);
  font-size: 8px; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--text-5); text-decoration: none; opacity: 0.75;
  transition: opacity 0.2s, color 0.2s;
}
.tipo-made b { font-weight: 700; color: var(--text-4); }
.tipo-made:hover { opacity: 1; color: var(--accent); }
.tipo-made:hover b { color: var(--accent); }
/* não competir com o sheet mobile nem com o fullscreen */
body.tipo-mobile .tipo-made, body.tipo-full .tipo-made { display: none; }
