:root {
  color-scheme: dark;
  --clock: #000000;
  --pulse: #2f82ff;
  --mirror: #ffffff;
  --ink: #f8fbff;
  --muted: rgba(248, 251, 255, 0.68);
  --line: rgba(248, 251, 255, 0.2);
  --panel: rgba(11, 13, 15, 0.72);
  --shadow: rgba(0, 0, 0, 0.28);
  --second-progress: 0%;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 36px 18px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.13), transparent 32%),
    linear-gradient(145deg, var(--clock), var(--pulse) 62%, var(--mirror));
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 44px
    );
  mix-blend-mode: soft-light;
}

button,
time,
output,
dd,
b {
  font: inherit;
}

.clock-app {
  width: min(100%, 720px);
  display: grid;
  gap: 18px;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  text-shadow: 0 1px 18px var(--shadow);
}

.masthead p,
.masthead h1 {
  margin: 0;
}

.masthead p {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.masthead h1 {
  font-size: 1.35rem;
  font-weight: 760;
}

.clock-face {
  width: 100%;
  min-height: 430px;
  display: grid;
  align-content: center;
  gap: 26px;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 48%),
    var(--panel);
  box-shadow: 0 24px 72px var(--shadow);
  backdrop-filter: blur(22px) saturate(130%);
}

.time-block {
  display: grid;
  gap: 8px;
}

#time {
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 5rem;
  font-weight: 780;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#period {
  width: max-content;
  min-width: 44px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.hex-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#hex {
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 2rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

#copy {
  min-width: 92px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  cursor: pointer;
  font-weight: 720;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

#copy:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.44);
}

#copy:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--pulse), white 24%);
  outline-offset: 3px;
}

.second-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

#second-fill {
  display: block;
  width: var(--second-progress);
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--clock), var(--pulse));
  transition: width 140ms linear;
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.readout div {
  min-width: 0;
  padding: 0;
}

.readout dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.readout dd {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 6px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 10, 12, 0.42);
  backdrop-filter: blur(16px);
}

.chip {
  grid-row: span 2;
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: var(--clock);
}

#chip-pulse {
  background: var(--pulse);
}

#chip-mirror {
  background: var(--mirror);
}

.swatch span:not(.chip) {
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.swatch b {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-status {
  position: fixed;
  left: 50%;
  bottom: 18px;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 10, 12, 0.76);
  color: var(--ink);
  font-size: 0.84rem;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.copy-status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  body {
    align-items: stretch;
    padding: 18px;
  }

  .clock-app {
    align-self: center;
  }

  .masthead {
    display: grid;
    justify-content: start;
  }

  .clock-face {
    min-height: 390px;
    padding: 26px 20px;
  }

  #time {
    font-size: 3rem;
  }

  #hex {
    font-size: 1.45rem;
  }

  .readout,
  .palette {
    grid-template-columns: 1fr;
  }
}

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