/* =============================================================================
   9UY Carbon — styles.css
   Full compliance with 9UY Toolbox Visual Style Guide.
   ============================================================================= */

/* --- Grid Background -------------------------------------------------------- */
body {
  background-color: #0a0a0a;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 30px 30px;
}

/* --- Scanline --------------------------------------------------------------- */
.scanline {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 50%,
    rgba(0,0,0,0.18) 50%,
    rgba(0,0,0,0.18) 100%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 100;
  opacity: 0.3;
}

/* High-DPI and mobile: reduce opacity to avoid moiré */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (max-width: 768px) {
  .scanline { opacity: 0.15; }
}

/* --- Block Cursor ----------------------------------------------------------- */
.block-cursor {
  display: inline-block;
  width: 0.6ch;
  height: 0.85em;
  background: #ffffff;
  vertical-align: baseline;
  margin-bottom: -0.05em;
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* --- Reduced Motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .block-cursor   { animation: none; opacity: 1; }
  .scanline       { display: none; }
  *               { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* --- Typography ------------------------------------------------------------- */
.section-header {
  font-size: 0.875rem;   /* text-sm equivalent — section sub-header */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #ffffff;
  white-space: nowrap;
}

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

.field-label {
  font-size: 0.75rem;    /* text-xs */
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a1a1aa;        /* gray-400 */
}

.field-input {
  background-color: #0a0a0a;         /* gray-950 */
  border: 1px solid #262626;         /* gray-800 */
  border-radius: 0.375rem;           /* rounded-md */
  padding: 0.5rem 0.75rem;           /* px-3 py-2 */
  color: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s cubic-bezier(0.4,0,0.2,1);
  min-height: 44px;                  /* A11y touch target */
}

.field-input::placeholder {
  color: #71717a;  /* gray-500 */
}

.field-input:hover {
  border-color: #52525b;
}

.field-input:focus {
  outline: none;
  border-color: #ffffff;
}

.field-input:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-color: #ffffff;
}

.field-input:disabled {
  opacity: 0.5;
  filter: grayscale(1);
  cursor: not-allowed;
  background-color: rgba(23,23,23,0.5);
}

select.field-input option {
  background-color: #171717;
  color: #ffffff;
}

.field-hint {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #71717a;  /* gray-500 */
  margin: 0;
}

/* --- Buttons --------------------------------------------------------------- */
.btn-primary {
  background-color: #ffffff;
  color: #000000;
  border: none;
  border-radius: 0.5rem;             /* rounded-lg */
  padding: 0.5rem 1rem;              /* px-4 py-2 */
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  min-height: 44px;                  /* A11y touch target */
  min-width: 44px;
  transition: background-color 0.2s cubic-bezier(0.4,0,0.2,1),
              transform 0.2s cubic-bezier(0.4,0,0.2,1);
}

.btn-primary:hover  { background-color: #e4e4e7; }
.btn-primary:active { transform: scale(0.95); }

.btn-primary:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.btn-ghost {
  background: transparent;
  color: #a1a1aa;
  border: 1px solid #262626;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: border-color 0.2s cubic-bezier(0.4,0,0.2,1),
              color 0.2s cubic-bezier(0.4,0,0.2,1),
              transform 0.2s cubic-bezier(0.4,0,0.2,1);
}

.btn-ghost:hover  { border-color: #52525b; color: #ffffff; }
.btn-ghost:active { transform: scale(0.95); }

.btn-ghost:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.btn-icon {
  background: transparent;
  border: 1px solid #262626;
  border-radius: 0.5rem;
  padding: 0.5rem;
  color: #71717a;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s cubic-bezier(0.4,0,0.2,1),
              color 0.2s cubic-bezier(0.4,0,0.2,1),
              transform 0.2s cubic-bezier(0.4,0,0.2,1);
}

.btn-icon:hover  { border-color: #52525b; color: #ef4444; }
.btn-icon:active { transform: scale(0.95); }

.btn-icon:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* --- Flight Leg Row --------------------------------------------------------- */
.leg-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 16px;
  background: rgba(23,23,23,0.5);   /* gray-900/50 */
  border: 1px solid #262626;
  border-radius: 0.75rem;           /* rounded-xl */
  transition: border-color 0.2s cubic-bezier(0.4,0,0.2,1);
}

.leg-row:hover { border-color: #3f3f46; }

.leg-arrow {
  color: #52525b;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

/* --- Airport Input with Autocomplete --------------------------------------- */
.airport-wrap {
  position: relative;
}

.airport-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #171717;
  border: 1px solid #3f3f46;
  border-radius: 0.5rem;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.airport-autocomplete.open { display: block; }

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background-color 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item[aria-selected="true"] {
  background-color: #262626;
}

.autocomplete-code {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.autocomplete-name {
  color: #71717a;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Results --------------------------------------------------------------- */
.result-card {
  padding: 20px;
  background: rgba(23,23,23,0.5);
  border: 1px solid #262626;
  border-radius: 0.75rem;
}

.result-card--accent {
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.04);
}

.result-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #71717a;
  margin-bottom: 6px;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1;
}

.result-unit {
  font-size: 0.875rem;
  font-weight: 400;
  color: #a1a1aa;
}

/* --- Leg Breakdown --------------------------------------------------------- */
.leg-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(23,23,23,0.3);
  border: 1px solid #262626;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

.leg-result-route {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.leg-result-meta {
  color: #71717a;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.leg-result-stats {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leg-result-co2 {
  color: #ffffff;
  font-weight: 600;
}

.leg-result-dist {
  color: #71717a;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Error Banner ---------------------------------------------------------- */
#error-banner:not(.hidden) {
  display: flex;
}
