/* Tema Caderno do PADD: folha de caderno pautada (creme, linhas cinza,
   margem rosa) com letra à mão (Patrick Hand) em tudo. Sub-notas num
   post-it, links em "caneta azul" com marca-texto, histórico e tema em
   fichas pautadas. Fica ativo só com o tema "caderno" (ver theme.js) e
   SUBSTITUI o note.css inteiro. A pauta do editor é alinhada à linha de
   base do texto pelo note.js (--rule-y). */

@font-face { font-family: "Patrick Hand"; src: url(fonts/patrick-hand-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: light;
  --desk: #ded9cf;
  --paper: linear-gradient(90deg, #fdf9f2, #f1f1e2);
  --rule: #bdbdb2;
  --margin: #e0457b;
  --ink: #2b2f33;        /* caneta preta */
  --pen: #2453b3;        /* caneta azul */
  --red: #c62828;        /* caneta vermelha */
  --pencil: #6b6f74;     /* lápis */
  --marker: rgba(255, 230, 0, .55);  /* marca-texto */
  --postit: #fff3a6;
  --line: 34px;          /* altura da pauta */
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.lc-only, .tm-only { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--desk); }
html, body { margin: 0; height: 100%; }
body { background: var(--desk); color: var(--ink); font: 400 20px/1.4 var(--hand); }
::selection { background: var(--marker); color: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px dashed var(--pen); outline-offset: 2px; }

/* "Marca-texto": risco amarelo atrás da metade de baixo do texto. */
.pp-mark, .links a:hover, .links button:hover, #sidebar a:hover, .list-page #list a:hover .path, .panel-list button:hover {
  background-image: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 88%, transparent 88%);
}

/* ---- Página da nota: a mesa, a folha e o post-it -------------------------- */
body.note-page {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; justify-content: center; align-items: stretch; gap: 28px;
  padding: 22px 24px;
}

/* A folha */
#main-column {
  /* ocupa toda a largura que sobra ao lado do post-it */
  position: relative; flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08), 0 14px 34px rgba(60, 45, 20, .22);
  overflow: hidden;
}
/* margem rosa, de cima a baixo da folha */
#main-column::before {
  content: ""; position: absolute; z-index: 2; top: 0; bottom: 0; left: 64px;
  width: 2px; background: var(--margin); pointer-events: none;
}

/* topo da folha: título à esquerda, data à direita */
#pp-head {
  flex-shrink: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
  min-height: 96px; padding: 0 30px 8px 84px; border-bottom: 1px solid var(--rule);
}
#pp-head > div:first-child { min-width: 0; }
#pp-crumb { color: var(--pencil); font-size: 18px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pp-title { font-size: 36px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pp-date {
  flex-shrink: 0; font-size: 24px; line-height: 1.2; padding: 0 4px 1px;
  border-bottom: 1px dashed var(--pencil);
}

/* pauta: listras que rolam junto com o texto (background-attachment: local) */
#editor, #preview {
  flex: 1 1 auto; min-height: 0; width: 100%;
  padding: 6px 30px var(--line) 84px;
  font: 400 22px/var(--line) var(--hand); color: var(--ink);
  background:
    repeating-linear-gradient(180deg, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line))
    0 var(--rule-y, 0px) / 100% var(--line) local;
}
#editor {
  border: none; outline: none; resize: none; caret-color: var(--pen);
  scrollbar-width: thin; scrollbar-color: #c9c4b6 transparent;
}
#editor::placeholder { color: var(--pencil); opacity: .8; }

/* rodapé da folha: links em caneta azul, status a lápis */
#status-bar {
  flex-shrink: 0; position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 30px 12px 84px; border-top: 1px solid var(--rule);
}
#status { color: var(--pencil); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status[data-state="ok"]::after { content: " ✓"; color: #2e7d32; }
#status[data-state="offline"] { color: var(--red); }
.links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
#more-links { display: contents; }
#logout-form { display: inline; margin: 0; }
#more-toggle { display: none; }
.links a, .links button {
  border: none; background: none; padding: 0 2px; margin: 0; cursor: pointer;
  color: var(--pen); text-decoration: none; font: inherit; white-space: nowrap;
}
#logout-form button { color: var(--red); }

/* O post-it das sub-notas, colado com fita */
#sidebar {
  position: relative; flex: 0 0 230px; align-self: flex-start;
  margin-top: 70px; max-height: calc(100% - 120px); overflow-y: auto;
  padding: 22px 18px 20px; background: var(--postit);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .25), transparent 40%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06), 0 10px 20px rgba(60, 45, 20, .18);
  transform: rotate(-2deg); scrollbar-width: none;
}
#sidebar::before {
  content: ""; position: absolute; top: 4px; left: 50%; width: 92px; height: 22px;
  transform: translateX(-50%) rotate(3deg);
  background: rgba(255, 255, 255, .55); box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
#sidebar-title {
  margin: 6px 0 6px; font-size: 22px; color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
#sidebar-up { display: block; color: var(--pen); text-decoration: none; font-size: 0; margin-bottom: 4px; }
#sidebar-up::after { content: "← " attr(data-parent); font-size: 20px; }
#sidebar-list { list-style: none; margin: 0; padding: 0; }
#sidebar-list li { margin: 2px 0; }
#sidebar-list a { color: var(--pen); text-decoration: none; font-size: 20px; overflow-wrap: anywhere; }
#sidebar-list a::before { content: "– "; color: var(--ink); }
#sidebar-list a .slash { display: none; }

/* ---- Preview de Markdown, escrito na pauta -------------------------------- */
#preview { overflow-y: auto; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: #c9c4b6 transparent; }
#preview > * { margin: 0 0 var(--line); }
#preview > :last-child { margin-bottom: 0; }
#preview h1, #preview h2, #preview h3, #preview h4, #preview h5, #preview h6 {
  font-weight: 400; line-height: var(--line); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px;
}
#preview h1 { font-size: 30px; color: var(--red); }
#preview h2 { font-size: 27px; color: var(--pen); }
#preview h3, #preview h4, #preview h5, #preview h6 { font-size: 24px; }
#preview p, #preview li { line-height: var(--line); }
#preview ul, #preview ol { padding-left: 1.4em; }
#preview li::marker { color: var(--pen); }
#preview li:has(input[type="checkbox"]) { list-style: none; margin-left: -1.4em; }
#preview input[type="checkbox"] { accent-color: var(--pen); width: 16px; height: 16px; vertical-align: -1px; }
#preview a { color: var(--pen); }
#preview strong { background-image: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 88%, transparent 88%); font-weight: 400; }
#preview blockquote { padding-left: 14px; border-left: 3px solid var(--pen); color: var(--pencil); }
#preview code { font-family: ui-monospace, Menlo, monospace; font-size: .8em; color: var(--red); }
#preview pre { line-height: var(--line); overflow-x: auto; }
#preview pre code { color: var(--ink); overflow-wrap: normal; }
#preview img { max-width: 100%; height: auto; }
#preview hr { border: none; height: var(--line); margin: 0; background: linear-gradient(transparent 45%, var(--pencil) 45%, var(--pencil) 50%, transparent 50%) 0 0 / 40% 100% no-repeat; }
#preview table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
#preview th, #preview td { border: 1px solid var(--pencil); padding: 0 10px; line-height: calc(var(--line) - 1px); text-align: left; font-weight: 400; overflow-wrap: normal; }
#preview th { color: var(--pen); }

/* ---- Fichas pautadas (histórico, tema) ------------------------------------- */
.panel {
  position: fixed; inset: 0; z-index: 20; background: rgba(60, 45, 20, .25);
  align-items: center; justify-content: center; padding: 2rem;
}
.panel:not([hidden]) { display: flex; }
.panel-inner {
  width: min(540px, 100%); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
  background:
    repeating-linear-gradient(180deg, transparent 0 29px, #b9d1ec 29px 30px) 0 8px,
    #fffef8;
  border-radius: 3px; box-shadow: 0 16px 40px rgba(60, 45, 20, .3);
  transform: rotate(-1deg);
}
.panel-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 20px 4px; background: #fffef8; border-bottom: 2px solid #e57373;
}
.panel-header strong { font-weight: 400; font-size: 26px; }
.panel-header button { border: none; background: none; padding: 0; cursor: pointer; color: var(--pen); font: inherit; font-size: 20px; }
.panel-header button::after { content: " ✕"; }
.panel-list { overflow-y: auto; padding: 8px 20px 14px; }
.panel-list button {
  display: block; width: 100%; padding: 0; border: none; background: none; cursor: pointer;
  color: var(--ink); text-align: left; font: inherit; font-size: 20px; line-height: 30px; overflow-wrap: anywhere;
}
.panel-list small { color: var(--pencil); font-size: 17px; }
.panel-list button.current { color: var(--pen); }
.panel-list button.current::before { content: "✓ "; }

/* ---- Celular ------------------------------------------------------------------ */
@media (max-width: 640px) {
  :root { --line: 32px; }
  body.note-page { flex-direction: column; gap: 0; padding: 0; }
  #main-column { flex: 1 1 auto; min-height: 0; max-width: none; border-radius: 0; box-shadow: none; }
  #main-column::before { left: 40px; }
  #pp-head { min-height: 74px; padding: 0 14px 6px 54px; }
  #pp-title { font-size: 30px; }
  #pp-date { font-size: 20px; }
  #editor, #preview { padding: 4px 14px var(--line) 54px; font-size: 20px; }

  /* post-it vira uma faixa no topo */
  #sidebar {
    flex: 0 0 auto; align-self: stretch; transform: none; margin: 0; max-height: none;
    padding: 8px 14px; display: flex; align-items: center; gap: 14px; overflow-x: auto; overflow-y: hidden; white-space: nowrap;
    box-shadow: 0 2px 6px rgba(60, 45, 20, .15); z-index: 3;
  }
  #sidebar:not([hidden]) { display: flex; }
  #sidebar::before, #sidebar-title { display: none; }
  #sidebar-up { margin: 0; flex-shrink: 0; }
  #sidebar-list { display: flex; gap: 14px; }
  #sidebar-list li { margin: 0; flex-shrink: 0; }
  #sidebar-list a { overflow-wrap: normal; }

  /* rodapé: visualizar + "⋯"; o resto num post-it que abre por cima */
  #status-bar { padding: 6px 14px 10px 54px; }
  #status { font-size: 17px; }
  .links { flex-wrap: nowrap; gap: 14px; }
  #more-toggle { display: block; border: none; background: none; padding: 0 4px; color: var(--pen); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
  #more-links {
    display: none; position: absolute; right: 10px; bottom: calc(100% + 6px); z-index: 10;
    flex-direction: column; align-items: flex-start; gap: 6px; min-width: 12rem; padding: 18px 20px 16px;
    background: var(--postit); box-shadow: 0 10px 24px rgba(60, 45, 20, .25); transform: rotate(1deg);
  }
  #status-bar.menu-open #more-links { display: flex; }
  #more-links a, #more-links button { font-size: 21px; }
  #logout-form { display: block; }

  .panel { padding: 0; }
  .panel:not([hidden]) { align-items: flex-end; }
  .panel-inner { width: 100%; max-height: 85dvh; transform: none; border-radius: 6px 6px 0 0; }
}

/* ---- Login: uma folha com a senha escrita na linha ---------------------------- */
body.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-page .card {
  position: relative; width: min(440px, 100%); padding: 40px 30px 34px 84px;
  background:
    repeating-linear-gradient(180deg, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line)) 0 14px,
    var(--paper);
  box-shadow: 0 14px 34px rgba(60, 45, 20, .22); border-radius: 2px; transform: rotate(-.6deg);
}
.login-page .card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 64px; width: 2px; background: var(--margin); }
.login-page h1 { margin: 0 0 6px; font-weight: 400; font-size: 34px; line-height: calc(var(--line) * 2); }
.login-page input[type="password"] {
  display: block; width: 100%; margin: 0 0 var(--line); padding: 0;
  border: none; outline: none; background: none; color: var(--ink); caret-color: var(--pen);
  font: inherit; font-size: 24px; line-height: var(--line); height: var(--line);
}
.login-page input[type="password"]::placeholder { color: var(--pencil); }
/* botão "desenhado à mão": borda irregular com raios diferentes em cada canto */
.login-page button {
  padding: 2px 22px; border: 2px solid var(--pen); background: none; cursor: pointer;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  color: var(--pen); font: inherit; font-size: 22px;
}
.login-page button::after { content: " →"; }
.login-page button:hover { background-image: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 88%, transparent 88%); }
.login-page .error { margin: 0; color: var(--red); line-height: var(--line); }

/* ---- Lista de notas: uma folha com as notas, uma por linha ------------------- */
body.list-page { min-height: 100vh; min-height: 100dvh; padding: 22px 24px; }
.list-page > header, .list-page #list, .list-page #empty { position: relative; max-width: 940px; margin-inline: auto; }
.list-page > header {
  display: flex; align-items: flex-end; justify-content: space-between;
  min-height: 96px; padding: 0 30px 8px 84px; background: var(--paper);
  border-bottom: 1px solid var(--rule); border-radius: 2px 2px 0 0;
  box-shadow: 0 14px 34px rgba(60, 45, 20, .12);
}
.list-page h1 { margin: 0; font-weight: 400; font-size: 36px; }
.list-page a.new { color: var(--pen); text-decoration: none; font-size: 22px; }
.list-page a.new:hover { background-image: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 88%, transparent 88%); }
.list-page #list {
  list-style: none; margin-block: 0; padding: 0 0 var(--line); min-height: calc(100dvh - 140px);
  background: var(--paper); box-shadow: 0 14px 34px rgba(60, 45, 20, .22); border-radius: 0 0 2px 2px;
}
.list-page > header::before, .list-page #list::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 64px; width: 2px; background: var(--margin);
}
.list-page #list li { border-bottom: 1px solid var(--rule); }
.list-page #list a {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 0 30px 0 84px; line-height: calc(var(--line) - 1px); color: var(--ink); text-decoration: none;
}
.list-page #list .path { color: var(--pen); font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-page #list .meta { color: var(--pencil); font-size: 16px; white-space: nowrap; }
.list-page #empty { padding: 20px 30px 20px 84px; color: var(--pencil); }
@media (max-width: 640px) {
  body.list-page { padding: 0; }
  .list-page > header { padding: 0 14px 6px 54px; min-height: 74px; border-radius: 0; }
  .list-page > header::before, .list-page #list::before { left: 40px; }
  .list-page h1 { font-size: 30px; }
  .list-page #list { border-radius: 0; min-height: calc(100dvh - 74px); }
  .list-page #list a { flex-direction: column; gap: 0; padding: 0 14px 0 54px; line-height: 1.25; padding-block: 4px; }
  .list-page #list .meta { font-size: 14px; }
  .login-page .card { padding-left: 60px; }
  .login-page .card::before { left: 42px; }
}
