/*
 * huoshui.org desktop landing page.
 * Hand-written to replace the Bootstrap 3 bundle the original shipped for one navbar.
 * The desktop composition (>= 1151px) keeps the original's vh/vw geometry exactly.
 */

:root {
  --color-bg: #429fb4;
  --color-banner: #58a9bb;
  --color-spinner: #36abe0;
  --color-screen: #141414;
  --color-footer-bg: #eaeaea;
  --color-text: #333;
  --color-link: #337ab7;
  --color-link-hover: #23527c;
  --font-sans: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;

  --topbar-h: 50px;

  /* Hero geometry. The original measured everything against 100vh. */
  --hero-h: 100vh;
  --hero-left: 15vw;
  --social-left: 16vw;
  --device-h: calc(var(--hero-h) * 0.85);
  --device-ratio: 1.14574; /* 794 / 693, the tablet artwork */
  /*
   * Caps for tall, narrow windows (5:4 and portrait monitors), derived from the
   * artwork's transparent margins: the tablet body starts 21.7% in at the
   * title's height, the hand 8% in at the contact block's height. The title is
   * ~410px wide; the contact block is its text, the gap and the QR code.
   * Common 16:9 sizes never hit either cap.
   */
  --title-w: 430px;
  --social-w: calc(240px + max(16px, 19vw - 230px) + var(--hero-h) * 0.15);
  --device-max-w: min(
    calc((100vw - var(--hero-left) - var(--title-w)) / 0.78),
    calc((100vw - var(--social-left) - var(--social-w) - 8px) / 0.92)
  );
}

@supports (height: 100svh) {
  :root {
    --hero-h: 100svh;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.428571429;
  color: var(--color-text);
  background-color: var(--color-bg);
}

img {
  border: 0;
  vertical-align: middle;
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--color-link);
  text-decoration: none;
}

a:hover,
a:focus {
  color: var(--color-link-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

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

/* ---------------------------------------------------------------------------
 * Top bar
 * ------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  height: var(--topbar-h);
  background-color: var(--color-banner);
}

/* Bootstrap 3 container steps, kept so the brand sits where it always has. */
.container {
  margin: 0 auto;
  padding: 0 15px;
}

@media (min-width: 768px) {
  .container {
    width: 750px;
  }
}

@media (min-width: 992px) {
  .container {
    width: 970px;
  }
}

@media (min-width: 1200px) {
  .container {
    width: 1170px;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  height: var(--topbar-h);
  font-size: 30px;
  font-weight: bold;
  color: #fff;
}

.brand:hover,
.brand:focus {
  color: #fff;
  text-decoration: none;
}

/* ---------------------------------------------------------------------------
 * Hero: title top-left, contact bottom-left, tablet bottom-right
 * ------------------------------------------------------------------------- */

.hero {
  position: relative;
  min-height: var(--hero-h);
  padding: var(--topbar-h) 35px 0;
}

.hero-title {
  position: absolute;
  top: calc(var(--hero-h) * 0.27);
  left: var(--hero-left);
  color: #fff;
  text-align: center;
}

.hero-title h1 {
  margin: 20px 0 10px;
  font-size: 50px;
  font-weight: 500;
  line-height: 1.1;
}

.hero-tagline {
  display: flex;
  justify-content: center;
  gap: 0.85em;
  margin: calc(var(--hero-h) * 0.05) 0 10px;
  padding: 0;
  list-style: none;
  font-size: 20px;
  font-weight: bold;
}

.hero-tagline li {
  display: flex;
  gap: 0.85em;
}

.hero-tagline li::before,
.hero-tagline li:last-child::after {
  content: "•";
}

.hero-social {
  position: absolute;
  bottom: calc(var(--hero-h) * 0.15);
  left: var(--social-left);
  display: flex;
  align-items: flex-end;
  gap: max(16px, 19vw - 230px);
  color: #fff;
  font-weight: bold;
}

.hero-social a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.55);
  text-underline-offset: 2px;
}

.hero-social a:hover,
.hero-social a:focus {
  color: inherit;
  text-decoration-color: currentColor;
}

.hero-social img {
  display: block;
  width: calc(var(--hero-h) * 0.15);
  height: auto;
}

.device {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(calc(var(--device-h) * var(--device-ratio)), var(--device-max-w));
  aspect-ratio: 794 / 693;
}

.device__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The glass area of the artwork, as a fraction of the image. */
.device__screen {
  position: absolute;
  top: 8.588%;
  left: 25.256%;
  width: 52%;
  height: 78.7%;
  background-color: var(--color-screen);
}

.device__frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Two chasing dots, shown until the app has loaded inside the frame. */
.spinner {
  position: absolute;
  top: 35%;
  left: 50%;
  width: 100px;
  height: 100px;
  transform: translateX(-50%);
  animation: sk-rotate 2s infinite linear;
}

.spinner__dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background-color: var(--color-spinner);
  animation: sk-bounce 2s infinite ease-in-out;
}

.spinner__dot:last-of-type {
  top: auto;
  bottom: 0;
  animation-delay: -1s;
}

.device__screen.is-loaded .spinner {
  display: none;
}

@keyframes sk-rotate {
  100% {
    transform: translateX(-50%) rotate(360deg);
  }
}

@keyframes sk-bounce {
  0%,
  100% {
    transform: scale(0);
  }
  50% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .spinner__dot {
    animation: none;
  }

  .spinner__dot {
    transform: scale(0.6);
  }
}

/* ---------------------------------------------------------------------------
 * Footer
 * ------------------------------------------------------------------------- */

.footer {
  height: 100px;
  padding-top: 20px;
  text-align: center;
  background-color: var(--color-footer-bg);
}

/* ---------------------------------------------------------------------------
 * Narrower windows
 * ------------------------------------------------------------------------- */

/* 1151-1280px: the original nudged the left column inward here. */
@media (max-width: 1280px) {
  :root {
    --hero-left: 8vw;
    --social-left: 9vw;
  }
}

/*
 * Below 1151px the original hid the title and contact block and left the tablet
 * floating (or, on portrait tablets, cut off). Stack everything instead.
 */
@media (max-width: 1150px) {
  .hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 6vh;
  }

  .hero-title,
  .hero-social {
    position: static;
  }

  /* Stays positioned: the artwork and screen inside are absolute to it. */
  .device {
    position: relative;
  }

  .hero-title {
    margin-top: 4vh;
  }

  .device {
    order: 2;
    width: min(92vw, 640px);
    margin-top: 4vh;
  }

  .hero-social {
    order: 3;
    gap: 32px;
    margin-top: 5vh;
  }
}

/*
 * A portrait or square window in the stacked range is already the shape the
 * app is built for (a phone or a portrait tablet), and the tablet's glass would
 * shrink the app to under half its width. Give the app the whole window
 * instead. The same iframe is restyled, not moved, so resizing across this
 * line never reloads the app or loses its state. Wider windows keep the
 * composition: the app has no max-width, and stretched past ~1150px it reads
 * worse than the tablet.
 */
@media (max-width: 1150px) and (max-aspect-ratio: 1/1) {
  body {
    overflow: hidden;
  }

  .topbar,
  .hero-title,
  .hero-social,
  .device__art,
  .footer {
    display: none;
  }

  .device__screen {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    background-color: #fff;
  }
}
