@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Space+Grotesk:wght@300..700");
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");

/* Global colours */

:root {
  --bg-color: #0b131e;
  /* deep navy */
  --surface: #0b2a48;
  /* card surface */
  --surface-2: #05203a;
  /* slightly darker surface */
  --card-border: #123852;
  --search-placeholder-color: #ffffff8c;
}

/* High level elements */

*:focus, *:focus-visible, *:active {
  border-color: #ff9c00 !important;
  outline-color: #ff9c00 !important;
  box-shadow: none !important;
  border-radius: 2px;
}

body {
  font-family: "Inter", sans-serif;
  color: #ffffff;
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 1rem;
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", sans-serif;
}

a {
  color: #ff9c00;
}

a:focus {
  outline: 2px solid #ff9c00;
  outline-offset: 2px;
}

/* Homepage: Logo */

.homepage-logo {
  width: 200px;
  height: 200px;
}

@media (min-width: 916px) {
  .homepage-logo {
    width: 512px;
    height: 512px;
  }
}

/* Homepage: Location search  */

#search {
  margin-top: 1.5rem;
}

#search input,
#search button,
#search i {
  display: inline-block;
}

#search input.form-control {
  min-width: 260px;
  max-width: 420px;
  border: 1px solid var(--card-border);
  color: #eaf6ff;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: none;
}

#search input.form-control,
#search input.form-control:-webkit-autofill,
#search input.form-control:-webkit-autofill:hover,
#search input.form-control:-webkit-autofill:focus {
  background: var(--surface-2);
  -webkit-box-shadow: 0 0 0px 1000px var(--surface-2) inset;
  -webkit-text-fill-color: #eaf6ff;
}

#search input.form-control:focus {
  outline: 2px solid #ff9c00;
  outline-offset: 0;
}

/* Define each variant separately as browsers skip one is not recognised in a comma-separated list */
#search input.form-control::placeholder {
  color: var(--search-placeholder-color);
  opacity: 1;
  /* ensure browsers don't dim the placeholder */
}

#search input.form-control::-webkit-input-placeholder {
  color: var(--search-placeholder-color);
  opacity: 1;
}

#search input.form-control:-ms-input-placeholder {
  color: var(--search-placeholder-color);
  opacity: 1;
}

/* Primary search button — custom look that fits the dark gradient */
#search-btn {
  background: #232e3e;
  color: #fff;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

#search-btn:hover,
#search-btn:focus {
  background: #192635;
  color: #ff9c00;
}

#search-btn:active {
  opacity: 0.95;
}

#search-btn:focus {
  outline: 2px solid #ff9c00;
  outline-offset: 2px;
}

/* Small screens: stack input and button */
@media (max-width: 768px) {
  #search .d-flex {
    flex-direction: column;
    gap: 0.5rem;
  }

  #search input.form-control {
    width: 100%;
    max-width: none;
    margin-right: 0;
  }

  #search-btn {
    width: 100%;
  }
}

.search-results {
  /* position the dropdown under the input; container (.d-flex) provides positioning context */
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1100;
  width: 100%;
  margin-top: 8px;
  display: none;
  /* hidden until there are results */
  box-sizing: border-box;
  max-height: 260px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--card-border);
  box-shadow: none;
  padding: 6px;
}

.search-results.open {
  display: block;
}

#location-btn {
  color: inherit;
  text-decoration: none;
  border: none !important;
  box-shadow: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#location-btn:hover,
#location-btn:focus {
  color: #ff9c00;
  outline: 2px solid #ff9c00 !important;
  outline-offset: 4px;
  box-shadow: none !important;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-results-item {
  margin: 0.35rem 0;
}

.search-result-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #eaf6ff;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.search-result-btn:hover,
.search-result-btn:focus,
.search-result-btn.selected {
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}

.search-result-btn:focus,
.search-result-btn.selected {
  border-color: #ff9c00;
}

/* Loading spinner */

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--card-border);
  border-top: 4px solid #ff9c00;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Weather page: Header */

header a .bi-chevron-left {
  font-size: 2rem !important;
  color: #fff;
}

/* Weather page: Error state */

.error-icon {
  font-size: 3rem;
  color: #ff9c00;
}

header > a > i {
  font-size: 3rem !important;
  color: #fff;
}

/* Make header stretch the full width so its contents can align left
   (body uses a centered flex layout; this forces the header to fill horizontally) */
header {
  width: 100%;
  align-self: stretch;
}

/* Ensure the container in the header uses flexbox and left-aligns children */
header .container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

/* Weather page: Dynamic data labels and values */

span.data-label {
  text-transform: uppercase;
  font-size: 0.75rem;
  display: block;
  color: #adb5bd;
  margin-bottom: 0.5rem;
}

span.data-value {
  font-weight: 600;
  font-size: 1.2rem;
  display: block;
  color: #fff;
}

/* Weather page: Cards - Bootstrap overrides */

/* Align the contents of the right column to the right on large screens */
.right-col {
  text-align: right;
  align-items: stretch; /* allow children to use full height */
}

/* Override bootstrap centering utilities so inner content sits at the right */
.right-col > .new-box,
.right-col > .weather-icon-box {
  justify-content: flex-end;
  align-items: center;
  display: flex;
}

/* Ensure temp text aligns right inside its container */
.right-col #temp {
  text-align: right;
}

/* Temperature font size: 2.5rem default, 3rem on large screens */
.right-col #temp > span {
  font-size: 2.5rem;
}

@media (min-width: 992px) {
  .right-col #temp > span {
    font-size: 3rem;
    line-height: 1;
  }
}

.card.bg-dark {
  background-color: #232e3e !important;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.time-box {
  font-size: 3rem;
  font-weight: 600;
}

.location-name {
  font-size: 1.5rem;
  font-weight: 600;
}

.rain-coverage-box {
  min-height: 80px;
  font-size: 1.2rem;
}

.time-box > div {
  width: 100%;
  text-align: center;
  padding-bottom: 1rem;
}
.location-name > div {
  width: 100%;
  text-align: center;
}
.rain-coverage-box > div {
  width: 100%;
  text-align: center;
}

@media screen and (min-width: 991px) {
  .time-box > div {
    width: 100%;
    text-align: left;
    line-height: 1;
  }
  .location-name > div {
    width: 100%;
    text-align: left;
  }
  .rain-coverage-box > div {
    width: 100%;
    text-align: left;
  }
}

.degrees-box {
  min-height: 120px;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
}

.weather-icon-box {
  display: block;
  align-items: center;
  justify-content: center;
  background-color: transparent;
}

/* The actual icon (emoji/text) — this controls visual size */
.weather-icon-box > #weather-icon-box {
  display: inline-block;
  text-align: left;
  line-height: 1;
  /* By default the icon uses --icon-size but you can override with
     a direct font-size on the span if you want a different value. */
  font-size: 200px;
  max-width: 100%;
  max-height: 100%;
}

/* Weather page: Interactive map */

#interactive-map {
  height: 450px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
  background-color: #232e3e;
}

/* Desktop: make right-column children take equal halves and keep inner content centered */
@media (min-width: 992px) {
  .right-col > .weather-icon-box {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* Weather page: Forecast section */

#forecast {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
#forecast::-webkit-scrollbar {
  display: none;
}

#forecast .card {
  background-color: #232e3e !important;
  border-radius: 12px;
  text-align: center;
  background-color: #222222;
  margin: 5px;
  width: 100%;
  padding-top: 1rem;
  padding-bottom: 1rem;
  transition: transform 0.3s ease;
}

#forecast .card:hover {
  transform: scale(1.08);
}

#forecast .card h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

#forecast .card .icon {
  font-size: 2.5rem;
  margin: 10px 0;
}

#forecast .card .temps {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}

#forecast .card .card-text {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}

/* Scroll to top button */

#scrollToTop {
  display: none;
  width: 50px;
  height: 50px;
}

/* Footer styles */

/* Default: footer is not fixed */
#homepage-footer {
  position: relative;
}

/* For screens up to 915px width: apply fixed-bottom only when height > 520px */
@media (max-width: 915px) and (min-height: 521px) {
  #homepage-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
}

/* For screens over 915px width: apply fixed-bottom only when height > 820px */
@media (min-width: 916px) and (min-height: 821px) {
  #homepage-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
}

/* Footer icons and links */
footer .bi-github {
  font-size: 2rem;
}

footer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

footer a:focus {
  outline-offset: 4px;
}

footer .footer-logo {
  display: block;
}
