/* ===========================================================================
   BrandBlog — Pastenote
   A 3M Post-it style notice board for `content/pages/pastenote.md`.

   This is a page-scoped stylesheet (linked only from theme/templates/pastenote.html)
   so the Post-it look — Canary yellow paper, handwriting, tilt and texture — stays
   self-contained and does not leak into the site design system. Design tokens are
   declared on `.pn-page` and documented in research/design_decisions.md §12.
   =========================================================================== */

.pn-page {
  /* ---- Post-it paper colours (3M-inspired) ---- */
  --note-yellow: #ffe066;
  --note-yellow-deep: #ffd43b;
  --note-blue: #a5d8ff;
  --note-blue-deep: #74c0fc;
  --note-pink: #ffc9c9;
  --note-pink-deep: #ffa8a8;
  --note-green: #b2f2bb;
  --note-green-deep: #8ce99a;
  --note-orange: #ffcc80;
  --note-orange-deep: #ffb454;
  --note-purple: #d0bfff;
  --note-purple-deep: #b197fc;

  /* ---- Ink ---- */
  --ink: var(--brand-ink);
  --ink-light: var(--brand-muted);

  /* ---- Elevation ---- */
  --note-shadow: var(--brand-shadow);
  --note-shadow-hover: 0 12px 32px rgba(0, 0, 40, 0.14);

  /* ---- Surfaces ---- */
  --paper-bg: var(--brand-white);
  --board-bg: var(--brand-surface);

  /* ---- Shared typography ---- */
  --pn-hand: var(--brand-font-sans);
  --pn-ui: var(--brand-font-sans);
}

/* ---------------------------------------------------------------------------
   Compose / paste zone
   --------------------------------------------------------------------------- */
.pn-compose {
  margin-top: 2rem;
  border: 1px dashed var(--brand-line);
  border-radius: 2px;
  background: var(--brand-white);
  padding: 1rem 1rem 0.75rem;
  transition: border-color 200ms ease, background-color 200ms ease,
    box-shadow 200ms ease;
}

.pn-compose:focus-within {
  border-color: var(--brand-petrol);
  border-style: solid;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 153, 153, 0.1);
}

.pn-compose.is-dragover {
  border-color: var(--brand-petrol);
  border-style: solid;
  background: var(--brand-surface);
}

.pn-compose-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.pn-compose-icon {
  font-size: 1.35rem;
  line-height: 1.6;
  user-select: none;
}

.pn-paste-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.25rem;
  font-family: var(--pn-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: #000;
  outline: none;
}

.pn-paste-input::placeholder {
  color: #9a958b;
}

.pn-compose-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid #ece9e0;
}

.pn-colors {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pn-color-dot {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  border: 2px solid rgba(0, 0, 40, 0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 150ms ease, box-shadow 150ms ease,
    border-color 150ms ease;
}

.pn-color-dot:hover {
  transform: scale(1.1);
}

.pn-color-dot[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0, 0, 40, 0.12);
  transform: scale(1.08);
}

.pn-color-dot:focus-visible {
  outline: 2px solid var(--brand-petrol);
  outline-offset: 2px;
}

.pn-compose-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.pn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 2px;
  padding: 0.55rem 1rem;
  font-family: var(--pn-ui);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease,
    border-color 160ms ease, transform 120ms ease;
}

.pn-btn:active {
  transform: translateY(1px);
}

.pn-btn-primary {
  border: 1px solid var(--brand-petrol);
  background: var(--brand-petrol);
  color: #fff;
}

.pn-btn-primary:hover {
  background: #007f7f;
  border-color: #007f7f;
}

.pn-btn-ghost {
  border: 1px solid var(--brand-line);
  background: var(--brand-white);
  color: var(--brand-ink);
}

.pn-btn-ghost:hover {
  border-color: var(--brand-petrol);
  color: var(--brand-petrol);
}

.pn-btn:focus-visible {
  outline: 2px solid var(--brand-petrol);
  outline-offset: 2px;
}

.pn-compose-hint {
  margin-top: 0.65rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--brand-muted);
}

/* ---------------------------------------------------------------------------
   Board
   --------------------------------------------------------------------------- */
.pn-board-section {
  background: var(--board-bg);
  background-image: radial-gradient(
      circle at 1px 1px,
      rgba(0, 0, 40, 0.05) 1px,
      transparent 0
    );
  background-size: 22px 22px;
  padding: 3rem 0 4.5rem;
}

.pn-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1.75rem;
}

.pn-board-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #000;
}

.pn-board-count {
  font-size: 0.85rem;
  color: var(--brand-muted);
}

.pn-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .pn-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------------------
   A single Post-it note
   --------------------------------------------------------------------------- */
.pn-note {
  position: relative;
  display: flex;
  min-height: 240px;
  aspect-ratio: 1 / 1;
  flex-direction: column;
  padding: 2rem 1.35rem 0.9rem;
  border-radius: 2px 2px 8px 8px;
  color: var(--ink);
  background: linear-gradient(
    180deg,
    var(--pn-c, var(--note-yellow)) 0%,
    var(--pn-c, var(--note-yellow)) 86%,
    var(--pn-c-deep, var(--note-yellow-deep)) 100%
  );
  box-shadow: var(--note-shadow);
  transform: rotate(var(--pn-tilt, 0deg));
  transition: transform 180ms ease, box-shadow 180ms ease;
  overflow: hidden;
}

/* Slight curl on the bottom edge — a soft highlight + darker lip. */
.pn-note::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0) 22%,
    rgba(0, 0, 0, 0) 82%,
    rgba(0, 0, 0, 0.08) 100%
  );
  pointer-events: none;
}

/* Very subtle paper grain (~4–5%). */
.pn-note::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.pn-note:hover,
.pn-note:focus-within {
  box-shadow: var(--note-shadow-hover);
  transform: rotate(var(--pn-tilt, 0deg)) scale(1.02);
  z-index: 2;
}

.pn-note.is-enter {
  animation: pn-note-in 320ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.pn-tilt-l {
  --pn-tilt: -1deg;
}

.pn-tilt-r {
  --pn-tilt: 1deg;
}

/* Colour modifiers */
.pn-note--yellow {
  --pn-c: var(--note-yellow);
  --pn-c-deep: var(--note-yellow-deep);
}
.pn-note--blue {
  --pn-c: var(--note-blue);
  --pn-c-deep: var(--note-blue-deep);
}
.pn-note--pink {
  --pn-c: var(--note-pink);
  --pn-c-deep: var(--note-pink-deep);
}
.pn-note--green {
  --pn-c: var(--note-green);
  --pn-c-deep: var(--note-green-deep);
}
.pn-note--orange {
  --pn-c: var(--note-orange);
  --pn-c-deep: var(--note-orange-deep);
}
.pn-note--purple {
  --pn-c: var(--note-purple);
  --pn-c-deep: var(--note-purple-deep);
}

/* Push-pin */
.pn-pin {
  position: absolute;
  top: 0.55rem;
  left: 0.7rem;
  width: 1.1rem;
  height: 1.1rem;
  color: rgba(0, 0, 40, 0.55);
  transform: rotate(-18deg);
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

/* Note body */
.pn-note-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  overflow: auto;
  font-family: var(--pn-hand);
  font-size: 19px;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pn-note-body[contenteditable="true"] {
  outline: none;
  cursor: text;
}

.pn-note-body[contenteditable="true"]:empty::before {
  content: "Viết gì đó…";
  color: rgba(0, 0, 40, 0.4);
}

.pn-note-body[contenteditable="true"]:focus-visible {
  border-radius: 2px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 40, 0.25);
}

/* Link card inside a note */
.pn-link {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
}

.pn-link:hover .pn-link-host {
  text-decoration: underline;
}

.pn-link-favicon {
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 auto;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.75);
  object-fit: contain;
  padding: 2px;
}

.pn-link-meta {
  min-width: 0;
}

.pn-link-host {
  display: block;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
}

.pn-link-path {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pn-link-caption {
  margin-top: 0.35rem;
  font-size: 16px;
  color: var(--ink-light);
}

/* Image note */
.pn-image {
  display: block;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 40, 0.08);
}

.pn-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 210px;
  object-fit: cover;
}

.pn-image-caption {
  margin-top: 0.45rem;
  font-size: 16px;
  color: var(--ink-light);
}

/* Footer: timestamp + actions */
.pn-note-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0, 0, 40, 0.12);
}

.pn-note-time {
  font-family: var(--pn-ui);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(0, 0, 40, 0.6);
  white-space: nowrap;
}

.pn-note-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.pn-note:hover .pn-note-actions,
.pn-note:focus-within .pn-note-actions {
  opacity: 1;
  transform: translateY(0);
}

.pn-icon-btn {
  display: inline-flex;
  width: 1.85rem;
  height: 1.85rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(0, 0, 40, 0.7);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.pn-icon-btn:hover {
  background: rgba(0, 0, 40, 0.12);
  color: var(--ink);
}

.pn-icon-btn.is-danger:hover {
  background: rgba(208, 2, 27, 0.12);
  color: #d0021b;
}

.pn-icon-btn:focus-visible {
  outline: 2px solid var(--brand-petrol);
  outline-offset: 1px;
}

/* Touch devices have no hover — keep the controls reachable. */
@media (hover: none) {
  .pn-note-actions {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------------- */
.pn-empty {
  margin-top: 0.5rem;
  border: 2px dashed #d8d5cc;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  padding: 3.25rem 1.5rem;
  text-align: center;
}

.pn-empty-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

.pn-empty-title {
  margin-top: 0.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #000;
}

.pn-empty-text {
  margin: 0.4rem auto 0;
  max-width: 28rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--brand-muted);
}

/* ---------------------------------------------------------------------------
   Sync status pill (sticky bottom-right)
   --------------------------------------------------------------------------- */
.pn-sync {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: calc(100vw - 2rem);
  border-radius: 100px;
  background: var(--brand-petrol);
  padding: 0.5rem 0.55rem 0.5rem 1rem;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 40, 0.16);
  font-family: var(--pn-ui);
  font-size: 0.82rem;
  font-weight: 600;
}

.pn-sync[data-state="error"] {
  background: #d0021b;
  box-shadow: 0 8px 24px rgba(208, 2, 27, 0.32);
}

.pn-sync[data-state="syncing"] {
  background: #007f7f;
}

.pn-sync-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pn-sync-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: #b2f2bb;
}

.pn-sync[data-state="syncing"] .pn-sync-dot {
  background: #ffe066;
  animation: pn-pulse 900ms ease-in-out infinite;
}

.pn-sync[data-state="error"] .pn-sync-dot {
  background: #fff;
}

.pn-sync-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pn-sync-btn {
  border: 0;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.18);
  padding: 0.4rem 0.85rem;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.pn-sync-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

.pn-sync-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.pn-sync-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.pn-sync-gear {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.pn-sync-gear:hover {
  background: rgba(255, 255, 255, 0.32);
}

.pn-sync-gear:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Modal (GitHub token / settings)
   --------------------------------------------------------------------------- */
.pn-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
}

.pn-modal.is-open {
  display: block;
}

.pn-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 250ms ease;
}

.pn-modal.is-open .pn-modal-overlay {
  opacity: 1;
}

.pn-modal-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow-y: auto;
  padding: 0;
}

.pn-modal-panel {
  width: 100%;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  transform: translateY(16px);
  opacity: 0;
  transition: transform 280ms ease, opacity 280ms ease;
}

.pn-modal.is-open .pn-modal-panel {
  transform: translateY(0);
  opacity: 1;
}

.pn-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 1.5rem;
}

.pn-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #000;
}

.pn-modal-sub {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--brand-muted);
}

.pn-modal-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--brand-muted);
  cursor: pointer;
}

.pn-modal-close:hover {
  background: #f5f5f5;
  color: #000;
}

.pn-modal-body {
  padding: 1.25rem 1.5rem;
}

.pn-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #000;
}

.pn-input {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  padding: 0.65rem 0.85rem;
  font-family: var(--pn-ui);
  font-size: 0.9rem;
  color: #000;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.pn-input:focus {
  border-color: var(--brand-petrol);
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 153, 153, 0.1);
}

.pn-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.9rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--brand-muted);
}

.pn-check input {
  margin-top: 0.15rem;
}

.pn-note-text {
  margin-top: 1rem;
  border-left: 3px solid #ffd43b;
  background: #fff9e6;
  padding: 0.75rem 0.9rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: #5c5750;
}

.pn-modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid #e0e0e0;
  padding: 1rem 1.5rem;
}

.pn-modal-foot .pn-btn-ghost {
  color: var(--brand-muted);
}

.pn-modal-foot .pn-btn-ghost:hover {
  border-color: #d0021b;
  color: #d0021b;
}

@media (min-width: 640px) {
  .pn-modal-content {
    align-items: center;
    padding: 1.5rem;
  }

  .pn-modal-panel {
    max-width: 30rem;
    border-radius: 16px;
  }
}

/* ---------------------------------------------------------------------------
   Toasts
   --------------------------------------------------------------------------- */
.pn-toasts {
  position: fixed;
  right: 1rem;
  top: 5.75rem;
  z-index: 80;
  display: flex;
  width: min(92vw, 22rem);
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.pn-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  border: 1px solid #e0e0e0;
  border-left: 4px solid var(--brand-petrol);
  border-radius: 10px;
  background: #fff;
  padding: 0.85rem 1rem;
  font-family: var(--pn-ui);
  font-size: 0.85rem;
  line-height: 1.4;
  color: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  pointer-events: auto;
  animation: pn-toast-in 240ms ease-out both;
}

.pn-toast.is-error {
  border-left-color: #d0021b;
}

.pn-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease-in, transform 200ms ease-in;
}

/* ---------------------------------------------------------------------------
   Animations
   --------------------------------------------------------------------------- */
@keyframes pn-note-in {
  from {
    opacity: 0;
    transform: rotate(var(--pn-tilt, 0deg)) scale(0.92);
  }
  to {
    opacity: 1;
    transform: rotate(var(--pn-tilt, 0deg)) scale(1);
  }
}

@keyframes pn-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pn-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pn-note,
  .pn-note.is-enter,
  .pn-toast,
  .pn-sync-dot,
  .pn-modal-panel,
  .pn-modal-overlay,
  .pn-color-dot {
    animation: none !important;
    transition: none !important;
  }

  .pn-note:hover,
  .pn-note:focus-within {
    transform: rotate(var(--pn-tilt, 0deg));
  }
}

/* ---------------------------------------------------------------------------
   Small screens
   --------------------------------------------------------------------------- */
@media (max-width: 639px) {
  .pn-board {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .pn-note {
    min-height: 220px;
  }

  .pn-sync {
    right: 0.75rem;
    bottom: 0.75rem;
    font-size: 0.78rem;
  }
}
