/* ============================================================
   JSONify – style.css
   Sections:
   1.  Tokens
   2.  Reset & Base
   3.  Background Orbs
   4.  Header
   5.  Main Layout
   6.  Hero
   7.  Toolbar
   8.  Segmented control & indent selector
   9.  Status bar
   10. Editor grid & panels
   11. Line numbers
   12. Textarea (input)
   13. Pre (formatted output)
   14. Syntax highlighting
   15. Tree view
   16. Action buttons
   17. Ad slots
   18. Toast
   19. Animations & Keyframes
   20. Responsive
   ============================================================ */


/* ── 1. Tokens ── */
:root {
  --red:        #e34949;
  --red-dim:    #c93c3c;
  --red-glow:   rgba(227,73,73,0.25);
  --logo-glow: rgba(29, 228, 59, 0.25);

  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-2:    #fafafa;
  --border:       rgba(0,0,0,0.08);
  --text:         #1d1d1f;
  --text-2:       #6e6e73;
  --text-3:       #aeaeb2;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:    0 8px 32px rgba(0,0,0,0.10);
  --shadow-lg:    0 24px 64px rgba(0,0,0,0.12);
  --glass:        rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);

  /* Syntax colours — light theme */
  --syn-key:    #c93c3c;
  --syn-str:    #2e7d32;
  --syn-num:    #1565c0;
  --syn-bool:   #6a1f9e;
  --syn-null:   #777;

  /* Error */
  --error-bg:   rgba(227,73,73,0.07);
  --error-border:#e34949;

  /* Valid */
  --valid-color: #34c759;
}

[data-theme="dark"] {
  --bg:           #000000;
  --surface:      #1c1c1e;
  --surface-2:    #2c2c2e;
  --border:       rgba(255,255,255,0.08);
  --text:         #f5f5f7;
  --text-2:       #aeaeb2;
  --text-3:       #636366;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:    0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg:    0 24px 64px rgba(0,0,0,0.6);
  --glass:        rgba(28,28,30,0.8);
  --glass-border: rgba(255,255,255,0.08);

  --syn-key:    #ff6b6b;
  --syn-str:    #69db7c;
  --syn-num:    #74c0fc;
  --syn-bool:   #cc99ff;
  --syn-null:   #999;
}


/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
}


/* ── 3. Background Orbs ── */
.bg-orbs {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}

.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.18;
  animation: orb-drift 18s ease-in-out infinite alternate;
}

.orb-1 { width: 500px; height: 500px; background: var(--red); top: -120px; right: -100px; }
.orb-2 { width: 350px; height: 350px; background: #1d1d1f; bottom: 100px; left: -80px; animation-delay: -6s; }
[data-theme="dark"] .orb-2 { background: #555; }


/* ── 4. Header ── */
header {
  position: sticky; top: 0; z-index: 100;
  height: 60px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.35s ease, border-color 0.35s ease;
}

.logo-wrap {
  display: flex; align-items: center; gap: 10px;
  animation: fade-down 0.5s ease both;
}

.logo-icon {
  /* width: 34px; height: 34px; */
  /* background: var(--red); */
  border-radius: 80px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px var(--logo-glow);
  overflow: hidden;
  transition: transform 0.2s ease;
  cursor: pointer; flex-shrink: 0;
}

.logo-icon:hover { transform: rotate(-6deg) scale(1.08); }
.logo-icon img { width: 34px; height: 34px; object-fit: contain; display: block; border-radius:80px;}

.logo-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); }
.logo-name span { color: var(--red); }

.theme-toggle {
  position: relative;
  width: 44px; height: 26px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease;
  animation: fade-down 0.5s 0.1s ease both;
}

.theme-toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), background 0.3s ease;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(18px); background: var(--red);
}

.toggle-icons {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 5px; pointer-events: none;
  font-size: 9px; color: var(--text-3);
}


/* ── 5. Main Layout ── */
main {
  position: relative; z-index: 1;
  max-width: 1300px; margin: 0 auto;
  padding: 40px 24px 32px;
}


/* ── 6. Hero ── */
.hero {
  text-align: center; margin-bottom: 28px;
  animation: fade-up 0.6s ease both;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700; letter-spacing: -0.04em; line-height: 1.1;
}

.hero h1 em { font-style: normal; color: var(--red); }
.hero p { margin-top: 10px; font-size: 0.95rem; color: var(--text-2); }


/* ── 7. Toolbar ── */
.toolbar {
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  margin-bottom: 12px;
  animation: fade-up 0.6s 0.08s ease both;
}

.toolbar-left, .toolbar-right {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}


/* ── 8. Segmented control & indent selector ── */
.indent-wrap {
  display: flex; align-items: center; gap: 8px;
}

.control-label {
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
}

.seg-control {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px; gap: 2px;
}

.seg-btn {
  flex: 1; text-align: center;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.78rem; font-weight: 500;
  color: var(--text-2);
  cursor: pointer; border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn.active {
  background: var(--red); color: #fff;
  box-shadow: 0 2px 8px var(--red-glow);
}


/* ── 9. Status bar ── */
.status-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-2);
  margin-bottom: 14px;
  transition: border-color 0.3s ease, background 0.3s ease;
  animation: fade-up 0.6s 0.12s ease both;
  min-height: 36px;
}

.status-bar.valid   { border-color: var(--valid-color); }
.status-bar.error   { border-color: var(--error-border); background: var(--error-bg); }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); flex-shrink: 0;
  transition: background 0.3s ease;
}

.status-bar.valid .status-dot { background: var(--valid-color); }
.status-bar.error .status-dot { background: var(--error-border); }

#statusText { flex: 1; }

.status-meta {
  margin-left: auto; color: var(--text-3);
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
}


/* ── 10. Editor grid & panels ── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  animation: fade-up 0.6s 0.16s ease both;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.2s ease;
  display: flex; flex-direction: column;
}

.card:hover { box-shadow: var(--shadow-md); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0;
  flex-shrink: 0;
}

.card-label {
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
}

.panel-hint {
  font-size: 0.72rem; color: var(--text-3);
}

/* View tabs (Formatted / Tree) */
.view-tabs {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 2px;
}

.view-tab {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  border: none; background: transparent;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.view-tab.active {
  background: var(--red); color: #fff;
  box-shadow: 0 1px 6px var(--red-glow);
}


/* ── 11. Line numbers ── */
.editor-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 420px;
  max-height: 620px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.line-numbers {
  flex-shrink: 0;
  width: 42px;
  padding: 14px 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  text-align: right;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1.6;
  overflow: hidden;
  user-select: none;
}

.line-numbers span {
  display: block;
  padding: 0 8px 0 4px;
}


/* ── 12. Textarea (input) ── */
.editor-textarea {
  flex: 1;
  border: none; outline: none; resize: none;
  background: transparent;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
  padding: 14px 16px;
  overflow-y: auto;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
}

.editor-textarea::placeholder { color: var(--text-3); }

/* Error state */
.editor-textarea.has-error {
  background: var(--error-bg);
}


/* ── 13. Pre (formatted output) ── */
.editor-pre {
  flex: 1;
  margin: 0; border: none; outline: none;
  background: transparent;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 14px 16px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  color: var(--text);
}

.editor-pre:empty::before {
  content: 'Formatted output will appear here';
  color: var(--text-3);
  font-style: italic;
}


/* ── 14. Syntax highlighting ── */
.syn-key    { color: var(--syn-key);  font-weight: 500; }
.syn-str    { color: var(--syn-str);  }
.syn-num    { color: var(--syn-num);  }
.syn-bool   { color: var(--syn-bool); font-weight: 500; }
.syn-null   { color: var(--syn-null); font-style: italic; }
.syn-brace  { color: var(--text-2);   }


/* ── 15. Tree view ── */
.tree-view {
  flex: 1;
  overflow-y: auto; overflow-x: auto;
  padding: 14px 16px;
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  min-height: 420px;
  max-height: 620px;
}

.tree-node { display: block; }

.tree-toggle {
  cursor: pointer;
  user-select: none;
  display: inline-flex; align-items: center; gap: 4px;
}

.tree-toggle::before {
  content: '▾';
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-3);
  transition: transform 0.2s ease;
  width: 12px;
}

.tree-toggle.collapsed::before { transform: rotate(-90deg); }

.tree-children {
  padding-left: 20px;
  border-left: 1.5px solid var(--border);
  margin-left: 5px;
}

.tree-children.hidden { display: none; }

.tree-key   { color: var(--syn-key); font-weight: 500; }
.tree-str   { color: var(--syn-str); }
.tree-num   { color: var(--syn-num); }
.tree-bool  { color: var(--syn-bool); font-weight: 500; }
.tree-null  { color: var(--syn-null); font-style: italic; }
.tree-count { color: var(--text-3); font-size: 0.7rem; margin-left: 4px; }


/* ── 16. Action Buttons ── */
.btn-action {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn-action:hover {
  border-color: var(--red); color: var(--red);
  transform: translateY(-1px);
}

.btn-action:active { transform: translateY(0); }

.btn-action.primary {
  background: var(--red); color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--red-glow);
}

.btn-action.primary:hover { background: var(--red-dim); color: #fff; }

.btn-action.primary i { transition: transform 0.4s ease; }
.btn-action.primary:hover i { transform: rotate(20deg) scale(1.1); }


/* ── 17. Ad Slots ── */
.ads-row {
  margin-top: 24px; display: flex; gap: 16px;
  animation: fade-up 0.6s 0.22s ease both;
}

.ad-slot {
  flex: 1; height: 90px; border-radius: 14px;
  border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 0.75rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 500; background: var(--surface);
}


/* ── 18. Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: 30px;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; z-index: 999;
  white-space: nowrap; pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.35s ease;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }


/* ── 19. Animations & Keyframes ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0);     }
}

@keyframes orb-drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(30px,40px) scale(1.1); }
}


/* ── 20. Responsive ── */
@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-wrap,
  .tree-view   { min-height: 280px; max-height: 380px; }
}

@media (max-width: 600px) {
  header { padding: 0 16px; }
  main   { padding: 28px 14px 24px; }
  .toolbar { gap: 8px; }
  .toolbar-left, .toolbar-right { gap: 6px; }
  .btn-action { padding: 8px 12px; font-size: 0.78rem; }
  .indent-wrap { gap: 6px; }
  .hero h1 { font-size: 1.8rem; }
  .ads-row { flex-direction: column; }
  .ad-slot { height: 60px; }
}

@media (max-width: 420px) {
  .hero h1 { font-size: 1.5rem; }
  .hero p  { font-size: 0.82rem; }
  .toolbar-right { width: 100%; justify-content: flex-start; }
  .btn-action { padding: 7px 10px; font-size: 0.75rem; }
  .logo-name { font-size: 0.95rem; }
  /* .logo-icon { width: 28px; height: 28px; } */
  .logo-icon img { width: 28px; height: 28px; }
  .editor-textarea,
  .editor-pre { font-size: 0.75rem; }
  .line-numbers { width: 34px; font-size: 0.65rem; }
}

@media (max-width: 300px) {
  header { padding: 0 10px; height: 52px; }
  main   { padding: 20px 10px 16px; }
  .hero h1 { font-size: 1.25rem; letter-spacing: -0.02em; }
  .hero p  { font-size: 0.72rem; }
  .toolbar { gap: 6px; }
  .btn-action { padding: 6px 8px; font-size: 0.7rem; gap: 4px; border-radius: 8px; }
  .logo-name { font-size: 0.82rem; }
  /* .logo-icon { width: 26px; height: 26px; border-radius: 7px; } */
  .logo-icon img { width: 26px; height: 26px; }
  .theme-toggle { width: 38px; height: 22px; }
  .theme-toggle::after { width: 15px; height: 15px; }
  [data-theme="dark"] .theme-toggle::after { transform: translateX(13px); }
  .editor-textarea,
  .editor-pre { font-size: 0.7rem; padding: 10px; }
  .line-numbers { width: 28px; font-size: 0.6rem; }
  .status-bar { font-size: 0.7rem; padding: 6px 10px; }
  .seg-btn { padding: 4px 6px; font-size: 0.68rem; }
  .toast { font-size: 0.7rem; padding: 8px 12px; white-space: normal; text-align: center; max-width: 90vw; }
  .ad-slot { display: none; }
  .ads-row { margin-top: 12px; }
  .editor-wrap,
  .tree-view { min-height: 200px; max-height: 280px; }
}
