/* DayDrop web. Mirrors the app: each countdown's accent paints the page, the
   day count is heavy SF Rounded, and the ring with its drop is the signature. */

:root {
  /* Per countdown; share.js sets these. The defaults are Ember. */
  --accent: #FF5A36;
  --partner: #FF9A3C;
  --fg: #FFFFFF;
  --on-accent: #FFFFFF;

  --ink: #17171C;
  --ink-2: #6C6C73;
  --surface: #FFFFFF;
  --control: rgb(23 23 28 / 0.06);
  --hairline: rgb(23 23 28 / 0.1);

  --round: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;

  --sheet-radius: 28px;
  --gutter-l: max(24px, env(safe-area-inset-left));
  --gutter-r: max(24px, env(safe-area-inset-right));
  --ring-size: clamp(92px, 27vw, 176px);
  --count-size: min(40vw, 27svh);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #F2F2F7;
    --ink-2: #98989F;
    --surface: #1C1C1E;
    --control: rgb(255 255 255 / 0.1);
    --hairline: rgb(255 255 255 / 0.12);
  }
}

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

[hidden] { display: none !important; }

html {
  background: var(--surface);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

/* ---------- The countdown ---------- */

.poster {
  position: relative;
  isolation: isolate;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 62svh;
  padding-block: max(28px, env(safe-area-inset-top)) calc(var(--sheet-radius) + 22px);
  padding-inline: var(--gutter-l) var(--gutter-r);
  color: var(--fg);
  background-color: var(--accent);
  overflow: hidden;
}

.stage-alone .poster {
  min-height: 100svh;
  padding-block-end: max(40px, env(safe-area-inset-bottom));
}

.poster[data-bg="solid"] {
  background-image: linear-gradient(180deg, rgb(255 255 255 / 0.18), rgb(255 255 255 / 0) 50%);
}

/* A soft take on the app's mesh: accent at the top left, partner pooling at the bottom right. */
.poster[data-bg="gradient"] {
  background-image:
    linear-gradient(180deg, rgb(255 255 255 / 0.18), rgb(255 255 255 / 0) 50%),
    radial-gradient(120% 90% at 100% 100%, var(--partner) 0 18%, transparent 72%),
    radial-gradient(70% 55% at 72% 48%, color-mix(in srgb, var(--accent), var(--partner)) 0, transparent 70%);
}

.photo {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Photos get the app's scrim: light at the top, darkest behind the day count. */
.poster[data-bg="image"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.28) 45%, rgb(0 0 0 / 0.62));
}

.ring-wrap {
  position: relative;
  flex: none;
  width: var(--ring-size);
  height: var(--ring-size);
  margin-bottom: clamp(20px, 5vw, 32px);
}

.ring {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ring-track,
.ring-arc {
  fill: none;
  stroke: currentColor;
  stroke-width: 10;
}

.ring-track { opacity: 0.28; }

.ring-arc { stroke-linecap: round; }

.ring-bead {
  fill: currentColor;
  filter: drop-shadow(0 1px 1.6px rgb(0 0 0 / 0.22));
}

.ring-emoji {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--ring-size) * 0.4);
  line-height: 1;
}

.title {
  margin: 0;
  max-width: 16ch;
  font: 800 clamp(30px, 8vw, 52px)/1.06 var(--round);
  letter-spacing: -0.012em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.meta {
  margin: 10px 0 0;
  max-width: 34ch;
  font: 600 clamp(16px, 4.3vw, 19px)/1.35 var(--round);
  opacity: 0.86;
  text-wrap: pretty;
}

.meta span { display: block; }

.count {
  margin-top: auto;
  padding-top: 36px;
}

.count-number {
  display: block;
  width: max-content;
  margin: 0 0 0 -0.045em;
  /* Room below the tight line box for a thousands comma or the y in "Today". */
  padding-bottom: 0.1em;
  font: 900 var(--count-size)/0.8 var(--round);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.count-caption {
  display: block;
  margin: 0.25em 0 0;
  font: 700 clamp(19px, 5.2vw, 26px)/1.2 var(--round);
  opacity: 0.9;
  text-wrap: balance;
}

/* A light action that sits on the poster itself. */
.pill {
  align-self: flex-start;
  margin-top: 20px;
  padding: 11px 20px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: 700 16px/1 var(--round);
  text-decoration: none;
  cursor: pointer;
}

/* While a hosted countdown loads, the ring turns slowly in the brand color. */
.stage[data-state="loading"] .ring { animation: turn 1.6s linear infinite; }
.stage[data-state="loading"] .title,
.stage[data-state="loading"] .meta,
.stage[data-state="loading"] .count { visibility: hidden; }

@keyframes turn { to { transform: rotate(1turn); } }

/* The home page's ring draws once, bead riding the head, to where the icon's ring sits. */
.ring-draw .ring-arc { animation: ring-draw 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s both; }
.ring-draw .ring-bead-group {
  transform-origin: 60px 60px;
  transform: rotate(259.2deg);
  animation: bead-ride 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s both;
}

@keyframes ring-draw { from { stroke-dasharray: 0 100; } }
@keyframes bead-ride { from { transform: rotate(0deg); } }

.brand-word {
  --count-size: clamp(64px, 19vw, 220px);
  font-variant-numeric: normal;
  letter-spacing: -0.03em;
}

/* ---------- The app, in an iPhone ---------- */

/* On narrow screens the phone rises out of the poster and the sheet slides
   over its lower half: the figure runs to the poster's bottom edge, which clips it. */
.hero-phone {
  --phone-w: min(74vw, 330px);
  flex: none;
  align-self: center;
  width: var(--phone-w);
  height: calc(var(--phone-w) * 1.15);
  margin: 40px 0 calc(-1 * (var(--sheet-radius) + 22px));
  animation: phone-rise 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.25s both;
}

.hero-phone img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 24px 40px rgb(0 0 0 / 0.35));
}

@keyframes phone-rise { from { opacity: 0; transform: translateY(24px); } }

/* ---------- What you can do with it ---------- */

.sheet {
  position: relative;
  z-index: 1;
  margin-top: calc(-1 * var(--sheet-radius));
  padding-block: 22px max(22px, env(safe-area-inset-bottom));
  padding-inline: var(--gutter-l) var(--gutter-r);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  background: var(--surface);
  color: var(--ink);
}

.sheet-inner { max-width: 520px; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-icon {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  box-shadow: 0 0 0 0.5px var(--hairline);
}

.sheet h2 {
  margin: 0;
  font: 800 21px/1.2 var(--round);
  letter-spacing: -0.005em;
}

.sub {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.35;
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  flex: 1 1 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font: 600 17px/1.1 var(--text);
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.button:active { transform: scale(0.97); }

.button-primary {
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent), var(--partner) 45%));
  color: var(--on-accent);
}

.button-secondary {
  background: var(--control);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  .button-primary { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12); }
}

.hint {
  margin: 14px 2px 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  text-wrap: pretty;
}

.hint[data-notice] {
  color: var(--ink);
  font-weight: 500;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.poster :focus-visible { outline-color: currentColor; }

/* ---------- Wide screens: the poster fills the window, the sheet floats ---------- */

@media (min-width: 880px) {
  :root {
    --ring-size: clamp(132px, 13vw, 184px);
    --count-size: min(21vw, 36svh);
  }

  .stage { display: block; position: relative; }

  .poster {
    min-height: 100svh;
    padding-block: 64px 48px;
    padding-inline: 72px;
  }

  .stage:not(.stage-alone) .count { max-width: calc(100% - 420px); }

  .brand-word { --count-size: min(11.5vw, 26svh); }

  /* Centered in the right half, in the space above the sheet (the poster
     less ~360px for the sheet and its margins). 2.04 is the frame's aspect. */
  .hero-phone {
    --above-sheet: calc(100svh - 360px);
    --phone-w: min(240px, var(--above-sheet) / 2.04);
    position: absolute;
    top: calc(48px + (var(--above-sheet) - var(--phone-w) * 2.04) / 2);
    left: calc(75% - var(--phone-w) / 2);
    height: auto;
    margin: 0;
  }

  .sheet {
    position: absolute;
    right: 40px;
    bottom: 40px;
    width: 384px;
    margin: 0;
    padding: 24px;
    border-radius: var(--sheet-radius);
    box-shadow: 0 30px 60px -24px rgb(0 0 0 / 0.4), 0 0 0 0.5px var(--hairline);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage[data-state="loading"] .ring,
  .ring-draw .ring-arc,
  .ring-draw .ring-bead-group,
  .hero-phone { animation: none; }
  .button { transition: none; }
}
