@layer reset, base, components, responsive;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    min-width: 300px;
    min-height: 100%;
    background: #07111f;
  }

  body,
  h1,
  h2,
  p,
  dl,
  dd,
  fieldset {
    margin: 0;
  }

  button,
  input {
    font: inherit;
  }
}

@layer base {
  :root {
    --ink: #f8fbff;
    --muted: #9eb1c9;
    --panel: rgb(9 24 42 / 82%);
    --panel-solid: #0b1b2f;
    --line: rgb(172 207 236 / 17%);
    --accent: #7dd3fc;
    --accent-strong: #38bdf8;
    --accent-ink: #032439;
    --glow: rgb(56 189 248 / 22%);
    --status: #7dd3fc;
    --status-bg: rgb(56 189 248 / 13%);
    --shadow: 0 24px 80px rgb(0 0 0 / 32%);
  }

  body[data-mode="dropoff"] {
    --accent: #c4b5fd;
    --accent-strong: #8b5cf6;
    --accent-ink: #1e1042;
    --glow: rgb(139 92 246 / 25%);
  }

  body[data-theme="ready"] {
    --status: #6ee7b7;
    --status-bg: rgb(16 185 129 / 13%);
  }

  body[data-theme="soon"] {
    --status: #fcd34d;
    --status-bg: rgb(245 158 11 / 16%);
  }

  body[data-theme="late"],
  body[data-theme="error"] {
    --status: #fb7185;
    --status-bg: rgb(244 63 94 / 16%);
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ink);
    font-family:
      Inter,
      ui-sans-serif,
      system-ui,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      sans-serif;
    background:
      radial-gradient(circle at 14% 5%, var(--glow), transparent 34rem),
      radial-gradient(
        circle at 92% 22%,
        rgb(56 189 248 / 10%),
        transparent 28rem
      ),
      linear-gradient(165deg, #081522 0%, #06101d 58%, #07111f 100%);
    transition: background 300ms ease;
  }

  body[data-theme="late"] {
    background:
      radial-gradient(
        circle at 18% 4%,
        rgb(244 63 94 / 24%),
        transparent 32rem
      ),
      linear-gradient(165deg, #1d101b 0%, #100d18 62%, #120c15 100%);
  }

  main {
    position: relative;
    z-index: 1;
    width: min(1080px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 46px;
  }

  a {
    color: var(--accent);
  }

  button {
    color: inherit;
  }

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

@layer components {
  .sky {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .flight-path {
    position: absolute;
    top: 136px;
    right: -4vw;
    width: min(52vw, 680px);
    border-top: 1px dashed rgb(186 230 253 / 22%);
    transform: rotate(-8deg);
  }

  .plane {
    position: absolute;
    top: 95px;
    right: 13vw;
    color: rgb(224 242 254 / 30%);
    font-size: 42px;
    transform: rotate(-9deg);
    filter: drop-shadow(0 0 15px var(--glow));
  }

  body[data-mode="dropoff"] .plane {
    transform: rotate(171deg);
  }

  .cloud {
    position: absolute;
    display: block;
    width: 240px;
    height: 70px;
    border-radius: 999px;
    background: rgb(255 255 255 / 2.5%);
    filter: blur(1px);
  }

  .cloud::before,
  .cloud::after {
    position: absolute;
    content: "";
    border-radius: 50%;
    background: inherit;
  }

  .cloud::before {
    width: 90px;
    height: 90px;
    left: 52px;
    bottom: 8px;
  }

  .cloud::after {
    width: 120px;
    height: 120px;
    right: 40px;
    bottom: 3px;
  }

  .cloud-one {
    top: 430px;
    left: -90px;
  }

  .cloud-two {
    right: -100px;
    bottom: 90px;
    transform: scale(1.4);
  }

  .masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
  }

  .brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    color: var(--accent-ink);
    font-size: 22px;
    font-weight: 900;
    border-radius: 14px 14px 14px 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 8px 30px var(--glow);
  }

  .brand strong,
  .brand small {
    display: block;
  }

  .brand strong {
    font-size: 18px;
    letter-spacing: 0.01em;
  }

  .brand small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
  }

  .hero {
    max-width: 760px;
    padding: 84px 0 40px;
  }

  .eyebrow {
    margin-bottom: 13px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
  }

  h1 {
    max-width: 720px;
    font-size: clamp(42px, 7vw, 76px);
    font-weight: 820;
    letter-spacing: -0.055em;
    line-height: 0.98;
  }

  .lede {
    max-width: 650px;
    margin-top: 24px;
    color: var(--muted);
    font-size: clamp(17px, 2.3vw, 21px);
    line-height: 1.55;
  }

  .planner,
  .result,
  .notice {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
  }

  .planner {
    padding: 24px;
  }

  #trip-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.7fr) minmax(130px, 0.7fr) minmax(
        155px,
        0.8fr
      );
    gap: 18px;
    align-items: end;
  }

  .mode-switch {
    display: flex;
    grid-column: 1 / -1;
    width: max-content;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgb(2 10 20 / 43%);
  }

  .mode-switch legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .mode-switch label {
    cursor: pointer;
  }

  .mode-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .mode-switch span {
    display: block;
    min-width: 124px;
    padding: 10px 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 720;
    text-align: center;
    border-radius: 10px;
    transition:
      color 180ms ease,
      background 180ms ease,
      box-shadow 180ms ease;
  }

  .mode-switch b {
    margin-right: 6px;
    color: var(--accent);
  }

  .mode-switch input:checked + span {
    color: var(--ink);
    background: rgb(255 255 255 / 8%);
    box-shadow: 0 4px 18px rgb(0 0 0 / 18%);
  }

  .mode-switch input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .field label {
    display: block;
    margin-bottom: 8px;
    color: #dbeafe;
    font-size: 13px;
    font-weight: 720;
  }

  .field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
  }

  .origin-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .places-attribution {
    margin-top: 6px;
    flex: none;
    color: #9ba6b4;
    font-size: 10px;
    white-space: nowrap;
  }

  input[type="text"] {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    color: var(--ink);
    border: 1px solid rgb(186 230 253 / 18%);
    border-radius: 13px;
    outline: 0;
    background: rgb(2 10 20 / 52%);
    transition:
      border-color 180ms ease,
      box-shadow 180ms ease,
      background 180ms ease;
  }

  input::placeholder {
    color: #61758e;
  }

  input:focus {
    border-color: var(--accent);
    background: rgb(2 10 20 / 72%);
    box-shadow: 0 0 0 4px var(--glow);
  }

  .input-action {
    position: relative;
  }

  .input-action input {
    padding-right: 52px;
  }

  .icon-button {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    color: var(--accent);
    font-size: 22px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
  }

  .icon-button:hover {
    background: var(--status-bg);
  }

  .button {
    display: inline-flex;
    min-height: 48px;
    padding: 0 18px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 780;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    transition:
      transform 150ms ease,
      filter 150ms ease,
      background 150ms ease;
  }

  .button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
  }

  .button:active {
    transform: translateY(0);
  }

  .button-primary {
    grid-column: 1 / -1;
    color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 12px 36px var(--glow);
  }

  .button-quiet {
    min-height: 42px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: rgb(255 255 255 / 4%);
  }

  .notice {
    margin-top: 20px;
    padding: 18px 20px;
    color: #fecdd3;
    border-color: rgb(251 113 133 / 32%);
    background: rgb(80 16 34 / 65%);
  }

  .result {
    margin-top: 22px;
    overflow: hidden;
  }

  .result-topline {
    display: flex;
    padding: 20px 24px 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
  }

  .status-pill {
    display: inline-flex;
    padding: 6px 10px;
    align-items: center;
    color: var(--status);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid color-mix(in srgb, var(--status) 35%, transparent);
    border-radius: 999px;
    background: var(--status-bg);
  }

  .departure-callout {
    padding: 38px 24px 34px;
    text-align: center;
  }

  #departure-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.13em;
    text-transform: uppercase;
  }

  #departure-relative {
    margin-top: 8px;
    color: var(--status);
    font-size: clamp(42px, 8vw, 76px);
    letter-spacing: -0.055em;
    line-height: 1;
    text-wrap: balance;
  }

  #departure-absolute {
    margin-top: 14px;
    color: var(--ink);
    font-size: clamp(18px, 3vw, 25px);
    font-weight: 680;
  }

  .late-detail {
    max-width: 600px;
    margin: 15px auto 0;
    color: #fecdd3;
    line-height: 1.5;
  }

  .facts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .facts div {
    min-width: 0;
    padding: 20px;
  }

  .facts div + div {
    border-left: 1px solid var(--line);
  }

  .facts dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .facts dd {
    margin-top: 7px;
    overflow-wrap: anywhere;
    font-size: 15px;
    font-weight: 680;
    line-height: 1.4;
  }

  .refresh-line {
    display: flex;
    min-height: 56px;
    padding: 0 24px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
  }

  .text-button {
    padding: 4px;
    color: var(--accent);
    font-weight: 720;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  footer {
    max-width: 730px;
    margin: 28px auto 0;
    color: #71869f;
    font-size: 11px;
    line-height: 1.55;
    text-align: center;
  }

  footer a {
    color: #93a9c0;
  }

  [aria-busy="true"] .button-primary,
  .button-primary:disabled {
    cursor: wait;
    filter: saturate(0.5);
  }
}

@layer responsive {
  @media (max-width: 760px) {
    main {
      width: min(100% - 24px, 640px);
      padding-top: 18px;
    }

    .hero {
      padding: 62px 2px 30px;
    }

    #trip-form {
      grid-template-columns: 1fr;
    }

    .mode-switch {
      width: 100%;
    }

    .mode-switch label,
    .mode-switch span {
      width: 100%;
    }

    .facts {
      grid-template-columns: 1fr 1fr;
    }

    .facts div:nth-child(3) {
      border-left: 0;
      border-top: 1px solid var(--line);
    }

    .facts div:nth-child(4) {
      border-top: 1px solid var(--line);
    }
  }

  @media (max-width: 460px) {
    .masthead {
      align-items: flex-start;
    }

    .button-quiet {
      width: 44px;
      padding: 0;
      font-size: 0;
    }

    .button-quiet span {
      font-size: 20px;
    }

    h1 {
      font-size: 43px;
    }

    .planner {
      padding: 17px;
      border-radius: 19px;
    }

    .result {
      border-radius: 19px;
    }

    .result-topline {
      align-items: flex-start;
      flex-direction: column;
    }

    .facts {
      grid-template-columns: 1fr;
    }

    .facts div + div,
    .facts div:nth-child(3) {
      border-top: 1px solid var(--line);
      border-left: 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      scroll-behavior: auto !important;
      transition-duration: 0.01ms !important;
    }
  }
}
