html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  line-height: 1.3;
  
  max-width: 90ch;
  margin-left: auto;
  margin-right: auto;
  
  height: 100dvh;
  
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
}

header {
  flex-grow: 0;
  flex-shrink: 0;
  
  padding: 1ex;
  
  font-size: 120%;
  font-weight: bold;
  
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

header > h1 {
  text-align: center;
  
  flex-grow: 1;
  flex-shrink: 0;
}

header > a.back {
  flex-grow: 0;
  flex-shrink: 0;
  
  text-decoration: none;
  color: inherit;
  
  aspect-ratio: 1/1;
  display: flex;
  justify-content: center;
  align-items: center;
  
  padding: 0.5ex;
  
  border-radius: 0.5ex;
  border-style: solid;
  border-color: #ddd;
  border-width: 1px;
}

header > a.back > span {
  line-height: 1;
}

.memory-form {
  --gap: 1ex;
  --fade: 2em;
  
  display: flex;
  flex-direction: row;
  
  gap: var(--gap);
}

.memory-form input[name="date"] {
  flex-grow: 0;
  flex-shrink: 0;
}
.memory-form input[name="note"] {
  flex-grow: 1;
  flex-shrink: 1;
}
.memory-form input[type="submit"],
.memory-form input[type="reset"] {
  flex-grow: 0;
  flex-shrink: 0;
}


/****************************************************************************** 
 * Name list (index) specific styles
 ******************************************************************************/

ul.name-list {
  list-style: none;
  padding: 0;
  margin: 0;
  
  font-size: 130%;
  
  display: flex;
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  
  gap: 1em;
  margin-top: calc(1em - 1ex);
}

ul.name-list li a {
  display: block;
  
  text-decoration: none;
  
  color: black;
  
  border-color: #aaa;
  border-width: 1px;
  border-style: solid;
  
  padding: 1ex;
  padding-left: 0.75em;
  padding-right: 0.75em;
  
  border-radius: 0.5ex;
}

ul.name-list li.new {
  flex-basis: 100%;
}

ul.name-list li.new a {
  border-style: none;
  
  padding: 0;
  
  color: #777;
  
  font-size: 1rem;
  text-align: center;
}

/****************************************************************************** 
 * Memory list specific styles
 ******************************************************************************/

div.memories {
  flex-grow: 1;
  flex-shrink: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
}

.memory-list {
  --timeline-thickness: 3px;
  --timeline-spacing: 1.5ex;
  --timeline-color: #aaa;
  --timeline-heading-spacing: 2em;
  --timeline-item-spacing: 1ex;
  
  border-left-color: var(--timeline-color);
  border-left-width: var(--timeline-thickness);
  border-left-style: solid;
  
  margin-left: var(--timeline-spacing);
  margin-right: 1ex;
  
  padding-bottom: var(--timeline-heading-spacing);
  
  position: relative;
}

.memory-list::after {
  /* Fade-out timeline at end */
  content: "";
  
  display: block;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.0),
    rgba(255,255,255,1.0)
  );
  
  position: absolute;
  
  left: calc(-1.5 * var(--timeline-thickness));
  bottom: 0;
  
  height: var(--timeline-heading-spacing);
  width: calc(2 * var(--timeline-thickness));;
}

.memory-list h2 {
  position: sticky;
  top: 0;
  z-index: 999;
  
  font-weight: bold;
  font-variant: small-caps;
  
  --top-padding: 1em;
  --bottom-fade: 2em;
  padding-top: var(--top-padding);
  padding-bottom: var(--bottom-fade);
  padding-left: var(--timeline-spacing);
  
  color: #444;
  
  pointer-events: none; 
  
  background: linear-gradient(
    to top,
    rgba(255,255,255,0.0),
    rgba(255,255,255,1.0) var(--bottom-fade)
  );
}

.memory-list h2::before {
  position: absolute;
  
  content: "";
  
  box-sizing: border-box;
  
  --size: 1em;
  width: var(--size);
  height: var(--size);
  border-radius: calc(0.5 * var(--size));
  
  border-width: var(--timeline-thickness);
  border-style: solid;
  border-color: var(--timeline-color);
  
  left: calc(-0.5 * var(--size) - var(--timeline-thickness));
  top: calc((1em - var(--size)) * 0.5 + var(--top-padding));
  
  background-color: #FFF;
}

.memory-list div:first-child h2 {
  --top-padding: 0;
}

.memory-list div:not(:first-child) {
  padding-top: var(--timeline-heading-spacing);
}

.memory-list ul li {
  position: relative;
  padding-left: var(--timeline-spacing);
}

.memory-list ul li:not(:last-child) {
  padding-bottom: var(--timeline-item-spacing);
}

.memory-list ul li::before {
  position: absolute;
  
  content: "";
  
  box-sizing: border-box;
  
  width: 0.5ex;
  height: var(--timeline-thickness);
  
  left: 0;
  top: 0.4em;
  
  background-color: var(--timeline-color);
}

.memory-list ul li a {
  text-decoration: none;
  color: inherit;
}

#new-memory {
  flex-grow: 0;
  flex-shrink: 0;
  
  padding: 1ex;
}


/****************************************************************************** 
 * Memory editor specific styles
 ******************************************************************************/

.edit-memory > .edit {
  flex-grow: 1;
  flex-shrink: 0;
}

.edit-memory > .delete
.edit-memory > .cancel {
  flex-grow: 0;
  flex-shrink: 0;
}
