/* The page frame and the pieces shared by every page. */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17.5px/1.65 var(--sans);
  padding-left: max(clamp(22px, 6vw, 32px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(22px, 6vw, 32px), env(safe-area-inset-right, 0px));
  -webkit-font-smoothing: antialiased;
}

html,
body {
  transition: background-color 0.35s ease;
}

a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--cyan-ink);
}

:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 4px;
  border-radius: 6px;
}

/* the dot layers: faint background dots behind the page, and the full-window layer the dots fly on */
#amb {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.26s ease;
}

/* the dissolve's last frame fades out over the portrait it has just become */
#fx.fx-out {
  opacity: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.is-hero {
  height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  min-height: 420px;
}

/* the open page: Timeline, Journal, and the pages behind them */
.is-hero .panel {
  display: none;
}

.panel {
  padding-block: 44px calc(110px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 56px;
  animation: rise 0.8s 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.view-in .fade {
  animation: fadeOnly 0.7s 0.45s ease-out backwards;
}

@keyframes fadeOnly {
  from {
    opacity: 0;
  }
}

.timeline,
.journal,
.detail,
.note {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.detail,
.note {
  gap: 40px;
}

/* links that open a page: the arrow nudges on hover (the light through the words is in animations.css) */
.go {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.go svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--dim);
  transition: transform 0.2s, color 0.2s;
}

/* an icon before the words (the plus in "New article") moves right on hover, so it needs more room than the gap */
.go > svg:first-child {
  margin-right: 6px;
}

.go:hover svg,
.go:focus-visible svg {
  color: var(--cyan-ink);
  transform: translateX(3px);
}

/* the bar above a page: Back, and Edit for the owner */
.back {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 0;
  margin: 0;
  color: var(--dim);
  font: 500 14px/1 var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  transition: color 0.2s;
}

.back:hover {
  color: var(--cyan-ink);
}

.back svg {
  width: 15px;
  height: 15px;
}

.nbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
}

.nbar .back {
  align-self: center;
}

/* a page's heading: date, title, and where */
.dhead {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dhead .when {
  font-size: 13px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.dhead h2 {
  margin: 0;
  font: 300 clamp(30px, 4.6vw, 44px)/1.12 var(--sans);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.dhead .org {
  margin: 0;
  font-size: 16px;
  color: var(--ink-2);
}

/* drop-down menus in the site's own style (the Journal's topics, the editor's topic picker) */
.dd {
  position: relative;
  width: fit-content;
  z-index: 5;
}

.dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  appearance: none;
  margin: 0;
  background: var(--glass-bg);
  color: var(--ink);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  padding: 10px 16px 10px 18px;
  font: 500 14px/1.2 var(--sans);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-hi);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.dd-btn i {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s;
  opacity: 0.7;
}

.dd-btn[aria-expanded="true"] i {
  transform: translateY(1px) rotate(225deg);
}

.dd-btn:hover {
  border-color: var(--cyan-edge);
}

.dd-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 18px;
  background: var(--menu-bg);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 18px 40px -16px var(--glass-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  transform-origin: top left;
  animation: ddIn 0.18s ease-out;
  outline: none;
}

@keyframes ddIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
}

.dd-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}

.dd-list li:hover,
.dd-list li.act {
  background: var(--cyan-soft);
  color: var(--ink);
}

.dd-list li[aria-selected="true"] {
  color: var(--cyan-ink);
}

.dd-list li[aria-selected="true"]::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
}

/* pills: small round buttons (Edit, Upload, Remove) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  appearance: none;
  margin: 0;
  border: 1px solid var(--edge);
  background: none;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 14px;
  font: 500 13.5px/1 var(--sans);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.pill svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.pill:hover {
  color: var(--cyan-ink);
  border-color: var(--cyan-edge);
}

.pill.pri {
  border-color: var(--cyan-edge);
  background: var(--cyan-soft);
  color: var(--cyan-ink);
}

.pill.warn {
  color: var(--warn);
  border-color: var(--warn);
}

/* a short message above the dock */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 62px);
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--menu-bg);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 12px 30px -14px var(--glass-shadow);
  color: var(--ink-2);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

/* text only screen readers hear */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
