/* Mattress Minute clock page. */

:root {
  --bg: #dadada;
  --text: #fff;
  --text-shadow: 0 1px 3px rgba(0, 0, 0, .07);
  --menu-bg: #333;
  --menu-text: #dadada;
  --control-bg: #111;
  --control-hover: #444;
  --gutter: 20px;
  --swap-fade: .3s;
  --swap-spin: .25s;
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
:root[data-theme="dark"] {
  --bg: #000;
  --text: #dadada;
  --text-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Barlow', system-ui, sans-serif;
  transition: background-color .5s ease;
}

button, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ---------- Photo ---------- */

.frame {
  position: relative;
  transition: width .5s ease-in-out, height .5s ease-in-out, border-radius .5s ease-in-out;
  cursor: pointer;
}
.view-circle .frame {
  width: 95vmin;
  height: 95vmin;
  border-radius: 50%;
  overflow: hidden;
}
.view-fill .frame {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}
.view-fit .frame {
  width: 90vw;
  height: 90vh;
  height: 90dvh;
}

.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}
.view-fit .photo {
  object-fit: contain;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, .2));
}
.photo:not([src]) { visibility: hidden; }
.photo-out { pointer-events: none; }

/* ---------- Time + details (bottom left) ---------- */

.info {
  position: fixed;
  left: 0;
  bottom: 0;
  padding: var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  font-size: min(2vmax, 40px);
  text-shadow: var(--text-shadow);
  pointer-events: none;
}
.info a {
  color: inherit;
  text-decoration: none;
  border-bottom: .1em dashed currentColor;
  pointer-events: auto;
}

.time {
  margin: 0;
  font-size: 3em;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.am-pm { font-size: .6em; font-weight: 800; }

.ticker {
  width: 10em;
  height: .35em;
}
.ticker-bar {
  width: 100%;
  height: 100%;
  background-color: currentColor;
  box-shadow: var(--text-shadow);
  transition: width .5s ease-out;
}

.meta {
  margin: .5em 0 0;
  font-size: 1em;
  line-height: 1.25;
}

/* ---------- Menu (top left) ---------- */

.menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  padding: var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-top: max(var(--gutter), env(safe-area-inset-top));
}
.menu.open {
  background-color: var(--menu-bg);
  color: var(--menu-text);
}
.menu-toggle {
  display: block;
  margin-bottom: 10px;
  filter: drop-shadow(var(--text-shadow));
  transition: opacity .6s ease;
}
.menu.open .menu-toggle { filter: none; }
.menu-toggle svg { display: block; }

.dropdown { display: none; }
.menu.open .dropdown {
  display: grid;
  gap: 4px;
  justify-items: start;
}
.dropdown label {
  margin-top: 6px;
  font-size: .7em;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.dropdown select {
  min-width: 120px;
  padding: 5px;
  font-size: 14px;
  color: #fff;
  background-color: var(--control-bg);
  border: 0;
}
.text-button {
  padding: 6px 8px;
  font-size: .8em;
  font-weight: 800;
  letter-spacing: .04em;
  color: #fff;
  background-color: var(--control-bg);
}
.text-button:hover { background-color: var(--control-hover); }
.credit {
  margin: 10px 0 0;
  font-size: .7em;
  line-height: 1.5;
  opacity: .6;
}
.credit a { color: inherit; text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* No shape animation while the window is being resized (the circle would
   stretch into an oval and then ease back). View switches still animate. */
.resizing .frame { transition: none; }

/* Fade the menu button (and the cursor in fullscreen) when idle. */
.idle .menu:not(.open) .menu-toggle { opacity: 0; }
.idle.fullscreen, .idle.fullscreen * { cursor: none; }

/* ---------- Messages ---------- */

.notice {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  text-align: center;
  font-size: 1.2rem;
  text-shadow: var(--text-shadow);
}

@media (prefers-reduced-motion: reduce) {
  :root { --swap-spin: 0s; }
  .frame, .ticker-bar { transition: none; }
}
