/*
 * PitStop -- public/css/name.css
 * The "Name this stop" sheet (20.54 FEAT-003). Same bottom-sheet shape as the
 * rating sheet; tokens from base.css with safe fallbacks.
 *
 * Layer: 1350 -- opened from the detail sheet (1200), so it must outrank it,
 * and it must sit UNDER the card sheet (1400) which can also be launched from
 * detail. The one authoritative ladder is the comment in install.css.
 * Explicit z-index, not DOM order.
 */

#name-root {
  position: fixed;
  inset: 0;
  z-index: 1350;
}

.nm-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim, rgba(0, 0, 0, 0.5));
  animation: nm-fade 0.15s ease-out;
}

.nm-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: var(--app-max-width, 480px);
  background: var(--surface, #ffffff);
  color: var(--text, #14181f);
  border-top-left-radius: var(--radius-lg, 18px);
  border-top-right-radius: var(--radius-lg, 18px);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.28);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: nm-rise 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nm-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .nm-scrim, .nm-sheet { animation: none; }
}

.nm-sheet::before {
  content: '';
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border, #d5dae2);
  margin: 0 auto 12px;
}

.nm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.nm-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}
.nm-sub {
  font-size: 0.85rem;
  color: var(--muted, #69727f);
  margin-top: 3px;
  line-height: 1.35;
}
.nm-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-subtle, #eef1f5);
  color: var(--muted, #69727f);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nm-close:active { transform: scale(0.92); }

.nm-field { margin: 4px 0 8px; }
.nm-input {
  width: 100%;
  box-sizing: border-box;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--border, #d5dae2);
  border-radius: var(--radius, 12px);
  background: var(--surface, #ffffff);
  color: var(--text, #14181f);
  /* 16px floor: iOS Safari zooms a smaller focused input and never zooms back */
  font-size: 1.05rem;
  font-weight: 600;
}
.nm-input::placeholder { color: var(--muted, #69727f); font-weight: 400; }
.nm-input:focus {
  outline: none;
  border-color: var(--accent, #2f6fed);
}
.nm-input:disabled { opacity: 0.6; }

.nm-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted, #69727f);
}

/* name.js toggles these with the `hidden` attribute. An author `display:flex`
   outranks the user-agent `[hidden] { display: none }` (author sheets win at
   equal specificity), so the attribute has to be honoured here explicitly --
   the done panel rendered as an empty green bar before this rule existed. */
.nm-done[hidden],
.nm-error[hidden],
.nm-hint[hidden] {
  display: none;
}

.nm-error {
  font-size: 0.85rem;
  color: var(--poor, #c63127);
  background: var(--poor-bg, rgba(210, 59, 59, 0.1));
  border-radius: var(--radius, 12px);
  padding: 9px 12px;
  margin-bottom: 10px;
}

.nm-done {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius, 12px);
  background: var(--great-bg, rgba(31, 157, 85, 0.12));
  color: var(--great, #197d46);
  font-size: 0.9rem;
  font-weight: 600;
  animation: nm-pop 0.25s ease-out;
}
.nm-done-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--great, #197d46);
  color: var(--tier-ink, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
@keyframes nm-pop {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .nm-done { animation: none; } }

.nm-foot {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.nm-btn {
  flex: 1 1 0;
  height: 50px;
  border: none;
  border-radius: var(--radius, 12px);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.06s ease;
}
.nm-btn:active:not(:disabled) { transform: scale(0.98); }
.nm-btn-go {
  background: var(--accent, #2f6fed);
  color: var(--brand-ink, #ffffff);
}
.nm-btn-go:disabled {
  background: var(--bg-subtle, #eef1f5);
  color: var(--muted, #69727f);
  cursor: default;
}
.nm-btn-quiet {
  flex: 0 0 auto;
  min-width: 96px;
  background: var(--bg-subtle, #eef1f5);
  color: var(--text, #14181f);
}

.nm-spin {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: nm-spin 0.7s linear infinite;
}
@keyframes nm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nm-spin { animation-duration: 1.6s; } }

@media (prefers-color-scheme: dark) {
  .nm-scrim { background: var(--scrim, rgba(0, 0, 0, 0.62)); }
}
