@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;700&display=swap");

:root {
  --light-surface: rgb(158, 157, 162);
  --light-ink: #11110f;
  --dark-surface: #11110f;
  --dark-ink: #f1eee6;
  --dark: rgb(158, 157, 162);
  --white: #f1eee6;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr);
  min-height: 100dvh;
  --dark: var(--light-surface);
  --white: var(--light-ink);
  background: var(--dark);
  color: var(--white);
  font-family: "Space Grotesk", "Arial Narrow", "Nimbus Sans Narrow", sans-serif;
  font-size: 15px;
  transition: grid-template-columns 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-theme="dark"] {
  --dark: var(--dark-surface);
  --white: var(--dark-ink);
}

body.modal-open {
  overflow: hidden;
}

body.panel-collapsed {
  grid-template-columns: 48px minmax(0, 1fr);
}

aside {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 18px;
  min-width: 0;
  border-right: 2px solid var(--white);
  padding: 16px;
  overflow: auto;
  transition: gap 220ms cubic-bezier(0.16, 1, 0.3, 1), padding 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.brand {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--white);
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: max-content;
}

body:not(.panel-collapsed) #new-note-toggle {
  display: none;
}

.brand-home {
  display: grid;
  justify-items: start;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  text-align: left;
  transform: translateX(0);
  opacity: 1;
  transition: opacity 170ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.brand-home:hover,
.brand-home:focus {
  background: transparent;
  color: var(--white);
  transform: translateY(-1px);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.9;
  text-transform: uppercase;
}

.brand p,
.empty-copy p,
.eyebrow {
  margin: 0;
  font-family: "Space Grotesk", "Arial Narrow", "Nimbus Sans Narrow", sans-serif;
  line-height: 1.25;
  text-transform: lowercase;
}

.icon-button,
.menu-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--white);
  transition: color 160ms ease, transform 160ms ease;
}

.icon-button {
  font-size: 24px;
  line-height: 1;
}

.menu-toggle {
  align-content: center;
  gap: 4px;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--white);
  transition: transform 160ms ease, background-color 160ms ease;
}

.icon-button:hover,
.icon-button:focus,
.menu-toggle:hover,
.menu-toggle:focus {
  background: transparent;
  color: var(--white);
  transform: translateY(-1px);
}

.icon-button:focus,
.menu-toggle:focus {
  outline: 0;
}

.icon-button:focus::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 3px;
  left: 7px;
  height: 2px;
  background: var(--white);
}

.menu-toggle:hover span,
.menu-toggle:focus span {
  background: var(--white);
}

.panel-collapsed aside {
  gap: 0;
  padding: 6px;
  overflow: hidden;
}

.panel-collapsed .brand {
  grid-template-columns: 1fr;
  justify-items: start;
  gap: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.panel-collapsed .brand-actions {
  display: grid;
  gap: 2px;
}

.panel-collapsed .brand-home {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-12px);
}

.panel-collapsed #notes-list {
  pointer-events: none;
  opacity: 0;
  transform: translateX(-12px);
}

form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-self: start;
}

#new-note-form {
  grid-row: 2;
  width: min(100%, 220px);
  gap: 7px;
  margin-top: -4px;
  padding: 10px 0 12px;
  border-bottom: 2px solid var(--white);
  animation: rise-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

#new-note-form label {
  font-family: "Space Grotesk", "Arial Narrow", "Nimbus Sans Narrow", sans-serif;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
}

#new-note-form button {
  justify-self: start;
  min-width: 92px;
}

input,
button,
textarea {
  min-width: 0;
  border: 2px solid var(--white);
  background: var(--dark);
  color: var(--white);
  font: inherit;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

input,
button {
  min-height: 40px;
  padding: 7px 9px;
}

button {
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button.active,
button:focus,
input:focus {
  background: var(--white);
  color: var(--dark);
  outline: 0;
}

button:active,
.icon-button:active,
.menu-toggle:active {
  transform: translateY(1px);
}

textarea:focus {
  outline: 0;
}

#notes-list {
  grid-row: 3;
  display: grid;
  align-content: start;
  gap: 0;
  border-top: 2px solid var(--white);
  transform: translateX(0);
  opacity: 1;
  transition: opacity 170ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

#notes-list button,
#notes-list .tree-row button {
  border: 0;
  background: transparent;
  color: var(--white);
}

#notes-list:empty {
  border-top: 0;
}

.root-row,
.tree-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  border-bottom: 2px solid var(--white);
}

.root-row {
  grid-template-columns: minmax(0, 1fr) 28px;
  text-align: left;
}

.tree-row {
  position: relative;
  padding-left: calc(var(--depth) * 14px);
}

.tree-main,
.tree-delete,
.tree-toggle {
  min-height: 32px;
  padding: 4px 6px;
}

.tree-toggle {
  display: grid;
  place-items: center;
  text-align: center;
}

.tree-toggle:disabled {
  cursor: default;
}

.tree-main {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
}

.tree-delete {
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", "Arial Narrow", "Nimbus Sans Narrow", sans-serif;
}

.tree-delete {
  text-transform: lowercase;
}

.child-row::before,
.child-row::after {
  content: "";
  position: absolute;
  background: var(--white);
  pointer-events: none;
}

.child-row::before {
  top: 0;
  bottom: 16px;
  left: calc((var(--depth) * 14px) + 11px);
  width: 2px;
}

.child-row::after {
  top: 16px;
  left: calc((var(--depth) * 14px) + 11px);
  width: 11px;
  height: 2px;
}

.root-row:hover,
.root-row:focus,
.tree-row:hover,
.tree-row:focus-within,
.tree-row.active,
.root-row.active {
  background: var(--white);
  color: var(--dark);
}

#notes-list .tree-row:hover button,
#notes-list .tree-row:focus-within button,
#notes-list .tree-row.active button,
#notes-list .root-row:hover button,
#notes-list .root-row:focus button,
#notes-list .root-row.active button {
  color: var(--dark);
}

.note-context {
  position: fixed;
  z-index: 2;
  width: 150px;
  border: 2px solid var(--white);
  background: var(--dark);
}

.note-context button {
  width: 100%;
  border: 0;
  text-align: left;
}

.panel-footer {
  grid-row: 4;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding-top: 16px;
}

.panel-collapsed .panel-footer {
  display: grid;
  justify-items: start;
  align-content: end;
}

.panel-collapsed .panel-icon-button,
.panel-collapsed .theme-toggle {
  width: 36px;
  min-height: 36px;
}

.panel-icon-button,
.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
}

.panel-icon-button:hover,
.panel-icon-button:focus,
.theme-toggle:hover,
.theme-toggle:focus {
  background: transparent;
  color: var(--white);
}

.theme-toggle img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.help-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: transparent;
}

.help-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--dark);
  opacity: 0.18;
}

.help-modal {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  min-height: min(320px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 2px solid var(--white);
  background: var(--dark);
}

.help-close {
  position: sticky;
  top: 0;
  z-index: 1;
  display: block;
  margin-left: auto;
  min-width: 40px;
  border-width: 0 0 2px 2px;
  text-transform: lowercase;
}

.help-content {
  display: grid;
  gap: 16px;
  padding: 0 24px 24px;
}

.help-content h2,
.help-content h3,
.help-content p,
.help-content ul {
  margin: 0;
}

.help-content h2 {
  font-size: 22px;
  line-height: 1;
}

.help-section {
  display: grid;
  gap: 8px;
}

.help-content h3 {
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.1;
  text-transform: uppercase;
}

.help-content p,
.help-content li {
  line-height: 1.35;
}

.help-content ul {
  display: grid;
  gap: 6px;
  padding-left: 18px;
}

.help-content a {
  color: var(--white);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

main {
  min-width: 0;
  min-height: 0;
}

.editor {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  animation: rise-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

[hidden] {
  display: none !important;
}

.editor-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

#note-name {
  border-width: 0 0 2px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

#export-note {
  border-width: 0 0 2px 2px;
  min-width: 104px;
  white-space: nowrap;
}

#note-body {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.5;
}

.empty-state {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: 100dvh;
  padding: 40px;
  background-image: url("assets/ascii-art.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--white);
}

.empty-state::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--dark);
  opacity: 0.34;
}

.empty-copy {
  display: grid;
  align-content: center;
  justify-self: start;
  gap: 18px;
  max-width: min(100%, 560px);
  min-width: 0;
  text-shadow: 0 1px 2px var(--dark);
  animation: rise-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.eyebrow {
  text-transform: uppercase;
}

.empty-copy h2 {
  margin: 0;
  max-width: 8ch;
  font-size: 96px;
  font-weight: 700;
  font-family: "Space Grotesk", "Arial Narrow", "Nimbus Sans Narrow", sans-serif;
  letter-spacing: 0;
  line-height: 0.78;
  text-transform: uppercase;
}

.empty-copy button {
  width: fit-content;
  min-width: 150px;
  margin-top: 8px;
  border-color: var(--white);
  background: transparent;
  color: var(--white);
}

.empty-copy button:hover,
.empty-copy button:focus {
  background: var(--white);
  color: var(--dark);
}

:disabled {
  cursor: default;
  opacity: 1;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 700px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr);
  }

  body.panel-collapsed {
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-rows: minmax(420px, 1fr);
  }

  aside {
    border-right: 0;
    border-bottom: 2px solid var(--white);
    max-height: 46dvh;
  }

  .panel-collapsed aside {
    max-height: none;
    min-height: 100dvh;
    padding: 6px;
    border-right: 2px solid var(--white);
    border-bottom: 0;
  }

  .panel-collapsed .brand {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .editor {
    min-height: 54dvh;
  }

  .empty-state {
    min-height: 54dvh;
    padding: 24px 16px;
  }

  .empty-copy {
    max-width: 100%;
  }

  .empty-copy h2 {
    font-size: 72px;
  }
}

@media (max-width: 900px) {
  .empty-copy h2 {
    font-size: 72px;
  }
}

@media (max-width: 420px) {
  .editor-bar {
    grid-template-columns: 1fr;
  }

  #export-note {
    border-width: 0 0 2px;
  }

  #note-name {
    font-size: 16px;
  }

  .empty-copy h2 {
    font-size: 40px;
  }
}
