/* Day detail: a popover anchored to the cell on desktop, a bottom sheet on
   touch devices. Same markup, two presentations. */

.panel {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  max-height: min(60vh, 460px);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: panel-pop 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel[hidden] {
  display: none;
}

@keyframes panel-pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

.panel__grip {
  display: none;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel__date {
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.panel__meta {
  color: var(--text-faint);
  font-size: 12.5px;
}

.panel__meta .dot {
  margin: 0 6px;
  opacity: 0.5;
}

.panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.panel__chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
}

.chip__swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.panel__body {
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.65;
  display: grid;
  gap: 10px;
}

.panel__body:empty::before {
  content: attr(data-empty);
  color: var(--text-faint);
  font-size: 13px;
}

.entry {
  margin: 0;
}

/* The things that happened that day, one bullet each. */
.entry--lines {
  display: grid;
  gap: 7px;
  padding: 0;
  list-style: none;
}

.entry--lines li {
  position: relative;
  padding-left: 15px;
}

.entry--lines li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--entry-accent, var(--line-strong));
}

/* A stretch of days that covers this one — context, not today's news. */
.entry--span {
  padding-left: 12px;
  border-left: 2px solid var(--line);
  color: var(--text-dim);
  font-size: 13px;
}

.entry i,
.entry em {
  font-style: normal;
  color: var(--text-dim);
}

.entry mark {
  padding: 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--match) 35%, transparent);
  color: inherit;
}

.panel__nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.panel-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgb(8 8 14 / 42%);
  backdrop-filter: blur(2px);
  animation: fade-in 0.2s ease;
}

.panel-scrim[hidden] {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- sheet mode ---------- */

@media (pointer: coarse), (max-width: 700px) {
  .panel {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: min(72dvh, 620px);
    padding: 6px 18px calc(14px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes sheet-up {
    from {
      transform: translateY(102%);
    }
  }

  .panel__grip {
    display: block;
    width: 38px;
    height: 4px;
    margin: 6px auto 10px;
    border-radius: 99px;
    background: var(--line-strong);
  }

  .panel__date {
    font-size: 19px;
  }

  .panel__nav .ghost-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 14px;
  }
}

@media (hover: hover) and (min-width: 701px) {
  .panel-scrim {
    display: none;
  }
}

/* ---------- password dialog ---------- */

.dialog {
  width: min(380px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
  background: rgb(8 8 14 / 45%);
  backdrop-filter: blur(2px);
}

.dialog__form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.dialog__title {
  font-size: 16px;
  font-weight: 650;
}

.dialog__hint {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.55;
}

.dialog__hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
}

.dialog__input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.dialog__input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: var(--ring);
}

.dialog__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog__spacer {
  flex: 1;
}
