/* --- Reset & Base (scoped to .tt-shell for Webflow embedding) --- */
.tt-shell, .tt-shell *, .tt-shell *::before, .tt-shell *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Tool Shell + Design Tokens (Light Mode Default) --- */
.tt-shell {
  /* ThumbMagic light mode palette */
  --tm-bg-primary: #ffffff;
  --tm-bg-secondary: #F7F7F7;
  --tm-bg-elevated: #ffffff;
  --tm-bg-hover: rgba(0, 0, 0, 0.04);
  --tm-text-primary: #000000;
  --tm-text-secondary: #5D5656;
  --tm-text-disabled: #aaaeb3;
  --tm-border: #e4e4e7;
  --tm-avatar-bg: #ececee;
  --tm-chip-bg: #F7F7F7;
  --tm-chip-bg-active: #000000;
  --tm-chip-text: #000000;
  --tm-chip-text-active: #ffffff;
  --tm-badge-bg: rgba(0, 0, 0, 0.8);
  --tm-badge-text: #ffffff;
  --tm-link-color: #FF0032;
  --tm-red: #FF0032;
  --tm-overlay-bg: rgba(0, 0, 0, 0.6);

  /* Tool-specific */
  --tool-accent: #FF0032;
  --tool-accent-hover: #cc0029;
  --tool-success: #1AB76A;
  --tool-warning: #f57c00;
  --tool-info: #ff0032;

  /* Scoring */
  --score-strong: #1AB76A;
  --score-decent: #ff0032;
  --score-moderate: #f9ab00;
  --score-weak: #d93025;

  /* Shell layout */
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px;

  /* Base typography */
  font-family: 'Open Sauce Two', 'Source Sans 3', Arial, sans-serif;
  background: var(--tm-bg-primary);
  color: var(--tm-text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Dark Mode (scoped) --- */
.tt-shell[data-theme="dark"] {
  --tm-bg-primary: #0f0f0f;
  --tm-bg-secondary: #1a1a1a;
  --tm-bg-elevated: #212121;
  --tm-bg-hover: rgba(255, 255, 255, 0.1);
  --tm-text-primary: #f1f1f1;
  --tm-text-secondary: #aaaaaa;
  --tm-text-disabled: #717171;
  --tm-border: #3f3f3f;
  --tm-chip-bg: #3f3f3f;
  --tm-chip-bg-active: #f1f1f1;
  --tm-chip-text: #f1f1f1;
  --tm-chip-text-active: #0f0f0f;
  --tm-badge-bg: rgba(0, 0, 0, 0.8);
  --tm-badge-text: #ffffff;
  --tm-link-color: #FF4D6A;
}

/* --- Header --- */
.tt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 24px;
  border-bottom: 1px solid var(--tm-border);
  margin-bottom: 24px;
}

.tt-header__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--tm-text-primary);
}

/* --- Inputs --- */
.tt-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tt-input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--tm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tt-input, .tt-select {
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Open Sauce Two', 'Source Sans 3', Arial, sans-serif;
  background: var(--tm-bg-primary);
  color: var(--tm-text-primary);
  border: 1px solid var(--tm-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.tt-input:focus, .tt-select:focus {
  border-color: var(--tm-link-color);
}

.tt-input::placeholder {
  color: var(--tm-text-disabled);
}

.tt-input--error {
  border-color: var(--score-weak);
}

.tt-error-msg {
  font-size: 12px;
  color: var(--score-weak);
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.2s;
}

/* --- Buttons --- */
.tt-btn {
  padding: 10px 20px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Open Sauce Two', 'Source Sans 3', Arial, sans-serif;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.tt-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tt-btn--primary {
  background: var(--tm-red);
  background-image: linear-gradient(360deg, rgba(0,0,0,0.2), transparent);
  color: #ffffff;
  box-shadow: rgba(255, 3, 50, 0.35) 0px 8px 12px -4px, rgba(121, 0, 0, 0.06) 0px 2px 0px 0px, rgba(255, 255, 255, 0.75) 0px 0px 10px 1px inset, rgba(0, 0, 0, 0.2) 0px 0px 0px 2px inset;
}

.tt-btn--primary:hover:not(:disabled) {
  background-color: var(--tool-accent-hover);
  transform: scale(1.02);
}

.tt-btn--secondary {
  background: var(--tm-chip-bg);
  color: var(--tm-chip-text);
}

.tt-btn--secondary:hover:not(:disabled) {
  background: var(--tm-bg-hover);
}

/* --- Cards --- */
.tt-pane-card {
  background: var(--tm-bg-elevated);
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.tt-pane-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tm-text-primary);
  margin-bottom: 4px;
}

.tt-pane-card__subtitle {
  font-size: 13px;
  color: var(--tm-text-secondary);
  margin-bottom: 14px;
}


/* ============================================================
   SECTION 1: Title Generator
   ============================================================ */

.title-gen {
  display: grid;
  gap: 24px;
}

.title-gen__form-grid {
  display: grid;
  gap: 14px;
}

.title-gen__actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* Loading spinner */
.title-gen__spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.title-gen__spinner.visible {
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Results area --- */
.title-gen__result {
  display: none;
}

.title-gen__result.visible {
  display: block;
}

.title-result__list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.title-result__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  background: var(--tm-bg-secondary);
  transition: border-color 0.2s, background 0.2s;
}

.title-result__item:hover {
  border-color: var(--tm-link-color);
  background: var(--tm-bg-elevated);
}

.title-result__number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tm-chip-bg-active);
  color: var(--tm-chip-text-active);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-result__text {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--tm-text-primary);
  line-height: 1.35;
  min-width: 0;
}

.title-result__char-count {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--tm-text-disabled);
  white-space: nowrap;
}

.title-result__copy {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--tm-border);
  background: var(--tm-bg-primary);
  color: var(--tm-text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.title-result__copy:hover {
  border-color: var(--tm-link-color);
  color: var(--tm-link-color);
}

.title-result__copy:focus-visible {
  outline: 2px solid var(--tm-link-color);
  outline-offset: 2px;
}

.title-result__copy--copied {
  border-color: var(--tool-success);
  color: var(--tool-success);
  background: rgba(26, 183, 106, 0.06);
}

/* Error message */
.title-gen__error {
  display: none;
  padding: 14px 16px;
  border: 1px solid var(--score-weak);
  border-radius: 12px;
  background: rgba(217, 48, 37, 0.05);
  color: var(--score-weak);
  font-size: 14px;
  font-weight: 500;
}

.title-gen__error.visible {
  display: block;
}

.tt-shell[data-theme="dark"] .title-gen__error {
  background: rgba(217, 48, 37, 0.1);
}

/* Char count colors */
.title-result__char-count--good {
  color: var(--tool-success);
}

.title-result__char-count--long {
  color: var(--score-moderate);
}

.title-result__char-count--too-long {
  color: var(--score-weak);
}


/* ============================================================
   SECTION: SEO Content
   ============================================================ */

.tt-seo {
  margin-top: 26px;
  margin-left: auto;
  margin-right: auto;
  max-width: 1120px;
  border-top: 1px solid var(--tm-border);
  padding-top: 26px;
  display: grid;
  gap: 18px;
}

.tt-seo__hero {
  background: linear-gradient(135deg, var(--tm-bg-secondary), var(--tm-bg-primary));
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  padding: 18px;
}

.tt-seo__eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--tm-red);
  margin-bottom: 8px;
}

.tt-seo__title {
  font-size: 28px;
  line-height: 1.15;
  color: var(--tm-text-primary);
  margin-bottom: 10px;
}

.tt-seo__lead {
  font-size: 14px;
  line-height: 1.55;
  color: var(--tm-text-secondary);
  max-width: 950px;
}

.tt-seo__section {
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  background: var(--tm-bg-primary);
  padding: 16px;
}

.tt-seo__section-title {
  font-size: 20px;
  line-height: 1.2;
  color: var(--tm-text-primary);
  margin-bottom: 12px;
}

.tt-seo__section-lead {
  font-size: 14px;
  color: var(--tm-text-secondary);
  margin-bottom: 10px;
  line-height: 1.55;
}


/* --- Tips grid --- */
.tt-seo__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tt-seo-card {
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  background: var(--tm-bg-secondary);
  padding: 12px;
}

.tt-seo-card__title {
  font-size: 15px;
  color: var(--tm-text-primary);
  margin-bottom: 6px;
}

.tt-seo-card__text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--tm-text-secondary);
}

.tt-seo-card__text a {
  color: var(--tm-link-color);
  text-decoration: none;
}

.tt-seo-card__text a:hover {
  text-decoration: underline;
}


/* ============================================================
   SECTION: Title Formula Table
   ============================================================ */

.tt-formula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 6px;
}

.tt-formula-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--tm-text-secondary);
  padding: 8px 10px;
  border-bottom: 2px solid var(--tm-border);
}

.tt-formula-table td {
  padding: 10px;
  border-bottom: 1px solid var(--tm-border);
  color: var(--tm-text-primary);
}

.tt-formula-table tr:last-child td {
  border-bottom: none;
}

.tt-formula-table .td-formula {
  font-weight: 500;
}

.tt-formula-table .td-example {
  color: var(--tm-text-secondary);
}

.tt-formula-table .td-use {
  color: var(--tm-text-disabled);
  font-size: 12px;
}


/* ============================================================
   SECTION: FAQ
   ============================================================ */

.tt-seo-faq {
  display: grid;
  gap: 8px;
}

.tt-seo-faq__item {
  border: 1px solid var(--tm-border);
  border-radius: 10px;
  background: var(--tm-bg-secondary);
  padding: 0 12px;
}

.tt-seo-faq__item summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--tm-text-primary);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
}

.tt-seo-faq__item summary::-webkit-details-marker {
  display: none;
}

.tt-seo-faq__item summary::after {
  content: '+';
  margin-left: auto;
  font-size: 18px;
  font-weight: 400;
  color: var(--tm-text-secondary);
  transition: transform 0.2s;
}

.tt-seo-faq__item[open] summary::after {
  content: '-';
}

.tt-seo-faq__item p {
  padding: 0 0 12px;
  color: var(--tm-text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.tt-seo-faq__item summary:focus-visible {
  outline: 2px solid var(--tm-link-color);
  outline-offset: 2px;
}


/* ============================================================
   CTA Section
   ============================================================ */

.tt-seo-cta {
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(255, 0, 50, 0.07), rgba(255, 0, 50, 0.03));
}

.tt-seo-cta__title {
  font-size: 20px;
  line-height: 1.2;
  color: var(--tm-text-primary);
  margin-bottom: 8px;
}

.tt-seo-cta__text {
  font-size: 14px;
  color: var(--tm-text-secondary);
  margin-bottom: 12px;
}

.tt-seo-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}


/* ============================================================
   Focus visible for all interactive elements
   ============================================================ */

.tt-shell *:focus-visible {
  outline: 2px solid var(--tm-link-color);
  outline-offset: 2px;
}


/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .tt-seo__grid {
    grid-template-columns: 1fr;
  }
  .tt-formula-table {
    font-size: 12px;
  }
  .tt-formula-table th, .tt-formula-table td {
    padding: 8px 6px;
  }
  .tt-seo__title {
    font-size: 22px;
  }
  .tt-seo__section-title {
    font-size: 18px;
  }
  /* Form inputs full-width */
  .tt-input, .tt-select {
    width: 100%;
  }
  .title-gen__actions {
    flex-direction: column;
  }
  .title-gen__actions .tt-btn {
    width: 100%;
  }
  /* Result items wrap for narrower screens */
  .title-result__item {
    flex-wrap: wrap;
    gap: 8px;
  }
  .title-result__text {
    flex-basis: calc(100% - 40px);
  }
}

@media (max-width: 480px) {
  .tt-shell {
    padding: 16px 12px;
  }
  .tt-header__title {
    font-size: 17px;
  }
  .tt-seo__title {
    font-size: 20px;
  }
  .tt-seo-cta__actions {
    flex-direction: column;
  }
  .tt-seo-cta__actions .tt-btn {
    width: 100%;
  }
  .tt-pane-card {
    padding: 14px;
  }
  .title-result__item {
    padding: 12px;
  }
  .title-result__text {
    font-size: 14px;
    flex-basis: 100%;
    order: 1;
  }
  .title-result__number {
    order: 0;
  }
  .title-result__char-count {
    order: 2;
    margin-left: auto;
  }
  .title-result__copy {
    order: 3;
  }
}
