/* ==========================================================================
   Text Style Generator — design system
   Pure CSS. Light/dark themes via CSS custom properties on <html data-theme>.
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-soft: #f1f2f5;
  --text: #16181d;
  --text-soft: #5c6270;
  --text-faint: #8b91a0;
  --border: #e5e7ec;
  --border-strong: #d4d7de;

  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.10);
  --gradient: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 55%, #6d28d9 100%);

  --success: #16a34a;
  --danger: #dc2626;
  --heart: #f43f5e;

  --shadow-sm: 0 1px 2px rgba(16, 18, 27, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 18, 27, 0.07);
  --shadow-lg: 0 12px 40px rgba(16, 18, 27, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --header-h: 64px;
  --container: 1120px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-soft: #1a1e27;
  --text: #eef0f4;
  --text-soft: #9aa1b0;
  --text-faint: #6b7280;
  --border: #232833;
  --border-strong: #313847;

  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --gradient: linear-gradient(135deg, #60a5fa 0%, #818cf8 55%, #a5b4fc 100%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- Reset & base ---------- */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

main { flex: 1; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 16px;
  border-radius: var(--radius-sm); transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.logo {
  display: inline-flex; align-items: center;
  color: var(--text);
}
.logo:hover { text-decoration: none; }

/* BOLD·TEXT wordmark lockup (templates/_logo.html) */
.logo-lockup { display: flex; flex-direction: column; line-height: 1; }

.logo-word {
  display: inline-flex; align-items: baseline;
  font-size: 21px; letter-spacing: -0.01em; color: var(--text);
}
.logo-bold { font-weight: 900; }
.logo-light { font-weight: 300; letter-spacing: 0.08em; }

.logo-arrow {
  width: 12px; height: 14px;
  align-self: center; transform: translateY(1px);
  margin: 0 1px 0 2px; flex-shrink: 0;
}

.logo-tagline {
  margin-top: 4px;
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--text-soft);
}
.logo-tagline b { font-weight: 800; color: var(--text); }

.site-nav { display: flex; align-items: center; gap: 4px; }

.site-nav a {
  color: var(--text-soft); font-size: 14.5px; font-weight: 500;
  padding: 8px 12px; border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s;
}
.site-nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--bg-soft); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--text-soft);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* sun shown in dark mode (click → light), moon in light mode */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.nav-burger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 38px; height: 38px; padding: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.nav-burger span {
  display: block; height: 2px; border-radius: 2px;
  background: var(--text); transition: transform 0.2s var(--ease), opacity 0.2s;
}
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */

.hero { padding: 72px 0 40px; text-align: center; }

.hero-badge {
  display: inline-block;
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 5px 14px; border-radius: 999px; margin-bottom: 20px;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 3.75rem);
  font-weight: 800; letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 16px;
}

.hero-subtitle {
  max-width: 880px; margin: 0 auto;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--text-soft);
}

.page-hero { padding: 56px 0 28px; }
.page-hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); font-weight: 800; }
.page-hero p { color: var(--text-soft); max-width: 640px; }

.breadcrumbs { font-size: 13.5px; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span[aria-current] { color: var(--text-soft); }
.breadcrumbs > span[aria-hidden] { margin: 0 6px; }

/* ---------- Converter: input card ---------- */

.converter { padding-bottom: 24px; }

.input-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
}

.input-card textarea {
  display: block; width: 100%; resize: vertical;
  min-height: 96px; max-height: 320px;
  border: none; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 1.15rem;
  line-height: 1.5; padding: 4px;
}
.input-card textarea::placeholder { color: var(--text-faint); }

.input-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 14px;
  border-top: 1px solid var(--border);
}

.input-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.char-counter { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */

.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s,
              transform 0.15s var(--ease), box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-ghost {
  background: var(--bg-soft); color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-strong); box-shadow: var(--shadow-md); color: #fff; }

/* Ripple effect (span injected by JS on click) */
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: 0.25;
  transform: scale(0);
  animation: ripple 0.55s var(--ease) forwards;
}
@keyframes ripple {
  to { transform: scale(3); opacity: 0; }
}

/* ---------- Search / grid toolbar ---------- */

.grid-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin: 26px 0 18px;
}

.search-wrap {
  position: relative; flex: 1; min-width: 220px; max-width: 420px;
  display: flex; align-items: center;
}
.search-wrap svg {
  position: absolute; left: 12px; color: var(--text-faint); pointer-events: none;
}
.search-wrap input {
  width: 100%;
  font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 14px 9px 36px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.style-count { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Style cards grid ---------- */

.styles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding-bottom: 40px;
}

.style-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s, border-color 0.18s;
  animation: fade-up 0.4s var(--ease) both;
}
.style-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.style-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.style-name {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--text-faint); margin: 0;
}

.style-preview {
  font-size: 1.18rem; line-height: 1.5; min-height: 1.8em;
  word-break: break-word; overflow-wrap: anywhere; margin: 0;
}

.style-card-foot { display: flex; justify-content: flex-end; }

.copy-btn { min-width: 88px; justify-content: center; }
.copy-btn.copied {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
}

.fav-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: none; border-radius: 50%;
  color: var(--text-faint); cursor: pointer;
  transition: color 0.15s, transform 0.15s var(--ease), background-color 0.15s;
}
.fav-btn:hover { color: var(--heart); background: color-mix(in srgb, var(--heart) 10%, transparent); }
.fav-btn[aria-pressed="true"] { color: var(--heart); }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }
.fav-btn.pop { animation: heart-pop 0.35s var(--ease); }

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.no-results {
  text-align: center; color: var(--text-faint);
  padding: 40px 0 60px; font-size: 15px;
}

/* ---------- Feature strip (home) ---------- */

.feature-strip {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 56px 0;
}

.features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px;
}
.feature-icon { font-size: 26px; display: block; margin-bottom: 10px; }
.feature h2 { font-size: 1.05rem; margin-bottom: 6px; }
.feature p { color: var(--text-soft); font-size: 14.5px; margin: 0; }

.home-seo { padding: 56px 0 72px; }
.home-seo h2 { font-size: 1.4rem; }
.home-seo p { color: var(--text-soft); max-width: 800px; }

/* ---------- Tool pages ---------- */

.tool-body { padding: 24px 0 72px; }
.tool-body h2 { font-size: 1.35rem; margin-top: 40px; }
.tool-body > .container > p { color: var(--text-soft); max-width: 800px; }

.examples-table {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  max-width: 720px;
}
.examples-row {
  display: grid; grid-template-columns: 180px 1fr;
  padding: 12px 18px; gap: 12px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.examples-row:first-child { border-top: none; }
.examples-head {
  background: var(--bg-soft);
  font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-faint);
}
.examples-row span:first-child { font-size: 14px; color: var(--text-soft); font-weight: 500; }
.example-output { font-size: 1.1rem; word-break: break-word; }

.faq-list { max-width: 720px; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elevated); margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}
.faq-item[open] { border-color: var(--border-strong); }
.faq-item summary {
  cursor: pointer; font-weight: 600; font-size: 15px;
  padding: 14px 18px; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; font-size: 18px; color: var(--text-faint);
  transition: transform 0.2s var(--ease);
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 18px 14px; margin: 0; color: var(--text-soft); font-size: 14.5px; }

/* ---------- Tools grid ---------- */

.tools-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; padding: 12px 0 64px;
}
.tools-grid-compact { padding-bottom: 0; }

.tool-card {
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s, border-color 0.18s;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}
.tool-card h2, .tool-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.tool-card p { color: var(--text-soft); font-size: 14px; margin: 0 0 14px; flex: 1; }
.tool-card-cta { font-size: 13.5px; font-weight: 600; color: var(--accent); }

/* ---------- Blog ---------- */

.blog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; padding: 12px 0 64px;
}

.blog-card {
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s, border-color 0.18s;
}
.blog-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}
.blog-card h2, .blog-card h3 { font-size: 1.1rem; margin: 8px 0 6px; }
.blog-card p { color: var(--text-soft); font-size: 14px; margin: 0 0 12px; flex: 1; }

.blog-card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-faint);
}

.tag {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 10px;
}

.article-body { padding-bottom: 32px; }
.article-body h2 { font-size: 1.4rem; margin-top: 36px; }
.article-body p { color: var(--text-soft); }
.article-body code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px;
}

.article-cta {
  margin-top: 36px; padding: 18px 22px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
}
.article-cta p { margin: 0; color: var(--text); }

.more-heading { font-size: 1.3rem; margin: 24px 0 4px; }

/* ---------- Error page ---------- */

.error-page { text-align: center; padding: 96px 0 120px; }
.error-code {
  font-size: clamp(3.5rem, 10vw, 6rem); font-weight: 800; margin: 0 0 8px;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-top: auto;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  padding-top: 48px; padding-bottom: 32px;
}

.footer-brand p {
  color: var(--text-soft); font-size: 14px; margin-top: 14px; max-width: 300px;
}

.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col h3 {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 4px;
}
.footer-col a { color: var(--text-soft); font-size: 14px; }
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 20px; padding-bottom: 24px;
}
.footer-bottom p { margin: 0; font-size: 13px; color: var(--text-faint); }
.footer-bottom strong { color: var(--text); font-weight: 700; }
.footer-bottom a:hover { text-decoration: none; }
.footer-bottom a strong { color: var(--accent); }

/* ---------- Animations ---------- */

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

.fade-in { animation: fade-up 0.55s var(--ease) both; }
.fade-in:nth-child(2) { animation-delay: 0.07s; }
.fade-in:nth-child(3) { animation-delay: 0.14s; }
.fade-in:nth-child(4) { animation-delay: 0.21s; }

/* Stagger style cards via --i set by JS */
.style-card { animation-delay: calc(var(--i, 0) * 18ms); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .features { grid-template-columns: 1fr; gap: 20px; }
  .footer-inner { grid-template-columns: repeat(3, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .nav-burger { display: flex; }

  .site-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 10px 16px 16px;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform 0.2s var(--ease), opacity 0.2s;
  }
  .site-nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .site-nav a { padding: 12px; font-size: 15.5px; }

  .hero { padding: 48px 0 28px; }
  .styles-grid { grid-template-columns: 1fr; }
  .examples-row { grid-template-columns: 120px 1fr; padding: 10px 14px; }
  .input-toolbar { flex-direction: column; align-items: stretch; }
  .char-counter { text-align: right; }
}

@media (max-width: 480px) {
  .logo-word { font-size: 18px; }
  .logo-tagline { font-size: 8.5px; }
  .footer-inner { gap: 20px; }
  .input-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .input-actions .btn { justify-content: center; }
  .input-actions .btn:last-child { grid-column: 1 / -1; }
}
