/* ============ Home notes paper board ============ */
.home-notes-board-section {
  position: relative;
  padding: 20px 0 14px;
  overflow: hidden;
  background: transparent;
}

.home-notes-board-section + .home-projects-section {
  padding-top: 28px;
  border-top: 0;
}

.home-notes-board-head {
  display: flex;
  justify-content: flex-end;
  min-height: 16px;
  margin-bottom: 2px;
}

.home-notes-board-more {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s ease;
}

.home-notes-board-more:hover,
.home-notes-board-more:focus-visible { color: var(--blue-light); }

.home-notes-board-more:focus-visible,
.home-note-paper:focus-visible {
  outline: 2px solid var(--blue-light);
  outline-offset: 3px;
}

.home-notes-board {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 12px 14px 22px;
  isolation: isolate;
}

.home-note-paper {
  --paper: #382d21;
  --paper-border: rgba(255, 211, 148, .13);
  --paper-ink: #f4e9d8;
  --paper-muted: #ad9b83;
  position: relative;
  min-width: 0;
  min-height: 152px;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  padding: 29px 22px 17px;
  border: 1px solid var(--paper-border);
  border-radius: 1px;
  background: var(--paper);
  box-shadow: 0 13px 24px rgba(0, 0, 0, .16), 0 2px 5px rgba(0, 0, 0, .1);
  color: var(--paper-ink);
  text-decoration: none;
  transform-origin: 50% 0;
  transition: transform .22s cubic-bezier(.2, .72, .24, 1), opacity .16s ease, box-shadow .22s ease, border-color .2s ease;
}

.home-note-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(255, 255, 255, .045);
  pointer-events: none;
}

.home-note-paper::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 17px 17px 0 0;
  border-color: rgba(255, 255, 255, .1) transparent transparent transparent;
}

.home-note-paper--1 {
  flex-grow: 1.08;
  margin-top: 14px;
  transform: translateX(5px) rotate(-.9deg);
}

.home-note-paper--2 {
  --paper: #343024;
  flex-grow: .92;
  transform: translateX(-4px) rotate(-.3deg);
}

.home-note-paper--3 {
  --paper: #372827;
  flex-grow: 1;
  margin-top: 20px;
  transform: translateX(4px) rotate(-1.35deg);
}

.home-note-paper:focus-visible {
  z-index: 4;
  border-color: rgba(224, 111, 42, .38);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .22), 0 4px 8px rgba(0, 0, 0, .12);
}

.home-note-paper--1:focus-visible { transform: translate(5px, 7px) rotate(-.18deg) scale(1.008); }
.home-note-paper--2:focus-visible { transform: translate(-4px, -7px) rotate(-.05deg) scale(1.008); }
.home-note-paper--3:focus-visible { transform: translate(4px, 12px) rotate(-.22deg) scale(1.008); }

@media (hover: hover) and (pointer: fine) {
  .home-note-paper:hover {
    z-index: 4;
    border-color: rgba(224, 111, 42, .38);
    box-shadow: 0 18px 34px rgba(0, 0, 0, .22), 0 4px 8px rgba(0, 0, 0, .12);
  }
  .home-note-paper--1:hover { transform: translate(5px, 7px) rotate(-.18deg) scale(1.008); }
  .home-note-paper--2:hover { transform: translate(-4px, -7px) rotate(-.05deg) scale(1.008); }
  .home-note-paper--3:hover { transform: translate(4px, 12px) rotate(-.22deg) scale(1.008); }
}

.home-note-paper.is-peeling {
  z-index: 5;
  opacity: .42;
  pointer-events: none;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .08);
  transition-duration: .15s;
}

.home-note-paper--1.is-peeling { transform: translate(7px, 1px) rotate(-2deg) scale(.982); }
.home-note-paper--2.is-peeling { transform: translate(-2px, -12px) rotate(-1.4deg) scale(.982); }
.home-note-paper--3.is-peeling { transform: translate(6px, 5px) rotate(-2.35deg) scale(.982); }

.home-note-paper.is-peeling .home-note-paper-tape {
  opacity: .18;
  transform: translate(-50%, -3px) rotate(-1.8deg) scaleX(.92);
}

.home-note-paper-tape {
  position: absolute;
  z-index: 2;
  top: -7px;
  left: 50%;
  width: 76px;
  height: 15px;
  border: 1px solid rgba(255, 207, 149, .1);
  background: rgba(224, 111, 42, .31);
  clip-path: polygon(3% 7%, 97% 0, 100% 88%, 2% 100%);
  transform: translateX(-50%) rotate(-.7deg);
  transition: opacity .15s ease, transform .15s ease;
}

.home-note-paper-label {
  display: block;
  margin-bottom: 11px;
  color: rgba(224, 138, 80, .88);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.home-note-paper-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--paper-ink);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.home-note-paper-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  color: var(--paper-muted);
  font-family: var(--mono);
  font-size: 10px;
}

.home-note-paper-foot > span {
  color: rgba(224, 138, 80, .9);
  font-size: 13px;
}

html[data-theme="light"] .home-note-paper {
  --paper: #f4dda9;
  --paper-border: rgba(117, 75, 35, .14);
  --paper-ink: #493725;
  --paper-muted: #8d7257;
  box-shadow: 0 13px 24px rgba(89, 52, 20, .1), 0 2px 5px rgba(89, 52, 20, .06);
}

html[data-theme="light"] .home-note-paper--2 { --paper: #eee0b9; }
html[data-theme="light"] .home-note-paper--3 { --paper: #edd5c4; }
html[data-theme="light"] .home-note-paper::before { border-top-color: rgba(255, 255, 255, .28); }
html[data-theme="light"] .home-note-paper::after { border-color: rgba(111, 74, 41, .13) transparent transparent transparent; }

@media (prefers-reduced-motion: reduce) {
  .home-note-paper,
  .home-note-paper-tape { transition: none; }
}

@media (max-width: 600px) {
  .home-notes-board-section { padding: 16px 0 10px; }
  .home-notes-board-section + .home-projects-section { padding-top: 20px; }
  .home-notes-board-head { margin-bottom: 5px; }
  .home-notes-board-more { font-size: 10px; }
  .home-notes-board {
    width: calc(100% + 24px);
    gap: 14px;
    padding: 12px 24px 20px 3px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    scrollbar-width: none;
  }
  .home-notes-board::-webkit-scrollbar { display: none; }
  .home-note-paper {
    flex: 0 0 min(76vw, 286px);
    min-height: 134px;
    padding: 26px 17px 15px;
    scroll-snap-align: start;
  }
  .home-note-paper--1 { margin-top: 8px; transform: rotate(-.7deg); }
  .home-note-paper--2 { transform: rotate(-.25deg); }
  .home-note-paper--3 { margin-top: 12px; transform: rotate(-1deg); }
  .home-note-paper-label { margin-bottom: 8px; }
  .home-note-paper-text { -webkit-line-clamp: 2; font-size: 13px; }
  .home-note-paper-foot { padding-top: 10px; font-size: 9px; }
}

/* ============ Blog notes ============ */
.notes-card {
  padding: 18px;
  scroll-margin-top: 96px;
}

.notes-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notes-card-head h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

.notes-card-kicker {
  display: block;
  color: var(--blue-light);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.notes-compose-toggle {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease, transform .2s ease;
}

.notes-compose-toggle:hover,
.notes-compose-toggle:focus-visible,
.notes-compose-toggle[aria-expanded="true"] {
  color: var(--blue-light);
  border-color: rgba(224, 111, 42, .42);
  background: rgba(224, 111, 42, .1);
}

.notes-compose-toggle[aria-expanded="true"] svg { transform: rotate(45deg); }
.notes-compose-toggle svg { transition: transform .2s ease; }
.notes-compose-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.notes-notice {
  margin: 10px 0 0 !important;
  padding: 8px 10px;
  border: 1px solid rgba(224, 111, 42, .22);
  border-radius: 6px;
  background: rgba(224, 111, 42, .08);
  color: var(--blue-light) !important;
  font-size: 12px !important;
  line-height: 1.45 !important;
}

.notes-notice--error {
  border-color: rgba(239, 112, 108, .28);
  background: rgba(239, 112, 108, .08);
  color: #ef8f89 !important;
}

.notes-compose {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.notes-compose[hidden] { display: none; }

.notes-compose > label {
  display: grid;
  gap: 5px;
}

.notes-compose > label > span {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
}

.notes-compose textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, .025);
  color: var(--text);
  font: 12px/1.55 var(--font);
}

.notes-compose textarea:focus {
  outline: none;
  border-color: rgba(224, 111, 42, .55);
  box-shadow: 0 0 0 2px rgba(224, 111, 42, .1);
}

.notes-compose-options {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.notes-compose-options label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.notes-compose-options input {
  accent-color: var(--blue);
}

.notes-compose-options button {
  min-height: 30px;
  margin-left: auto;
  padding: 0 11px;
  border: 1px solid rgba(224, 111, 42, .3);
  border-radius: 6px;
  background: rgba(224, 111, 42, .13);
  color: var(--blue-light);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.notes-list {
  display: grid;
  margin-top: 10px;
}

.note-item {
  min-width: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
}

.note-item:first-child { padding-top: 5px; }

.note-item-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  color: var(--body);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.note-item-text:hover { color: var(--heading); }

.note-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
}

.note-item-meta > a:first-child {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  color: inherit;
}

.note-item-edit {
  flex: 0 0 auto;
  color: var(--blue-light);
}

.notes-empty {
  margin-top: 12px !important;
  color: var(--muted-2) !important;
  font-size: 12px !important;
}

.notes-load-more {
  width: 100%;
  min-height: 30px;
  margin-top: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: rgba(224, 111, 42, .07);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.notes-load-more:hover,
.notes-load-more:focus-visible {
  background: rgba(224, 111, 42, .13);
  color: var(--blue-light);
}

.notes-load-more:disabled { cursor: wait; opacity: .65; }

html[data-theme="light"] .notes-compose textarea {
  background: rgba(91, 60, 36, .025);
}

/* ============ Note detail ============ */
.note-detail-page {
  padding: 96px 0 0;
}

.note-detail-container {
  width: min(100% - 40px, 820px);
  padding-bottom: 56px;
}

.note-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.note-detail-label {
  color: var(--blue-light);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.note-detail-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted-2);
  font-size: 12px;
}

.note-detail-meta .article-edit-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.note-detail-content {
  padding: clamp(22px, 4vw, 38px);
  box-shadow: none;
}

.note-detail-content p,
.note-detail-content ul,
.note-detail-content ol {
  font-size: 16px;
  line-height: 1.78;
}

.note-editor-card {
  max-width: 820px;
}

.note-editor-card textarea {
  min-height: 220px;
}

.note-editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.note-editor-actions .writer-switches {
  display: flex;
  flex: 1 1 auto;
  gap: 14px;
}

.note-editor-actions .writer-submit-row { margin-left: auto; }

@media (max-width: 1060px) {
  .blog-content-grid > .sidebar { display: contents; }
  .blog-content-grid > .home-main { order: 0; }
  .blog-content-grid > .sidebar > .notes-card { order: -1; }
  .blog-content-grid > .sidebar > .side-card:not(.notes-card) { order: 1; }
}

@media (max-width: 600px) {
  .notes-card { padding: 16px; }
  .notes-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
  }
  .note-item {
    padding: 10px;
    border-bottom: 0;
    border-right: 1px solid var(--border-soft);
  }
  .note-item:first-child { padding-top: 10px; padding-left: 0; }
  .note-item:last-child { padding-right: 0; border-right: 0; }
  .note-item-text { -webkit-line-clamp: 4; font-size: 12px; }
  .note-item-meta { align-items: flex-start; flex-direction: column; gap: 5px; }
  .note-detail-page { padding-top: 78px; }
  .note-detail-container { width: min(100% - 24px, 820px); }
  .note-detail-head { align-items: flex-start; flex-direction: column; }
  .note-detail-meta { justify-content: flex-start; }
  .note-editor-actions { align-items: flex-start; flex-direction: column; }
  .note-editor-actions .writer-submit-row { margin-left: 0; }
}

@media (max-width: 380px) {
  .notes-list { grid-template-columns: 1fr; }
  .note-item,
  .note-item:first-child,
  .note-item:last-child {
    padding: 10px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }
  .note-item-meta { align-items: center; flex-direction: row; }
}
