/* ==========================================================
   Add to Home Screen  —  button in templates/partials/header.html,
   help window in templates/partials/add_home.html
   ========================================================== */

/* ---------- Header button: blinks red to catch the eye ---------- */

.btn-add-home {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  animation: a2hs-blink 1.2s ease-in-out infinite;
}

.btn-add-home .ico {
  width: 18px;
  height: 18px;
}

/* Blink: switches between solid red and red outline with a glow */
@keyframes a2hs-blink {
  0%, 100% {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 0 18px 2px rgba(255, 23, 68, 0.7);
  }
  50% {
    background: transparent;
    color: var(--accent);
    box-shadow: 0 0 0 0 rgba(255, 23, 68, 0);
  }
}

.btn-add-home:hover {
  animation-play-state: paused;
}

.btn-add-home:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

/* Icon-only where the header gets tight; the text stays for screen readers */
@media (max-width: 1199px) {
  .btn-add-home {
    width: 36px;
    padding: 0;
  }

  .btn-add-home-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ---------- Popup ---------- */

.a2hs-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line-gold);
  border-radius: 18px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(255, 176, 0, 0.14), transparent 60%),
    radial-gradient(60% 50% at 0% 100%, rgba(255, 23, 68, 0.12), transparent 70%),
    var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(255, 176, 0, 0.12);
}

.a2hs-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.a2hs-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.a2hs-icon {
  flex-shrink: 0;
  border: 1px solid var(--line-gold);
  border-radius: 12px;
}

.a2hs-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
}

.a2hs-sub {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.a2hs-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  cursor: pointer;
}

.a2hs-close .ico {
  width: 16px;
  height: 16px;
}

.a2hs-close:hover {
  border-color: var(--gold);
  color: var(--text);
}

/* One-tap install */
.a2hs-install {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-top: 20px;
}

.a2hs-install[hidden] {
  display: none;
}

.a2hs-install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--on-btn);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--glow-btn);
  transition: background-color 0.2s ease;
}

.a2hs-install-btn .ico {
  width: 20px;
  height: 20px;
}

.a2hs-install-btn:hover {
  background: var(--btn-bg-hover);
}

.a2hs-install-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Android + iPhone steps, side by side */
.a2hs-guides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.a2hs-guide {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
}

/* The visitor's own phone: gold border, shown first */
.a2hs-guide.is-yours {
  order: -1;
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(255, 176, 0, 0.15);
}

.a2hs-guide-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--text);
}

.a2hs-guide-title .ico {
  width: 18px;
  height: 18px;
  color: var(--gold);
}

.a2hs-yours {
  display: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-light);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.a2hs-guide.is-yours .a2hs-yours {
  display: inline-block;
}

/* Steps as one line of chips: Menu › Install … */
.a2hs-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 0;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.a2hs-flow li {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line-gold);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.a2hs-flow li + li {
  margin-left: 18px;
}

.a2hs-flow li + li::before {
  content: "\203A";
  position: absolute;
  left: -14px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.a2hs-flow .ico {
  width: 15px;
  height: 15px;
  color: var(--gold);
}

/* Secondary close button */
.a2hs-ok {
  width: 100%;
  height: 40px;
  margin-top: 14px;
  border: 1px solid var(--line-gold);
  border-radius: 10px;
  background: transparent;
  color: var(--gold-light);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.a2hs-ok:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.a2hs-close:focus-visible,
.a2hs-ok:focus-visible,
.a2hs-install-btn:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .a2hs-dialog {
    padding: 20px 16px;
  }

  .a2hs-title {
    font-size: 17px;
    line-height: 23px;
  }

  .a2hs-guides {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-add-home {
    animation: none;
    background: var(--accent);
    color: var(--on-accent);
  }
}
