/* ============================================================
   Coding.Tools — Shared Stylesheet
   Warm Paper aesthetic. Cream backgrounds, terracotta accents,
   serif headings. Editorial and organic.
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --bg: #faf8f0;
  --surface: #ffffff;
  --text-primary: #2c2416;
  --text-secondary: #6b5e4f;
  --text-muted: #a09585;
  --accent: #c45d3a;
  --accent-light: #fdf0eb;
  --accent-hover: #a84a2e;
  --secondary: #2d6a4f;
  --secondary-light: #e8f5ee;
  --cat-image: #7c6a5b;
  --cat-formatter: #2d6a4f;
  --cat-internet: #3d7a8a;
  --cat-hash: #b8860b;
  --cat-number: #2d6a4f;
  --cat-text: #8b4a5e;
  --border: #e8e0d4;
  --success: #2d6a4f;
  --error: #c45d3a;
  --code-bg: #f5f0e8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(44, 36, 22, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(44, 36, 22, 0.08),
               0 2px 4px -2px rgba(44, 36, 22, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(44, 36, 22, 0.1),
               0 4px 6px -4px rgba(44, 36, 22, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(44, 36, 22, 0.1),
               0 8px 10px -6px rgba(44, 36, 22, 0.05);
}

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

/* --- Base --- */
body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
  position: relative;
}

/* Subtle grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: "Fraunces", serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

code, pre {
  font-family: "IBM Plex Mono", monospace;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: rgba(250, 248, 240, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(44, 36, 22, 0.06);
}

.navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.navbar > .inner {
  max-width: 1200px;
  margin: auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.navbar-brand svg {
  color: var(--accent);
}

.navbar-links {
  display: flex;
  gap: 8px;
}

.navbar-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.navbar-links a:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 100px 32px 60px;
  text-align: center;
  background: linear-gradient(180deg, #f5f0e8 0%, var(--bg) 100%);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--accent), #d4725a);
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
}

.hero-title {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #2c2416 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

.hero-search {
  max-width: 480px;
  margin: 32px auto 0;
  position: relative;
}

.hero-search input {
  width: 100%;
  height: 56px;
  padding: 0 20px 0 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(196, 93, 58, 0.06), var(--shadow-sm);
  transition: all 0.25s;
  outline: none;
  color: var(--text-primary);
}

.hero-search input::placeholder {
  color: var(--text-muted);
}

.hero-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(196, 93, 58, 0.1), 0 4px 16px rgba(196, 93, 58, 0.08);
}

.hero-search .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   Category Sections
   ============================================================ */
.category-section {
  max-width: 1200px;
  margin: auto;
  padding: 0 32px 64px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.category-header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.category-header .category-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 10px;
  padding: 6px;
}

[data-category="image-utilities"] .category-icon { background: #f0ebe4; color: #7c6a5b; }
[data-category="formatter-minifier"] .category-icon { background: #e8f5ee; color: #2d6a4f; }
[data-category="hash-cryptography"] .category-icon { background: #faf0d4; color: #b8860b; }
[data-category="number-conversion"] .category-icon { background: #e8f5ee; color: #2d6a4f; }
[data-category="string-text-utilities"] .category-icon { background: #f5e8ee; color: #8b4a5e; }

[data-category="image-utilities"]   { border-left: 3px solid #7c6a5b; padding-left: 24px; border-radius: 0 0 0 8px; }
[data-category="formatter-minifier"] { border-left: 3px solid #2d6a4f; padding-left: 24px; border-radius: 0 0 0 8px; }
[data-category="hash-cryptography"]  { border-left: 3px solid #b8860b; padding-left: 24px; border-radius: 0 0 0 8px; }
[data-category="number-conversion"]  { border-left: 3px solid #2d6a4f; padding-left: 24px; border-radius: 0 0 0 8px; }
[data-category="string-text-utilities"] { border-left: 3px solid #8b4a5e; padding-left: 24px; border-radius: 0 0 0 8px; }

.category-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ============================================================
   Tool Grid
   ============================================================ */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Tool Cards
   ============================================================ */
.tool-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tool-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color 0.15s;
}

.tool-card-arrow {
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.2s;
  color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(44, 36, 22, 0.06), 0 8px 10px -6px rgba(44, 36, 22, 0.04);
  border-color: rgba(196, 93, 58, 0.3);
}

[data-category="image-utilities"] .tool-card:hover    { border-color: #7c6a5b; border-left: 3px solid #7c6a5b; box-shadow: 0 8px 24px rgba(124, 106, 91, 0.15); }
[data-category="formatter-minifier"] .tool-card:hover { border-color: #2d6a4f; border-left: 3px solid #2d6a4f; box-shadow: 0 8px 24px rgba(45, 106, 79, 0.15); }
[data-category="hash-cryptography"] .tool-card:hover  { border-color: #b8860b; border-left: 3px solid #b8860b; box-shadow: 0 8px 24px rgba(184, 134, 11, 0.15); }
[data-category="number-conversion"] .tool-card:hover  { border-color: #2d6a4f; border-left: 3px solid #2d6a4f; box-shadow: 0 8px 24px rgba(45, 106, 79, 0.15); }
[data-category="string-text-utilities"] .tool-card:hover { border-color: #8b4a5e; border-left: 3px solid #8b4a5e; box-shadow: 0 8px 24px rgba(139, 74, 94, 0.15); }

.tool-card:hover .tool-card-name {
  color: var(--accent);
}

.tool-card:hover .tool-card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Hidden state for search filter */
.tool-card.hidden {
  display: none;
}

/* ============================================================
   Scroll Animations
   ============================================================ */
.category-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.category-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.tool-card {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.tool-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.tool-card:nth-child(1)  { transition-delay: 0s; }
.tool-card:nth-child(2)  { transition-delay: 0.03s; }
.tool-card:nth-child(3)  { transition-delay: 0.06s; }
.tool-card:nth-child(4)  { transition-delay: 0.09s; }
.tool-card:nth-child(5)  { transition-delay: 0.12s; }
.tool-card:nth-child(6)  { transition-delay: 0.15s; }
.tool-card:nth-child(7)  { transition-delay: 0.18s; }
.tool-card:nth-child(8)  { transition-delay: 0.21s; }
.tool-card:nth-child(9)  { transition-delay: 0.24s; }
.tool-card:nth-child(10) { transition-delay: 0.27s; }
.tool-card:nth-child(11) { transition-delay: 0.30s; }
.tool-card:nth-child(12) { transition-delay: 0.33s; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: linear-gradient(180deg, var(--surface) 0%, #f5f0e8 100%);
  border-top: 1px solid var(--border);
  padding: 40px 32px;
  text-align: center;
}

.footer-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 2;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--accent);
}

/* ============================================================
   Tool Page Layout
   ============================================================ */
.tool-layout {
  max-width: 1200px;
  margin: auto;
  padding: 0 32px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.tool-main {
  flex: 1;
  min-width: 0;
}

.tool-sidebar {
  width: 280px;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .tool-layout {
    flex-direction: column;
  }

  .tool-sidebar {
    width: 100%;
  }
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
  padding: 24px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span {
  color: var(--text-secondary);
  margin: 0 8px;
}

/* ============================================================
   Tool Header
   ============================================================ */
.tool-header {
  margin-bottom: 32px;
}

.tool-header h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.editor-wrapper {
  margin-bottom: 16px;
}

/* ============================================================
   Toolbar
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

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

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 93, 58, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Secondary button — forest green */
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

/* ============================================================
   Status Bar
   ============================================================ */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 13px;
}

.status-message {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ============================================================
   Sidebar Cards
   ============================================================ */
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

/* ============================================================
   Description Section
   ============================================================ */
.description-section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
  max-width: 800px;
}

.description-section h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}

.description-section h3 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.description-section p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}

.description-section .steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
}

.description-section .steps li {
  counter-increment: step;
  padding: 12px 0;
  padding-left: 40px;
  position: relative;
  color: var(--text-secondary);
  line-height: 1.7;
}

.description-section .steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  width: 28px;
  height: 28px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: "DM Sans", sans-serif;
}

.code-block {
  background: var(--code-bg);
  border-radius: var(--radius-md);
  padding: 20px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
  border: 1px solid var(--border);
}

/* ============================================================
   Toast Notification
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  background: var(--text-primary);
  color: #faf8f0;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hero-badge {
  animation: fadeInUp 0.6s ease forwards;
}

.hero-title {
  animation: fadeInUp 0.6s ease 0.1s forwards;
  opacity: 0;
}

.hero-subtitle {
  animation: fadeInUp 0.6s ease 0.2s forwards;
  opacity: 0;
}

.hero-search {
  animation: fadeInUp 0.6s ease 0.3s forwards;
  opacity: 0;
}

/* ============================================================
   Responsive — Navbar & Hero tweaks
   ============================================================ */
@media (max-width: 768px) {
  .navbar > .inner {
    padding: 0 20px;
  }

  .hero {
    padding: 72px 20px 48px;
  }

  .hero-title {
    font-size: 36px;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .category-section {
    padding: 0 20px 48px;
  }

  .category-header h2 {
    font-size: 22px;
  }

  .tool-layout {
    padding: 0 20px;
  }

  .footer {
    padding: 32px 20px;
  }
}
