:root {
  --bg-0: #06101c;
  --bg-1: #0b223f;
  --glass: rgba(0, 0, 0, 0.72);
  --glass-strong: rgba(0, 0, 0, 0.86);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f5f2ea;
  --text-secondary: rgba(245, 242, 234, 0.84);
  --text-muted: rgba(245, 242, 234, 0.6);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --dim-strength: 1;
}

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

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050b14;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  text-rendering: optimizeLegibility;
}

body.dim-mode {
  --dim-strength: 0.78;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, calc((1 - var(--dim-strength)) * 0.12));
  z-index: 3;
  pointer-events: none;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

.photo-layer,
.ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.photo-layer {
  top: 50%;
  left: 50%;
  min-width: 106%;
  min-height: 106%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  transition: opacity 1200ms ease;
  border: 0;
}

.photo-base {
  opacity: 1;
  z-index: 0;
}

.photo-next {
  opacity: 0;
  z-index: 1;
}

.ambient {
  z-index: 2;
  transition: opacity 900ms ease, background 900ms ease;
}

.ambient-color {
  background:
    linear-gradient(180deg, rgba(12, 24, 42, 0.08) 0%, rgba(14, 34, 56, 0.02) 30%, rgba(12, 34, 58, 0.03) 62%, rgba(8, 18, 26, 0.12) 100%),
    radial-gradient(circle at 50% 120%, rgba(62, 118, 188, 0.12), transparent 38%);
}

.ambient-stars {
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 8% 16%, rgba(255, 255, 255, 0.85) 0 1px, transparent 1.5px),
    radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.55) 0 1px, transparent 1.4px),
    radial-gradient(circle at 42% 12%, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.5px),
    radial-gradient(circle at 64% 18%, rgba(255, 255, 255, 0.68) 0 1px, transparent 1.5px),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.6) 0 1px, transparent 1.4px),
    radial-gradient(circle at 92% 22%, rgba(255, 255, 255, 0.78) 0 1px, transparent 1.4px),
    radial-gradient(circle at 54% 28%, rgba(255, 255, 255, 0.42) 0 1px, transparent 1.4px);
}

.ambient-clouds {
  opacity: 0;
  mix-blend-mode: screen;
  background-repeat: repeat-x;
}

.ambient-clouds-back {
  background-image:
    radial-gradient(ellipse at 16% 52%, rgba(255, 255, 255, 0.16) 0 18%, transparent 20%),
    radial-gradient(ellipse at 46% 42%, rgba(255, 255, 255, 0.12) 0 19%, transparent 21%),
    radial-gradient(ellipse at 76% 50%, rgba(255, 255, 255, 0.11) 0 18%, transparent 20%);
  background-size: 52% 100%;
  animation: drift-slow 90s linear infinite;
  filter: blur(12px);
}

.ambient-clouds-front {
  background-image:
    radial-gradient(ellipse at 18% 48%, rgba(255, 255, 255, 0.18) 0 14%, transparent 17%),
    radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.14) 0 16%, transparent 18%),
    radial-gradient(ellipse at 82% 56%, rgba(255, 255, 255, 0.12) 0 14%, transparent 16%);
  background-size: 48% 100%;
  animation: drift-fast 58s linear infinite;
  filter: blur(7px);
}

.ambient-rain {
  opacity: 0;
  background-image: repeating-linear-gradient(
    104deg,
    transparent 0 18px,
    rgba(218, 233, 255, 0.08) 18px 20px,
    transparent 20px 36px
  );
  animation: rain-fall 1.3s linear infinite;
}

.ambient-fog {
  opacity: 0;
  background:
    radial-gradient(circle at 18% 72%, rgba(240, 245, 255, 0.14), transparent 32%),
    radial-gradient(circle at 72% 64%, rgba(240, 245, 255, 0.13), transparent 34%),
    radial-gradient(circle at 50% 90%, rgba(240, 245, 255, 0.1), transparent 40%);
  filter: blur(26px);
}

.ambient-vignette {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.16), transparent 24%, transparent 76%, rgba(0, 0, 0, 0.22)),
    radial-gradient(circle at center, transparent 48%, rgba(0, 0, 0, 0.08) 100%);
}

.display {
  position: relative;
  z-index: 4;
  width: 100%;
  height: 100%;
  padding:
    calc(24px + var(--safe-top))
    calc(28px + var(--safe-right))
    calc(18px + var(--safe-bottom))
    calc(28px + var(--safe-left));
}

.hero-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  height: 85vh;
  max-height: 85vh;
  padding: 24px 34px 20px;
  border-radius: 34px;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 280ms ease, border-color 280ms ease, box-shadow 280ms ease;
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 70%;
  height: 70%;
  min-height: 70%;
}

.hero-bottom-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  flex: 0 0 30%;
  height: 30%;
  min-height: 30%;
}

.hero-bottom-col {
  min-width: 0;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 0;
  flex: 1 1 0;
}

.hero-bottom-center {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 200px;
  flex: 0 0 200px;
  width: 200px;
  padding: 0 8px;
}

.hero-bottom-left {
  text-align: left;
}

.hero-bottom-right {
  text-align: right;
}

.hero-center {
  text-align: center;
}

.location-line,
.date-line,
.weather-summary,
.weather-meta,
.photo-credit {
  margin: 0;
}

.location-line {
  font-size: 2.25rem;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1;
  font-weight: 500;
  color: var(--text-primary);
}

.date-line {
  margin-top: 8px;
  font-size: 1.15rem;
  font-size: clamp(0.95rem, 1.5vw, 1.4rem);
  line-height: 1.15;
  color: var(--text-secondary);
}

.time-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

.time-line {
  margin: 0;
  font-size: 22rem;
  font-size: clamp(16rem, 47vh, 32rem);
  line-height: 0.66;
  font-family: "Avenir Next Condensed", "Arial Narrow", "HelveticaNeue-CondensedBold", "Roboto Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: -0.09em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--text-primary);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: color 280ms ease, text-shadow 280ms ease, transform 180ms ease;
}

.time-sidecar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  margin-left: 18px;
  margin-bottom: 0.85rem;
}

.seconds {
  display: block;
  min-width: 2ch;
  margin-bottom: 0.25rem;
  font-size: 2.6rem;
  line-height: 1;
  font-weight: 700;
  color: var(--text-primary);
  font-family: "Avenir Next Condensed", "Arial Narrow", "HelveticaNeue-CondensedBold", "Roboto Condensed", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  transition: color 280ms ease, transform 180ms ease;
}

.meridiem {
  margin-bottom: 0;
  font-size: 2.8rem;
  font-size: clamp(2rem, 3.3vw, 3.2rem);
  line-height: 1;
  font-weight: 700;
  color: var(--text-primary);
  font-family: "Avenir Next Condensed", "Arial Narrow", "HelveticaNeue-CondensedBold", "Roboto Condensed", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  transition: color 280ms ease, transform 180ms ease;
}

.weather-headline {
  display: inline-block;
}

.weather-temp {
  display: inline-block;
  vertical-align: top;
  font-size: 3.4rem;
  font-size: clamp(2.5rem, 4vw, 4rem);
  line-height: 0.95;
  font-weight: 500;
  margin-right: 10px;
}

.weather-range {
  display: inline-block;
  vertical-align: top;
  font-size: 1.25rem;
  font-size: clamp(0.95rem, 1.6vw, 1.5rem);
  line-height: 1.05;
  color: var(--text-primary);
  white-space: nowrap;
}

.weather-summary {
  margin-top: 8px;
  font-size: 1.5rem;
  font-size: clamp(1.15rem, 1.9vw, 1.8rem);
  line-height: 1.05;
  color: var(--text-primary);
}

.weather-emblem {
  position: relative;
  margin: 0 auto;
  width: 128px;
  height: 128px;
  width: clamp(110px, 10vw, 144px);
  height: clamp(110px, 10vw, 144px);
  display: block;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.weather-emblem img {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.28));
  transition: transform 280ms ease, filter 280ms ease;
}

.weather-meta {
  display: flex;
  justify-content: center;
  margin-top: -6px;
  color: rgba(245, 242, 234, 0.82);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  min-height: 1.4em;
}

.weather-meta span + span {
  margin-left: 24px;
}

.weather-meta strong {
  color: var(--text-primary);
  font-weight: 700;
}

.hero-card.mode-digital {
  background: rgba(0, 0, 0, 0.74);
}

.hero-card.mode-flip {
  background: rgba(8, 10, 14, 0.86);
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.hero-card.mode-flip .time-line,
.hero-card.mode-flip .seconds,
.hero-card.mode-flip .meridiem {
  color: #f7f3eb;
  text-shadow: none;
}

.hero-card.mode-flip .time-line {
  padding: 0.02em 0.18em 0.08em;
  background: linear-gradient(180deg, rgba(58, 59, 64, 0.96), rgba(25, 27, 31, 0.96));
  border-radius: 16px;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 30px rgba(0, 0, 0, 0.28);
}

.hero-card.mode-flip .time-sidecar {
  padding: 0.25rem 0.6rem 0.45rem;
  background: linear-gradient(180deg, rgba(58, 59, 64, 0.96), rgba(25, 27, 31, 0.96));
  border-radius: 12px;
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 22px rgba(0, 0, 0, 0.26);
}

.hero-card.mode-flip.time-tick .time-line,
.hero-card.mode-flip.time-tick .seconds,
.hero-card.mode-flip.time-tick .meridiem {
  transform: translateY(2px);
}

.hero-card.mode-splitflap {
  background:
    radial-gradient(circle, rgba(255, 181, 92, 0.09) 0 1px, transparent 1.6px) 0 0/10px 10px,
    rgba(8, 8, 8, 0.92);
  border-color: rgba(255, 201, 128, 0.08);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
}

.hero-card.mode-splitflap .location-line,
.hero-card.mode-splitflap .date-line,
.hero-card.mode-splitflap .weather-temp,
.hero-card.mode-splitflap .weather-range,
.hero-card.mode-splitflap .weather-summary,
.hero-card.mode-splitflap .weather-meta,
.hero-card.mode-splitflap .weather-meta strong,
.hero-card.mode-splitflap .time-line,
.hero-card.mode-splitflap .seconds,
.hero-card.mode-splitflap .meridiem {
  color: #ffbf6a;
  text-shadow: 0 0 14px rgba(255, 165, 71, 0.08);
}

.hero-card.mode-splitflap .time-line,
.hero-card.mode-splitflap .seconds,
.hero-card.mode-splitflap .meridiem {
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.hero-card.mode-splitflap .weather-emblem img {
  filter: grayscale(1) sepia(0.65) saturate(2.2) hue-rotate(338deg) brightness(0.92) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.32));
}

.photo-credit {
  display: none;
}

body.theme-clear-day .ambient-stars {
  opacity: 0.06;
}

body.theme-clear-day .ambient-color {
  background:
    linear-gradient(180deg, rgba(28, 68, 110, 0.28), rgba(19, 88, 150, 0.1) 32%, rgba(12, 40, 70, 0.26)),
    radial-gradient(circle at 50% 100%, rgba(255, 194, 105, 0.16), transparent 36%);
}

body.theme-cloudy .ambient-clouds,
body.theme-partly-cloudy-day .ambient-clouds,
body.theme-partly-cloudy-night .ambient-clouds,
body.theme-rain .ambient-clouds,
body.theme-rain-light .ambient-clouds,
body.theme-drizzle .ambient-clouds,
body.theme-thunderstorm .ambient-clouds,
body.theme-fog .ambient-clouds {
  opacity: 0.84;
}

body.theme-fog .ambient-fog {
  opacity: 0.88;
}

body.theme-rain .ambient-rain,
body.theme-rain-light .ambient-rain,
body.theme-drizzle .ambient-rain,
body.theme-thunderstorm .ambient-rain {
  opacity: 0.56;
}

body.theme-rain-light .ambient-rain,
body.theme-drizzle .ambient-rain {
  opacity: 0.32;
}

body.theme-thunderstorm .ambient-color {
  background:
    linear-gradient(180deg, rgba(4, 11, 21, 0.52), rgba(8, 22, 38, 0.24) 26%, rgba(3, 9, 16, 0.56) 100%),
    radial-gradient(circle at 50% 100%, rgba(93, 113, 163, 0.2), transparent 38%);
}

body.theme-fog .ambient-stars,
body.theme-cloudy .ambient-stars,
body.theme-rain .ambient-stars,
body.theme-rain-light .ambient-stars,
body.theme-drizzle .ambient-stars,
body.theme-thunderstorm .ambient-stars {
  opacity: 0.08;
}

body.theme-cold .ambient-color {
  background:
    linear-gradient(180deg, rgba(10, 30, 50, 0.34), rgba(16, 48, 80, 0.1) 28%, rgba(10, 24, 40, 0.42)),
    radial-gradient(circle at 50% 100%, rgba(120, 175, 255, 0.18), transparent 36%);
}

body.theme-hot .ambient-color {
  background:
    linear-gradient(180deg, rgba(28, 42, 67, 0.26), rgba(74, 98, 146, 0.08) 26%, rgba(20, 34, 48, 0.34)),
    radial-gradient(circle at 50% 100%, rgba(255, 186, 92, 0.18), transparent 36%);
}

.time-row-flip,
.time-row-split {
  display: none;
}

.flip-clock {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  perspective: 1200px;
  -webkit-perspective: 1200px;
}

.flip-digit {
  position: relative;
  width: clamp(8.3rem, 13.4vw, 11.4rem);
  height: clamp(20rem, 32vh, 26rem);
  margin: 0 0.22rem;
  border-radius: 0.35rem;
  background: #202227;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.flip-digit::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.flip-current,
.flip-next {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Avenir Next Condensed", "Arial Narrow", "HelveticaNeue-CondensedBold", "Roboto Condensed", sans-serif;
  font-size: clamp(10.6rem, 22vh, 17rem);
  line-height: 1;
  font-weight: 700;
  color: #f7f3eb;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-origin: center 50%;
  -webkit-transform-origin: center 50%;
}

.flip-next {
  transform: rotateX(90deg);
  -webkit-transform: rotateX(90deg);
}

.flip-colon {
  margin: 0 0.42rem 1rem;
  font-family: "Avenir Next Condensed", "Arial Narrow", "HelveticaNeue-CondensedBold", "Roboto Condensed", sans-serif;
  font-size: clamp(11.5rem, 24vh, 18rem);
  line-height: 1;
  font-weight: 700;
  color: #f7f3eb;
}

.digit-flip .flip-current {
  animation: flipOut 0.54s ease forwards;
}

.digit-flip .flip-next {
  animation: flipIn 0.54s ease forwards;
}

.split-clock {
  min-width: 0;
  padding: 0.08em 0.16em;
  border-radius: 0.08em;
  background:
    radial-gradient(circle, rgba(255, 165, 71, 0.14) 0 1px, transparent 1.7px) 0 0/10px 10px,
    #080808;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -2px 0 rgba(0, 0, 0, 0.46),
    0 12px 30px rgba(0, 0, 0, 0.3);
  font-family: "MatrixSansPrint", "Courier New", monospace;
  font-size: clamp(12.5rem, 27vh, 18.8rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: #ffbf6a;
  white-space: nowrap;
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .hero-card {
    background: rgba(0, 0, 0, 0.72);
  }
}

@keyframes flipOut {
  0% { transform: rotateX(0deg); opacity: 1; }
  100% { transform: rotateX(-90deg); opacity: 0; }
}

@keyframes flipIn {
  0% { transform: rotateX(90deg); opacity: 0; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

@keyframes drift-slow {
  from { transform: translate3d(-10%, 0, 0); }
  to { transform: translate3d(10%, 0, 0); }
}

@keyframes drift-fast {
  from { transform: translate3d(-6%, 0, 0); }
  to { transform: translate3d(15%, 0, 0); }
}

@keyframes rain-fall {
  from { transform: translate3d(0, -16px, 0); }
  to { transform: translate3d(-8px, 16px, 0); }
}

@media (max-width: 820px), (orientation: portrait) {
  .hero-card {
    top: 50%;
    width: 94vw;
    max-width: 900px;
    height: auto;
    max-height: none;
    padding: 22px 18px 18px;
  }

  .hero-top-row {
    min-height: 0;
    height: auto;
  }

  .hero-bottom-row {
    display: block;
    height: auto;
  }

  .hero-bottom-left,
  .hero-bottom-right,
  .hero-center {
    text-align: center;
  }

  .hero-bottom-center {
    width: auto;
    padding: 0;
  }

  .weather-headline {
    justify-content: center;
  }

  .weather-meta {
    margin-top: 22px;
    flex-wrap: wrap;
  }

  .weather-emblem {
    margin: 18px auto 0;
  }

  .weather-meta span + span {
    margin-left: 14px;
  }

  .photo-credit {
    max-width: 80vw;
  }
}
