/* ============ Tokens ============ */
:root {
  --bg: #FAFAF7;
  --primary: #2D6A4F;
  --primary-dark: #204F3B;
  --secondary: #3D5A80;
  --green: #52B788;
  --yellow: #F4A261;
  --red: #E76F51;
  --text: #2B2B2B;
  --text-soft: #5C5C56;
  --border: #E4E2DA;
  --card-bg: #FFFFFF;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(43, 43, 43, 0.06);
  --font-title: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-width: 320px;
}

h1, h2, h3 { font-family: var(--font-title); margin: 0; }

/* ============ Header ============ */
.app-header {
  padding: 28px 20px 18px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.logo-text {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.logo-tc {
  font-weight: 700;
  color: var(--primary);
}

.logo-aldia {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--secondary);
}

.tagline {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

/* ============ Ad slots ============ */
.ad-slot {
  min-height: 90px;
  margin: 0 auto 20px;
  max-width: 480px;
  width: calc(100% - 32px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(61, 90, 128, 0.03);
}

/* Placeholder visible solo en desarrollo. Para producción: eliminar este bloque
   y dejar el div#ad-slot-top / #ad-slot-bottom vacío para que el proveedor de
   anuncios inyecte su contenido, manteniendo min-height para evitar layout shift. */
.ad-placeholder-label {
  font-size: 0.8rem;
  color: var(--text-soft);
  opacity: 0.6;
  letter-spacing: 0.02em;
}

/* ============ Layout ============ */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 8px;
}

/* ============ Cards ============ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.1rem;
  margin-bottom: 14px;
  color: var(--text);
}

/* ============ Form ============ */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-family: var(--font-body);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.form-error {
  color: var(--red);
  font-size: 0.88rem;
  margin: -4px 0 14px;
  font-weight: 500;
}

.btn-primary, .btn-secondary {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: #fff;
  color: var(--secondary);
  border: 1.5px solid var(--secondary);
  margin-top: 4px;
}

.btn-secondary:hover { background: rgba(61, 90, 128, 0.06); }
.btn-secondary:active { transform: scale(0.98); }

/* ============ Results ============ */
.results {
  animation: fadeSlideIn 0.5s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

#results-capture {
  background: var(--bg);
  padding: 4px 0 0;
}

.capture-header {
  display: none; /* solo visible durante la captura para exportar imagen */
  justify-content: center;
  padding: 10px 0 16px;
  opacity: 0.55;
}

.capture-logo {
  font-family: var(--font-title);
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.summary-label {
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-value {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.summary-sub {
  font-size: 0.72rem;
  color: var(--text-soft);
}

@media (max-width: 380px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { flex-direction: row; justify-content: space-between; text-align: left; }
}

/* ============ Timeline ============ */
.timeline {
  position: relative;
  height: 44px;
  border-radius: 999px;
  overflow: visible;
  margin-bottom: 14px;
}

.timeline-bar {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.timeline-bar span {
  height: 100%;
}

.timeline-today {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.today-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--secondary);
  border: 3px solid var(--card-bg);
  box-shadow: 0 0 0 1.5px var(--secondary);
}

.today-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--secondary);
  margin-top: 18px;
  white-space: nowrap;
}

.timeline-axis {
  position: relative;
  height: 46px; /* valor por defecto; script.js lo ajusta según cuántas filas de etiquetas necesite */
  margin: 4px 0 14px;
}

.axis-point {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
}

.axis-tick {
  width: 1.5px;
  height: 7px;
  background: var(--border);
  flex-shrink: 0;
}

.axis-label {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text-soft);
  line-height: 1.3;
  text-align: center;
}

.axis-label strong {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }

/* ============ Score card ============ */
.utilization-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.utilization-percent {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.4rem;
  min-width: 58px;
}

.utilization-bar-track {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.utilization-bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.5s ease;
}

.advice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.advice-block {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.advice-block:hover {
  border-color: var(--text-soft);
}

.advice-block:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

/* Estado seleccionado: se activa solo cuando el usuario hace clic (aria-pressed="true"),
   nunca por defecto, para no sugerir que ya se eligió un consejo. */
.advice-block--build[aria-pressed="true"] {
  border-color: var(--secondary);
  background: rgba(61, 90, 128, 0.08);
  box-shadow: 0 0 0 1px var(--secondary) inset;
}

.advice-block--apply[aria-pressed="true"] {
  border-color: var(--text-soft);
  background: rgba(43, 43, 43, 0.05);
  box-shadow: 0 0 0 1px var(--text-soft) inset;
}

.advice-check {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 4px;
}

.advice-block--apply .advice-check { color: var(--text-soft); }

.advice-block[aria-pressed="true"] .advice-check { display: block; }

.advice-icon {
  font-size: 1.15rem;
  display: block;
  margin-bottom: 6px;
}

.advice-title {
  font-family: var(--font-title);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 6px;
}

.advice-block--build[aria-pressed="true"] .advice-title { color: var(--secondary); }

.advice-text {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.45;
  margin: 0;
}

.advice-text strong {
  color: var(--text);
}

/* ============ FAQ / contenido SEO ============ */
.faq-container {
  margin-top: 4px;
}

.faq-card { margin-bottom: 0; }

.faq-item {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.faq-item:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.faq-question {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.35;
}

.faq-answer {
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin: 0;
}

/* ============ Footer ============ */
.app-footer {
  max-width: 480px;
  margin: 12px auto 0;
  padding: 20px 20px 36px;
  text-align: center;
}

.app-footer p {
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 4px 0;
}

/* ============ Capture mode (aplicado por JS antes de exportar imagen) ============ */
.capturing .capture-header {
  display: flex;
}

.capturing #results-capture {
  padding: 16px;
  border-radius: var(--radius);
}
