@font-face {
  font-family: "StardosStencil";
  src: url("/resources/font/fonts/StardosStencil-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "StardosStencil";
  src: url("/resources/font/fonts/StardosStencil-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "StardosStencil", Arial, Helvetica, sans-serif;
  line-height: 1.5;
  --page-bg: #000000;
  --page-image: none;
  --panel-bg: #020202;
  --panel-border: rgba(255, 255, 255, 0.18);
  --field-bg:
    linear-gradient(
      90deg,
      rgba(115, 115, 115, 0.24) 0%,
      rgba(255, 255, 255, 0.22) 51%,
      rgba(115, 115, 115, 0.24) 100%
    );
  --accent: #59a138;
  --text-main: #ffffff;
  --text-soft: #cfcfcf;
  --text-dim: #8c8c8c;
  --section-divider: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text-main);
  position: relative;
  isolation: isolate;
  font-family: "StardosStencil", Arial, Helvetica, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--page-bg);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.4)),
    var(--page-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-header {
  display: flex;
  justify-content: center;
  padding: 1.5rem 1.25rem 0;
}

.app-logo {
  width: min(100%, 3rem);
  height: auto;
  display: block;
  border-radius: 0.5rem;
}

.layout-shell {
  --section-pad: clamp(1.25rem, 4vw, 4rem);
  width: min(100%, 75rem);
  min-height: calc(100vh - 18rem);
  margin: 4rem auto 0;
  padding: 2.5rem 0rem 3rem;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(3, 3, 3, 0.86) 0%, rgba(8, 8, 8, 0.68) 100%);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
}

.layout-divider-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.layout-divider {
  position: absolute;
  background: var(--section-divider);
}

.legacy-layout {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 4rem;
  margin-top: 0;
}

.lefty,
.righty {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.righty {
  margin-left: 0;
}

.trip-section,
.vehicle-mpg-section,
.results-section {
  margin: 0;
  width: 100%;
  min-width: 0;
}

.trip-section h2,
.vehicle-mpg-section h2 {
  margin: 0 0 0.5rem;
  padding-left: var(--section-pad);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.vehicle-mpg-section {
  margin-top: 0;
}

.trip-form-edit {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding-inline: var(--section-pad);
}

.one {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0;
}

.origin-label,
.destination-label {
  color: var(--text-main);
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

.origin-label {
  margin-top: 1rem;
  margin-left: 1rem;
}

.destination-label {
  margin-top: 1rem;
  padding-left: 0;
  margin-left: 1rem;
}

.autocomplete-field {
  position: relative;
  z-index: 0;
  margin-top: 0.3rem;
}

#additional-destination-container {
  margin-top: 1rem;
}

.autocomplete-field:focus-within {
  z-index: 8;
}

.autocomplete-shell {
  position: relative;
}

.input-field {
  width: 100%;
  padding: 0.25rem 1rem;
  border: none;
  background: var(--field-bg);
  color: gainsboro;
  font: inherit;
  border-radius: 0.25rem;
}

.input-field::placeholder {
  color: rgba(255, 255, 255, 0.46);
}

.input-field:focus {
  outline: 1px solid rgba(89, 161, 56, 0.5);
  box-shadow: 0 0 0 3px rgba(89, 161, 56, 0.12);
}

.toggle-group,
.towing,
.fuel {
  display: inline-flex;
  align-self: flex-start;
  overflow: hidden;
  padding: 0.2rem;
  background: var(--field-bg);
  border-radius: 0.5rem;
  border: none;
}

.toggle-group input,
.towing input,
.fuel input,
.vehicle-type input {
  display: none;
}

.toggle-group label,
.towing label,
.fuel label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6rem;
  min-height: 1.6rem;
  color: var(--text-main);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 0.25rem;
}

.placeholder-toggle:disabled label {
  opacity: 0.82;
}

.toggle-group input:checked + label,
.towing input:checked + label,
.fuel input:checked + label {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
}

.trip-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  margin-top: 1rem;
  padding-left: 0;
}

.subtle-action,
.manual-btn {
  padding: 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 0.78rem;
  text-decoration: underline;
  text-transform: lowercase;
}

.subtle-action:disabled,
.manual-btn:disabled {
  cursor: default;
}

.result-button {
  padding: 0.25rem 1rem;
  border: none;
  border-radius: 0.25rem;
  background: linear-gradient(90deg, #335d20 0%, #59a138 51%, #345d20 100%);
  color: var(--text-main);
  font: inherit;
  font-size: 0.95rem;
  text-transform: lowercase;
  cursor: pointer;
  transition: transform 120ms ease;
}

.result-button:hover:not(:disabled) {
  transform: scale(1.04);
}

.result-button:disabled {
  opacity: 0.75;
  cursor: wait;
}

.vehicle-result-button {
  align-self: center;
  margin: 0 auto;
  margin-top: 2rem;
}

.form-status {
  min-height: 1.5rem;
  margin: 0.9rem 0 0;
  padding-left: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.vehicle-mpg-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding-inline: var(--section-pad);
}

.fuel-input-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.manual-mpg-input {
  width: min(100%, 8rem);
  margin-top: 0;
}

.vehicle-type {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  border: none;
  border-top: 1px solid var(--section-divider);
  padding: 0.9rem 0 0;
  margin: 0.15rem 0 0;
}

.vehicle-type label {
  color: gray;
  font-size: 1rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 120ms ease;
}

.vehicle-type input:checked + label {
  color: var(--text-main);
}

.vehicle-gallery-panel[hidden] {
  display: none !important;
}

.vehicle-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.trailer-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--section-divider);
}

.trailer-gallery-grid[hidden] {
  display: none !important;
}

.vehicle-option-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.0155rem;
  min-height: 0;
  padding: 0.0015rem 0.35rem 0.5rem 0.5rem;
  border: 2px solid transparent;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font: inherit;
  text-align: center;
  text-transform: lowercase;
  cursor: pointer;
  opacity: 0.72;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    opacity 120ms ease,
    color 120ms ease;
}

.vehicle-option-card span {
  color: inherit;
}

.vehicle-option-image {
  width: 4.15rem;
  height: 3rem;
  object-fit: contain;
  display: block;
  filter: grayscale(0.85) brightness(0.82);
  transition: filter 120ms ease;
}

.vehicle-option-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
}

.vehicle-option-card:focus-visible {
  outline: 1px solid rgba(89, 161, 56, 0.6);
  outline-offset: 2px;
}

.vehicle-option-card.active {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-main);
  opacity: 1;
}

.vehicle-option-card.active .vehicle-option-image {
  filter: none;
}

.trailer-card {
  min-height: 0;
}

.trailer-image {
  width: 4.4rem;
  height: 3.2rem;
}

.placeholder-note {
  margin: 0.25rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

#fuel-price-note {
  margin-top: -0.8rem;
  margin-left: 0.5rem;
}

.results-content {
  padding-inline: var(--section-pad);
  font-size: 1rem;
}

.results-content p {
  margin: 0 0 0.7rem;
}

.result-intro {
  color: var(--text-soft);
  min-height: 1.3rem;
}

#distance-value,
#duration-value,
#fuel-placeholder {
  color: var(--accent);
}

.ok {
  color: #86efac;
}

.error {
  color: #fca5a5;
}

.pending {
  color: #fcd34d;
}

.suggestions-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.15rem;
  max-height: 15rem;
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.suggestions-panel[hidden] {
  display: none !important;
}

.suggestion-option {
  display: grid;
  width: 100%;
  gap: 0.18rem;
  padding: 0.25rem 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.suggestion-option:hover,
.suggestion-option.active {
  background: rgba(89, 161, 56, 0.16);
  border-color: rgba(89, 161, 56, 0.24);
  transform: none;
}

.suggestion-title {
  color: var(--text-main);
  font-size: 0.95rem;
}

.suggestion-subtitle {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.suggestions-attribution {
  margin: 0.35rem 0.35rem 0.1rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .legacy-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 2.5rem;
  }

  .righty {
    margin-left: 0;
  }

  .trip-section,
  .vehicle-mpg-section,
  .results-section {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .layout-shell {
    --section-pad: 1.25rem;
    width: calc(100% - 1.5rem);
    min-height: calc(100vh - 4.75rem);
    margin-top: 0.9rem;
    padding: 1.25rem 0 2.5rem;
    border-radius: 1.1rem;
  }

  .page-header {
    padding-top: 1rem;
  }

  .app-logo {
    width: min(100%, 11.5rem);
  }

  .legacy-layout {
    margin-top: 1.5rem;
    gap: 2rem;
  }

  .lefty,
  .righty {
    gap: 2.5rem;
  }

  .trip-section h2,
  .vehicle-mpg-section h2 {
    padding-left: var(--section-pad);
  }

  .trip-section,
  .vehicle-mpg-section,
  .results-section {
    width: 100%;
  }

  .one {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }

  .origin-label,
  .destination-label,
  .trip-actions,
  .form-status {
    padding-left: 0;
  }

  .trip-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .subtle-action,
  .manual-btn {
    text-align: left;
  }

  .result-button {
    width: 100%;
  }

  .vehicle-gallery {
    grid-template-columns: repeat(4, minmax(5rem, 1fr));
    overflow-x: auto;
  }

  .trailer-gallery-grid {
    grid-template-columns: repeat(4, minmax(5rem, 1fr));
    overflow-x: auto;
  }

  .vehicle-gallery,
  .trailer-gallery-grid {
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .vehicle-gallery::-webkit-scrollbar,
  .trailer-gallery-grid::-webkit-scrollbar {
    display: none;
  }

  .vehicle-option-card {
    min-width: 5.4rem;
  }
}
