/* The calendar loader: the week view of an invented calendar app, Halden, on a soft warm page.
   .wrap is moved by GSAP, .win (the white window) is styled here. Each event (.ev) is first a grey slab of the
   skeleton and then the event itself: GSAP moves it with top and height, its colour layer (.ev__bg), its edge
   (.ev__bar) and its words (.ev__t, .ev__h) come in on top. The hour lines and the now line are SVG drawn in pixels. */
:root {
  --page: #f2f0eb;          /* the page */
  --win: #ffffff;           /* the window */
  --ink: #17181f;           /* titles and figures */
  --muted: #8a8b94;         /* small words */
  --line: #ebe9e4;          /* the hour lines */
  --bone: #eeece7;          /* the skeleton slabs */
  --bone-light: #fbfaf7;    /* the light crossing them */
  --accent: #4b55d6;        /* the events, today and the status: indigo */
  --warm: #e2603c;          /* focus time and the now line: coral */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vh, 20px) clamp(8px, 3vw, 20px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(255, 255, 255, 0.9), transparent 70%),
    radial-gradient(40% 30% at 72% 80%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--page);
}

/* a fine grain, so the page is never flat */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(100%, 640px);
  opacity: 0;
}

.win {
  --gut: 40px;
  position: relative;
  border-radius: 18px;
  padding: clamp(9px, 2.2vh, 16px) clamp(9px, 2.6vw, 16px) clamp(8px, 1.8vh, 13px);
  background: var(--win);
  box-shadow:
    inset 0 1px 0 #fff,
    0 0 0 1px rgba(23, 24, 31, 0.06),
    0 1px 2px rgba(23, 24, 31, 0.05),
    0 8px 18px -8px rgba(23, 24, 31, 0.12),
    0 34px 60px -28px rgba(40, 42, 90, 0.28);
}

.win--narrow {
  --gut: 28px;
}

/* a sheen that crosses the glass once, when the week is synced */
.win__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

.win__sheen-band {
  position: absolute;
  top: -20%;
  left: 0;
  width: 34%;
  height: 140%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.75) 50%, transparent);
  mix-blend-mode: soft-light;
  opacity: 0;
}

/* ------------------------------------------------------------ the bar */
.bar {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 14px);
  height: clamp(26px, 5vh, 32px);
  margin-bottom: clamp(6px, 1.6vh, 12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.brand__mark {
  width: 18px;
  height: 18px;
  fill: var(--accent);
}

.brand__mark-cut {
  stroke: #fff;
  stroke-width: 1.4;
  opacity: 0.9;
}

.brand__mark-ring {
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.brand__name {
  font-size: 13.5px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}

.bar__title {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding-left: clamp(8px, 2vw, 14px);
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.bar__month {
  font-size: 13px;
  font-weight: 560;
}

.bar__week {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 460;
}

.bar__right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 7px;
  border-radius: 99px;
  background: #f6f5f2;
  box-shadow: inset 0 0 0 1px rgba(23, 24, 31, 0.06);
  font-size: 11.5px;
  font-weight: 520;
  white-space: nowrap;
}

.status__icon {
  width: 16px;
  height: 16px;
  overflow: visible;
}

.status__track {
  fill: none;
  stroke: rgba(75, 85, 214, 0.16);
  stroke-width: 1.6;
}

.status__arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 0.28 0.72;
  transform: rotate(-90deg);
  transform-origin: 8px 8px;
}

.status__check {
  fill: none;
  stroke: #fff;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.status__words {
  position: relative;
  display: inline-grid;
}

.status__w {
  grid-area: 1 / 1;
}

.status__w b {
  font-weight: 640;
}

.status__w i {
  font-style: normal;
  color: var(--muted);
}

.status__w--done {
  opacity: 0;
  color: inherit;
}

.bar__btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.bar__btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .bar__btn:hover {
    background: #f3f2ee;
    color: var(--ink);
  }
}

/* ------------------------------------------------------------ the week */
.heads {
  display: grid;
  grid-template-columns: var(--gut) repeat(var(--n, 5), 1fr);
  height: clamp(28px, 6vh, 40px);
  border-bottom: 1px solid var(--line);
}

.head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.head__sk {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54%;
  max-width: 54px;
  height: 9px;
  margin: -4.5px 0 0 0;
  transform: translateX(-50%);
  border-radius: 5px;
  background: var(--bone);
  overflow: hidden;
}

.head__in {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.head__d {
  font-size: 11px;
  color: var(--muted);
  font-weight: 480;
  letter-spacing: 0.01em;
}

.head__n {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
}

.head--today .head__n {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.head--today .head__d {
  color: var(--accent);
}

.body {
  position: relative;
  display: grid;
  grid-template-columns: var(--gut) 1fr;
  height: clamp(168px, 47vh, 330px);
}

.gutter {
  position: relative;
}

.hour {
  position: absolute;
  right: 7px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 460;
  transform: translateY(-50%);
  white-space: nowrap;
}

.grid {
  position: relative;
}

.lines,
.now {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.lines line {
  stroke: var(--line);
  stroke-width: 1;
}

.lines .half {
  stroke-dasharray: 2 3;
  opacity: 0.8;
}

/* today keeps a faint indigo wash */
.today-wash {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), color-mix(in srgb, var(--accent) 2%, transparent));
  opacity: 0;
}

.cols {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n, 5), 1fr);
}

.col {
  position: relative;
}

/* ------------------------------------------------------------ an event: a slab first, then itself */
.ev {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 7px;
  background: var(--bone);
  overflow: hidden;
  cursor: default;
  will-change: top, height;
}

.ev__sh {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--bone-light) 50%, transparent 80%);
  transform: translateX(-110%);
}

.ev__bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 13%, #fff), color-mix(in srgb, var(--c) 9%, #fff));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 16%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border-radius: inherit;
  opacity: 0;
}

.ev__bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c);
  transform-origin: 50% 0;
  transform: scaleY(0);
}

.ev__in {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 5px 0 8px;
  min-width: 0;
}

.ev__t {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  color: color-mix(in srgb, var(--c) 72%, var(--ink));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
}

.ev__h {
  font-size: 9.5px;
  font-weight: 470;
  color: color-mix(in srgb, var(--c) 52%, var(--muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
}

.ev--short .ev__in {
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  padding-top: 3px;
}

.ev--tight .ev__in {
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  padding-top: 3px;
}

.ev--tight:not(.ev--short) .ev__h {
  display: none;
}

.ev--warm {
  --c: var(--warm);
}

.ev--warm .ev__bg {
  background:
    repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--c) 7%, transparent) 5px 6px),
    linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, #fff), color-mix(in srgb, var(--c) 8%, #fff));
}

/* the lift: GSAP moves .ev__lift, the event box keeps its top and height */
.ev__lift {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.ev.is-ready {
  cursor: pointer;
  overflow: visible;
  background: transparent;
}

.ev.is-ready .ev__lift {
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.35s;
}

.ev.is-ready .ev__sh {
  display: none;
}

@media (hover: hover) {
  .ev.is-ready:hover .ev__lift {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--c) 55%, transparent);
  }
}

.ev.is-hot .ev__lift {
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--c) 70%, transparent), 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent);
}

/* ------------------------------------------------------------ the now line */
.now__week {
  stroke: color-mix(in srgb, var(--warm) 40%, transparent);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.now__day {
  stroke: var(--warm);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.now__tick {
  fill: var(--warm);
}

.now__pill {
  position: absolute;
  left: calc(var(--gut) * -1 - 2px);
  width: calc(var(--gut) + 2px);
  display: grid;
  justify-items: end;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0;
}

.now__pill span {
  padding: 1px 4px;
  border-radius: 5px;
  background: var(--warm);
  color: #fff;
  font-size: 9.5px;
  font-weight: 620;
  box-shadow: 0 3px 8px -3px color-mix(in srgb, var(--warm) 70%, transparent);
}

/* ------------------------------------------------------------ the event card the pointer opens */
.pop {
  position: absolute;
  z-index: 5;
  width: 164px;
  display: grid;
  gap: 3px;
  padding: 10px 11px 10px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 #fff,
    0 0 0 1px rgba(23, 24, 31, 0.07),
    0 2px 4px rgba(23, 24, 31, 0.05),
    0 18px 34px -14px rgba(30, 34, 90, 0.35);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.pop__edge {
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.pop__title {
  font-size: 12.5px;
  font-weight: 640;
}

.pop__when,
.pop__where {
  font-size: 10.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pop__where svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

.pop__people {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

.pop__av {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: -3px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 640;
  color: hsl(var(--h) 45% 32%);
  background: hsl(var(--h) 60% 90%);
  box-shadow: 0 0 0 1.5px #fff;
}

.pop__more {
  margin-left: 9px;
  font-size: 10px;
  color: var(--muted);
}

.pop__join {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 8px -4px rgba(23, 24, 31, 0.5);
}

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  width: 18px;
  height: 18px;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(23, 24, 31, 0.3));
}

.cursor path {
  fill: var(--ink);
  stroke: #fff;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------ the totals */
.foot {
  display: flex;
  gap: clamp(10px, 3vw, 20px);
  align-items: center;
  height: clamp(22px, 4.4vh, 30px);
  margin-top: clamp(4px, 1vh, 8px);
  padding-top: clamp(4px, 1vh, 8px);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.foot__item b {
  color: var(--ink);
  font-weight: 620;
  margin-right: 2px;
}

.foot__item--warm b {
  color: var(--warm);
}

.win--narrow .bar__week,
.win--narrow .brand__name {
  display: none;
}

@media (max-height: 360px) {
  .foot {
    display: none;
  }
}
