/* scheme: baked into the site, so it's the same everywhere */
@font-face {
  font-family: 'Scheme';
  src: url('../fonts/Scheme.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'Plex';
  src: url('../fonts/IBMPlexMono-Regular.ttf') format('truetype');
  font-display: swap;
}

/* the world is drawn by hand. the controls around it are plainly digital. */
:root {
  --paper: #ffffff;
  --ink: #1d1a5e;
  --dim: rgba(29, 26, 94, 0.6);
  --faint: rgba(29, 26, 94, 0.35);
  --ui: #05060a;
  --ui-fg: #ffffff;
  --blue: #00b4ff;
  --pink: #ff3d8e;
  --head: 'Scheme', 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'Plex', ui-monospace, Menlo, Consolas, monospace;
}
body[data-theme="night"] {
  --paper: #3e3478;
  --ink: #ffffff;
  --dim: rgba(255, 255, 255, 0.66);
  --faint: rgba(255, 255, 255, 0.4);
  --ui: #ffffff;
  --ui-fg: #3e3478;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--mono);
  -webkit-tap-highlight-color: transparent;
}

#sky { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
#sky.grabbing { cursor: grabbing; }
#sky.pointing, body.marking #sky { cursor: pointer; }
body.marking #sky { cursor: crosshair; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* waking up: the header and buttons wait until the world has woken (and appear anyway if something goes wrong) */
#top, #acts, #zoom { transition: opacity 1.2s ease, visibility 0s; }
#acts { transition-delay: .25s; }
#zoom { transition-delay: .5s; }
/* while the world sleeps the ui isn't just see-through but properly hidden, so no browser paints a trace of it */
body.intro #top, body.intro #acts, body.intro #zoom { opacity: 0; visibility: hidden; pointer-events: none; animation: introfallback 0s 12s forwards; }
body.intro #top a, body.intro #top button { pointer-events: none; }
@keyframes introfallback { to { opacity: 1; visibility: visible; } }
#sky { animation: skyin 1.4s ease both; }
@keyframes skyin { from { opacity: 0; } }

#top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 20px; pointer-events: none;
}
h1 { font-family: var(--head); font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: .01em; }
#clock { font-size: 11px; color: var(--dim); margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: .04em; text-transform: uppercase; }
#clock .ck { white-space: nowrap; }
#clock.stacked .dot { display: none; }
#clock.stacked .ck { display: block; }
#presence { text-align: right; font-size: 11px; color: var(--dim); line-height: 1.8; letter-spacing: .04em; text-transform: uppercase; }
#here { color: var(--ink); }
/* the record, one rainbow letter at a time */
#today .record span { display: inline-block; white-space: pre; animation: rainbowtext 2.4s linear infinite, hop 1.2s ease-in-out infinite; animation-delay: calc(var(--i) * -0.09s), calc(var(--i) * -0.07s); }
@keyframes rainbowtext { 0%, 100% { color: #ff4a6e; } 16% { color: #ff9a3c; } 33% { color: #e0b000; } 50% { color: #3cb83c; } 66% { color: #00a0e6; } 83% { color: #6b7bff; } }
@keyframes hop { 0%, 100% { transform: none; } 50% { transform: translateY(-2px); } }
#here::before { content: '● '; color: #2bd96b; }
#ways { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; margin-top: 2px; }
#ways .w1, #ways .w2 { display: contents; }
#ways a { pointer-events: auto; }
#ways a { color: var(--ink); text-decoration: none; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; border-bottom: 1px solid transparent; }
#ways a:hover { border-bottom-color: var(--ink); }

/* little messages float above the world */
#whisper {
  position: fixed; left: 50%; top: var(--under-top, 76px); transform: translateX(-50%);
  width: var(--whisper-w, min(600px, calc(100vw - 32px))); text-align: center;
  font-family: var(--head); font-size: 22px; line-height: 1.3; text-wrap: balance;
  color: var(--ink); opacity: 0; transition: opacity 1.1s ease; pointer-events: none; z-index: 2;
}
#whisper.on { opacity: 1; transition-duration: .3s; }
#whisper.quote.on { pointer-events: auto; }
#whisper a { color: inherit; text-decoration: none; }
#whisper a:hover { color: var(--pink); }
#whisper .from {
  display: block; margin-top: 6px;
  font-family: var(--mono); font-style: normal; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
}
#whisper a:hover .from { color: var(--pink); }
#whisper .cursor { display: inline-block; margin-left: 2px; color: var(--ink); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

#tip {
  position: fixed; pointer-events: none; z-index: 3;
  font-size: 10px; line-height: 1.5; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ui-fg); background: var(--ui);
  padding: 4px 8px; width: max-content; max-width: min(340px, calc(100vw - 24px)); text-align: center;
  transform: translate(-50%, calc(-100% - 16px));
}

/* buttons: square, mono, a hard shadow. love everyone is the biggest. */
#acts {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#acts .row { display: flex; gap: 10px; }
#acts button, #zoom button {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 8px 12px; color: var(--ui); background: var(--paper);
  border: 1px solid var(--ui); border-radius: 0;
  box-shadow: 3px 3px 0 var(--ui);
  transition: transform .08s, box-shadow .08s, background .15s, color .15s;
}
#acts button:hover, #zoom button:hover { background: var(--ui); color: var(--ui-fg); }
#acts button:active, #zoom button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ui); }
#acts button[aria-pressed="true"] { background: var(--ui); color: var(--ui-fg); }

/* i love you all: the rectangle, with cloud bumps rolling around its edge (drawn in heartstar.js) */
#act-all {
  font-family: var(--head) !important; text-transform: none !important;
  font-size: 24px !important; letter-spacing: .02em !important; padding: 15px 38px 17px !important;
  border: 0 !important; box-shadow: none !important; background: none !important;
  position: relative;
}
#act-all > span { position: relative; z-index: 1; }
#act-all .cloud { position: absolute; left: 0; top: 0; pointer-events: none; }
#act-all:hover { color: #fff !important; background: none !important; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); }
#act-all:active { transform: translate(4px, 5px); }

#act-you { display: inline-flex; align-items: center; gap: 7px; }
#act-sound .ico { display: none; }
#act-you .sw { width: 10px; height: 10px; border: 1px solid #05060a; display: inline-block; }

/* little windows */
.win {
  position: fixed; z-index: 4; left: 50%; bottom: calc(var(--acts-h, 120px) + 8px); transform: translateX(-50%); /* 12px above the buttons, like the gap between them */
  background: var(--paper); border: 1px solid var(--ui); box-shadow: 4px 4px 0 var(--ui);
  width: min(380px, calc(100vw - 32px));
}
.win[hidden] { display: none; }
.win .bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ui); color: var(--ui-fg);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 4px 3px 8px;
}
.win .bar button { width: 16px; height: 16px; line-height: 14px; font-size: 13px; border: 1px solid var(--ui-fg); color: var(--ui-fg); }
.win .small { font-size: 11px; color: var(--dim); line-height: 1.6; padding: 10px 14px 0; }

#swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 4px; }
.swatch { width: 26px; height: 26px; border: 1px solid #05060a; transition: transform .1s, box-shadow .1s; }
.swatch:hover { transform: translate(-2px, -2px); box-shadow: 2px 2px 0 var(--ui); }

#custom { position: relative; display: grid; place-items: center; background: #fff; color: #05060a; cursor: pointer; }
#custom svg { width: 15px; height: 15px; pointer-events: none; filter: drop-shadow(0 0 1px #fff); }
#custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
#name-form { display: flex; align-items: center; gap: 6px; padding: 10px 14px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#name-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 12px; text-transform: lowercase; letter-spacing: .02em;
  padding: 6px 8px; border: 1px solid var(--ui); background: var(--paper); color: var(--ink); border-radius: 0; outline: none;
}
#name-form input:focus { box-shadow: 2px 2px 0 var(--ui); }
#name-form .suffix { color: var(--dim); text-transform: lowercase; }
#name-form button { padding: 6px 10px; border: 1px solid var(--ui); box-shadow: 2px 2px 0 var(--ui); text-transform: uppercase; }
#name-form button:active { transform: translate(2px, 2px); box-shadow: none; }
#say-form { display: flex; align-items: center; gap: 6px; padding: 0 14px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#say-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 12px; text-transform: lowercase; letter-spacing: .02em;
  padding: 6px 8px; border: 1px solid var(--ui); background: var(--paper); color: var(--ink); border-radius: 0; outline: none;
}
#say-form input:focus { box-shadow: 2px 2px 0 var(--ui); }
#say-form button { padding: 6px 10px; border: 1px solid var(--ui); box-shadow: 2px 2px 0 var(--ui); text-transform: uppercase; }
#say-form button:active { transform: translate(2px, 2px); box-shadow: none; }
#say-form button:disabled { opacity: .5; }

#plants { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 12px 14px 14px; }
.plant { aspect-ratio: 1; border: 1px solid var(--ui); display: grid; place-items: center; background: var(--paper); }
.plant canvas { width: 34px; height: 34px; }
.plant:hover { box-shadow: 2px 2px 0 var(--ui); transform: translate(-1px, -1px); }

#sing-card > p:not(.small) { font-family: var(--head); font-size: 21px; padding: 14px 14px 0; }
#sing-card .row { display: flex; gap: 10px; padding: 14px; }
#sing-card .row button {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 7px 12px;
  border: 1px solid var(--ui); box-shadow: 3px 3px 0 var(--ui); color: var(--ui);
}
#sing-card .row button:active { transform: translate(3px, 3px); box-shadow: none; }
#sing-yes { background: var(--ui) !important; color: var(--ui-fg) !important; }

/* today: a small kindness, and breathing and humming together */
#kind-act { font-family: var(--head); font-size: 21px; line-height: 1.3; padding: 10px 18px 0; text-wrap: balance; text-align: center; }
#kind-src { text-align: center; font-style: italic; padding-top: 6px; white-space: pre-line; }
#kind-date { text-align: center; }
#today-win .row { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 14px 14px 4px; }
#today-win .kflower svg { width: 30px; height: 38px; display: block; }
#today-win .kflower:last-child svg { transform: scaleX(-1); }
#today-win .kflower .petals { transform-box: view-box; transform-origin: 15px 13px; animation: petalspin 13.8s linear infinite; }
@keyframes petalspin { to { transform: rotate(360deg); } }
#today-win button:not(.x) {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 7px 12px;
  border: 1px solid var(--ui); box-shadow: 3px 3px 0 var(--ui); color: var(--ui); background: var(--paper);
}
#today-win button:not(.x):active { transform: translate(3px, 3px); box-shadow: none; }
#kind-done { background: var(--paper) !important; color: var(--ui) !important; } /* unfilled, until you hover or say it */
#kind-done:not(.done):hover { background: var(--ui) !important; color: var(--ui-fg) !important; }
#kind-done.done { color: #fff !important; border-color: transparent !important; text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  background: linear-gradient(90deg, #ff4a6e, #ff9a3c, #ffd23f, #62d64a, #00b4ff, #6b7bff, #b06bff, #ff4a6e) 0 0 / 200% 100% !important;
  animation: rainbowslide 3s linear infinite; cursor: default; }
@keyframes rainbowslide { to { background-position: -200% 0; } }
#today-win .together { border-top: 1px dashed var(--ui); margin: 12px 14px 0; padding: 10px 0 0; }
#today-win .together { padding-bottom: 14px; }

/* while planet scorsby breathes or sings, everything else steps back */
#act-all, #acts button, .win { transition: opacity 1.2s ease; }
body.ritual #top, body.ritual #act-all, body.ritual #acts button, body.ritual #zoom, body.ritual .win, body.ritual #tip { opacity: 0 !important; pointer-events: none !important; }
/* singing keeps just the sound button, on its own in the middle */
body.ritual.ritual-sing #acts button:not(#act-sound) { display: none; }
body.ritual.ritual-sing #acts .row { justify-content: center; }
body.ritual.ritual-sing #acts { align-items: center; }
body.ritual.ritual-sing #acts button#act-sound { opacity: 1 !important; pointer-events: auto !important; }
/* once the sound is on, that button fades away too, leaving just the song */
body.ritual.ritual-sing.sound-on #acts button#act-sound { opacity: 0 !important; pointer-events: none !important; }

#zoom { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; }
#zoom button { width: 32px; height: 32px; padding: 0; font-size: 16px; }

#home {
  position: fixed; right: 20px; bottom: 24px; font-size: 18px;
  color: var(--faint); text-decoration: none; transition: color .3s;
}
#home:hover { color: var(--ink); }

@media (max-width: 600px) {
  #top { padding: 14px 16px; }
  h1 { font-size: 24px; }
  #top { gap: 14px; }
  #presence { flex: 0 0 auto; max-width: none; }
  #today .rec { white-space: nowrap; }
  #top > div:first-child { min-width: 0; }
  #whisper { font-size: 17px; }
  #today .sep { display: none; }
  #today .rec { display: block; }
  /* love everyone spans exactly the row of buttons under it */
  #acts { left: 50%; right: auto; transform: translateX(-50%); bottom: 14px; width: max-content; max-width: calc(100vw - 24px); align-items: stretch; }
  #acts .row { flex-wrap: nowrap; justify-content: center; gap: 8px; }
  #acts .row button, #acts .over button { padding: 7px 9px; font-size: 10px; white-space: nowrap; }
  #acts .over { display: flex; justify-content: flex-end; gap: 8px; }
  #acts .over[hidden] { display: none; }
  #act-sound .lbl { display: none; }
  #act-sound .ico { display: block; width: 16px; height: 16px; }
  #act-sound { padding: 5px 8px !important; }
  #act-all { width: 100%; }
  /* windows sit just above the buttons (however tall they are), and scroll rather than ever covering them */
  .win { max-height: calc(100dvh - var(--acts-h, 130px) - 40px); overflow-y: auto; }
  /* phones pinch to zoom (or double-tap in, two-finger tap out), so no zoom buttons */
  #zoom { display: none !important; }
  /* peace love joy on one line; subscribe and shop on the next */
  #ways-row { display: grid; grid-template-columns: auto auto; justify-content: end; align-items: center; gap: 3px 9px; margin-top: 2px; }
  #ways { display: contents; }
  #ways a { line-height: 1.15; }
  #ways .w1 { display: flex; gap: 9px; grid-column: 1 / 3; justify-self: end; }
  #ways .w2 { display: flex; gap: 9px; grid-row: 2; grid-column: 1 / 3; justify-self: end; }
  #ways a { letter-spacing: .07em; }
}

/* at night the buttons are filled black */
body[data-theme="night"] #acts button:not(:hover):not([aria-pressed="true"]),
body[data-theme="night"] #zoom button:not(:hover),
body[data-theme="night"] #name-form button,
body[data-theme="night"] #say-form button,
body[data-theme="night"] #sing-card .row button:not(#sing-yes) { background: #05060a; }

/* a little spinner on the zoom button while a closer map is on its way */
#zoom button { position: relative; }
#zoom button.loading::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px dashed currentColor; opacity: .55; animation: zoomwait 1.4s linear infinite; pointer-events: none; }
@keyframes zoomwait { to { transform: rotate(360deg); } }
