/* =========================
   Mindset Digital · SERP Snippet Preview
   ========================= */

/* Layout */
.mdt-serp-preview {
  background: var(--md-background);
  color: var(--md-foreground);
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 2rem;
}
@supports (height: 1dvh) { .mdt-serp-preview { min-height: 100dvh; } }
.mdt-serp-preview .md-card {
  width: min(780px, 94vw);
  background: var(--md-surface, #fff);
  color: var(--md-foreground);
}

/* Header */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .65rem;
  border: 1px solid var(--md-border, rgba(0,0,0,.12));
  border-radius: 999px;
  background: transparent;
  color: var(--md-foreground);
  cursor: pointer;
  line-height: 1;
}
.theme-toggle:hover { background: rgba(0,0,0,.04); }
[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,.06); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
#iconMoon { display: none; }
[data-theme="dark"] #iconSun { display: none; }
[data-theme="dark"] #iconMoon { display: block; }
@media (max-width: 480px) { .theme-toggle__label { display: none; } }

/* Form */
.serp-form {
  display: grid;
  gap: .25rem;
  margin-block: 1rem;
}
.form-row {
  display: grid;
  gap: .3rem;
  margin-bottom: .85rem;
}
.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--md-foreground);
}
.counter {
  font-weight: 400;
  font-size: .82rem;
  color: color-mix(in srgb, var(--md-foreground) 55%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.counter.warn { color: var(--md-color-warning); }
.counter.over { color: var(--md-color-danger); font-weight: 600; }

input[type="text"], textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--md-foreground);
  caret-color: var(--md-color-primary);
}

/* Pixel bar */
.pixel-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--md-border);
  overflow: hidden;
}
.pixel-bar__fill {
  height: 100%;
  border-radius: 2px;
  background: var(--md-color-primary);
  transition: width .12s ease, background .2s ease;
  width: 0;
}
.pixel-bar__fill.warn { background: var(--md-color-warning); }
.pixel-bar__fill.over { background: var(--md-color-danger); }
.pixel-hint {
  font-size: .78rem;
  color: color-mix(in srgb, var(--md-foreground) 45%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Options */
.options {
  margin: .75rem 0;
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius);
  padding: .75rem 1rem;
}
.opt-row {
  display: flex;
  gap: .75rem 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.opt-row label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
}
.opt-sep {
  margin-left: auto;
}
@media (max-width: 560px) { .opt-sep { margin-left: 0; } }

/* Keyword row inside options */
.keyword-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px solid var(--md-border);
}
.keyword-row label { font-weight: 600; white-space: nowrap; font-size: .88rem; }
.keyword-row input { flex: 1; min-width: 0; }
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--md-color-primary);
}

/* Actions */
.actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  align-items: center;
  position: relative;
}
.md-btn {
  background: var(--md-color-primary, #1063ff);
  color: var(--md-color-primary-contrast, #fff);
}
.md-btn--secondary {
  background: var(--md-color-secondary, #f0b138);
  color: var(--md-color-secondary-contrast, #090a08);
}

/* Help */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--md-border);
  border-radius: 50%;
  background: var(--md-surface);
  color: var(--md-foreground);
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.help-popover {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: .5rem;
  z-index: 1000;
  width: min(520px, 86vw);
  background: var(--md-surface);
  color: var(--md-foreground);
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: .85rem 1rem;
  display: none;
}
.help-popover.is-open { display: block; }
.help-popover ul { padding-left: 1.2rem; margin: .5rem 0; }
.help-popover li { margin-bottom: .4rem; }

/* ============================
   SERP Preview Card (Google)
   ============================ */
.serp-preview-section {
  margin-top: 1.25rem;
}
.serp-preview-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--md-foreground);
  font-family: var(--md-font-body);
}

.serp-card {
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  max-width: 652px; /* Google desktop width */
  font-family: Arial, sans-serif;
  color: #4d5156;
  line-height: 1.58;
}
[data-theme="dark"] .serp-card {
  background: #1e1e1e;
  border-color: #3c4043;
  color: #bdc1c6;
}

/* Breadcrumb / URL row */
.serp-card__breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 14px;
}
.serp-favicon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f1f3f4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
[data-theme="dark"] .serp-favicon {
  background: #303134;
}
.serp-favicon svg, .serp-favicon img {
  width: 18px;
  height: 18px;
}
.serp-favicon[hidden] { display: none; }
.serp-url {
  color: #4d5156;
  font-size: 14px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .serp-url { color: #bdc1c6; }

/* Title */
.serp-card__title {
  font-size: 20px;
  line-height: 1.3;
  color: #1a0dab;
  font-weight: 400;
  cursor: pointer;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.serp-card__title:hover { text-decoration: underline; }
[data-theme="dark"] .serp-card__title { color: #8ab4f8; }

/* Keyword bolding (Google-like) */
.serp-card__title strong,
.serp-card__desc strong { font-weight: 700; }

/* Date */
.serp-card__date {
  font-size: 14px;
  color: #70757a;
  margin-bottom: 2px;
}
.serp-card__date[hidden] { display: none; }
[data-theme="dark"] .serp-card__date { color: #9aa0a6; }

/* Description */
.serp-card__desc {
  font-size: 14px;
  line-height: 1.58;
  color: #4d5156;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
[data-theme="dark"] .serp-card__desc { color: #bdc1c6; }

/* Mobile variant */
.serp-card[data-device="mobile"] {
  max-width: 420px;
  padding: .85rem;
  font-size: 14px;
}
.serp-card[data-device="mobile"] .serp-card__title {
  font-size: 18px;
}
.serp-card[data-device="mobile"] .serp-card__desc {
  -webkit-line-clamp: 2;
}

/* Status */
.status-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95rem;
  color: var(--md-foreground);
  display: inline-block;
  padding: .3rem .5rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--md-surface) 85%, transparent);
  min-height: 1.4em;
}
.status-line::after {
  content: "▊";
  margin-left: .3rem;
  opacity: .7;
  animation: blink 1s steps(2, end) infinite;
}
@keyframes blink { 0%,50% { opacity: 0; } 50.01%,100% { opacity: 1; } }

/* Accessibility */
.skip-link {
  position: absolute;
  left: .5rem;
  top: -1000px;
  background: var(--md-foreground);
  color: var(--md-background);
  padding: .5rem .75rem;
  border-radius: 6px;
  text-decoration: none;
}
.skip-link:focus { top: .5rem; z-index: 10; }
textarea:focus-visible, input:focus-visible, button:focus-visible, select:focus-visible {
  outline: 3px solid var(--md-focus, #0a57ff);
  outline-offset: 2px;
}
:root { color-scheme: light dark; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
