/* ---- Jotter: handwritten paper aesthetic ---- */

:root {
  --desk: #e9decb;
  --paper: #fffdf4;
  --paper-shade: #f6efd9;
  --rule: #b9d4e2;
  --margin-red: #e2857c;
  --ink: #26364e;
  --ink-soft: #44546c;
  --pencil: #7c7668;
  --accent: #b3402f;
  --sticky: #fdf3b3;
  --shadow: 0 2px 6px rgba(90, 70, 40, 0.18), 0 12px 28px rgba(90, 70, 40, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.5), transparent 45%),
    var(--desk);
  color: var(--ink);
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 19px;
  line-height: 1.45;
}

a { color: var(--accent); }

/* ---- Header ---- */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem 0.4rem;
  flex-wrap: wrap;
}

.brand {
  position: relative;
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 2.4rem;
  color: var(--ink);
  text-decoration: none;
  transform: rotate(-2deg);
  display: inline-block;
}

.brand-underline {
  position: absolute;
  left: -2px;
  right: -6px;
  bottom: 2px;
  height: 4px;
  background: var(--accent);
  border-radius: 40% 60% 55% 45% / 60% 40% 60% 40%;
  transform: rotate(-1deg);
  opacity: 0.75;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1.05rem;
}

.nav-hello { color: var(--pencil); }

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Flash notes ---- */
.flash-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
}

.flash {
  background: var(--sticky);
  padding: 0.5rem 1.2rem;
  box-shadow: var(--shadow);
  transform: rotate(-1deg);
  border-radius: 2px;
  max-width: 34rem;
}

.flash-error { background: #f9d3c8; }

/* ---- Layout ---- */
.page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1rem 1.2rem 4rem;
}

.page-title, .section-title {
  font-family: "Caveat", cursive;
  font-weight: 700;
  color: var(--ink);
  transform: rotate(-1deg);
}

.page-title { font-size: 2.6rem; margin: 0.4rem 0 1rem; }
.section-title { font-size: 2rem; margin: 2.2rem 0 0.8rem; }

/* ---- Paper pieces ---- */
.paper-sheet, .paper-card {
  background: var(--paper);
  box-shadow: var(--shadow);
  border-radius: 3px;
}

.sheet-title {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 2.3rem;
  margin: 0 0 0.8rem;
  transform: rotate(-0.6deg);
}

/* ---- Forms & inputs ---- */
.handwriting-input,
.stacked-form input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px dashed var(--pencil);
  padding: 0.3rem 0.2rem;
  outline: none;
  min-width: 0;
}

.handwriting-input:focus,
.stacked-form input:focus {
  border-bottom-color: var(--accent);
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stacked-form label {
  margin-top: 0.7rem;
  color: var(--pencil);
  font-size: 1rem;
}

.hint { color: var(--pencil); font-size: 0.95rem; }

.btn {
  font: inherit;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  padding: 0.35rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:hover { background: var(--paper-shade); transform: rotate(-1deg) scale(1.03); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: bold;
}

.btn-ghost { border-color: var(--pencil); color: var(--ink-soft); }
.btn-danger, .btn-danger-text { border-color: var(--accent); color: var(--accent); }
.btn-small { padding: 0.2rem 0.9rem; font-size: 0.95rem; }

/* ---- Auth pages ---- */
.auth-wrap { display: flex; justify-content: center; padding-top: 2rem; }

.auth-card {
  width: 100%;
  max-width: 26rem;
  padding: 2rem 2.2rem 1.6rem;
  transform: rotate(0.5deg);
}

.auth-card .btn { margin-top: 1.4rem; align-self: flex-start; }
.auth-alt { color: var(--pencil); margin-top: 1.4rem; }

/* ---- Dashboard ---- */
.new-list-form {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  margin-bottom: 1.8rem;
  flex-wrap: wrap;
}

.new-list-form .handwriting-input { flex: 1 1 16rem; font-size: 1.25rem; }

.empty-note { color: var(--pencil); font-size: 1.15rem; transform: rotate(-0.5deg); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 1.3rem;
}

.list-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.1rem 1.2rem 1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
  border-radius: 2px;
  text-decoration: none;
  color: var(--ink);
  transform: rotate(-1deg);
  transition: transform 0.12s ease;
  background-image: repeating-linear-gradient(
    transparent, transparent 1.55em, var(--rule) 1.55em, var(--rule) calc(1.55em + 1px)
  );
}

.card-grid .list-card:nth-child(even) { transform: rotate(1.2deg); }
.list-card:hover { transform: rotate(0deg) scale(1.04); }

.card-borrowed { background-color: var(--sticky); }

.card-title {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1.1;
}

.card-count { color: var(--ink-soft); font-size: 1rem; }
.card-shared { color: var(--accent); font-size: 0.95rem; }

/* ---- List page ---- */
.list-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 1.6rem;
  align-items: start;
}

.list-toolbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.toolbar-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.back-link { text-decoration: none; font-size: 1.05rem; }

.list-sheet {
  padding: 1.6rem 1.6rem 2.2rem 3.4rem;
  position: relative;
  background-image:
    linear-gradient(to right, transparent 2.35rem, var(--margin-red) 2.35rem, var(--margin-red) calc(2.35rem + 2px), transparent calc(2.35rem + 2px)),
    repeating-linear-gradient(transparent, transparent 2.1em, var(--rule) 2.1em, var(--rule) calc(2.1em + 1px));
  min-height: 24rem;
}

/* ---- Items ---- */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-height: 2.1em;
  line-height: 2.1em;
  font-size: 1.15rem;
}

.item-check {
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  align-self: center;
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  cursor: pointer;
  position: relative;
  padding: 0;
}

.item-check::after {
  content: "\2713";
  position: absolute;
  left: 0.02em;
  top: -0.42em;
  font-size: 1.25em;
  color: var(--accent);
  transform: scale(0) rotate(-8deg);
  transition: transform 0.18s ease-out;
}

.item.done .item-check::after,
.item.scribbling .item-check::after {
  transform: scale(1) rotate(-8deg);
}

.item-text {
  position: relative;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.item-text::after {
  content: "";
  position: absolute;
  left: -0.15em;
  top: 55%;
  height: 2px;
  width: 0;
  background: var(--ink-soft);
  transform: rotate(-0.7deg);
  transition: width 0.55s ease-in-out;
  pointer-events: none;
}

.item.scribbling .item-text::after,
.item.done .item-text::after { width: 102%; }

.item.done .item-text { color: var(--pencil); }

.item-delete {
  flex: 0 0 auto;
  align-self: center;
  background: none;
  border: none;
  color: var(--pencil);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  opacity: 0.35;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.item:hover .item-delete, .item-delete:focus { opacity: 1; color: var(--accent); }

/* ---- Add item row ---- */
.add-item-form {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.1em;
  margin-top: 0.1rem;
}

.add-bullet {
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  border: 2px dashed var(--pencil);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  opacity: 0.6;
}

.add-item-form .handwriting-input {
  flex: 1 1 auto;
  font-size: 1.15rem;
  border-bottom: none;
}

.add-item-form .handwriting-input::placeholder { color: var(--pencil); opacity: 0.7; }

/* ---- Done section ---- */
.done-section {
  margin-top: 1.6rem;
  border-top: 2px dashed var(--pencil);
  padding-top: 0.5rem;
}

.done-toggle {
  background: none;
  border: none;
  font: inherit;
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--pencil);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.done-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.done-toggle.open .done-arrow { transform: rotate(90deg); }

.done-list .item-text { text-decoration: none; }

/* ---- Share panel ---- */
.share-panel {
  background: var(--sticky);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.3rem;
  transform: rotate(1.2deg);
  border-radius: 2px;
}

.share-heading {
  font-family: "Caveat", cursive;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.member-list {
  list-style: none;
  margin: 0 0 0.8rem;
  padding: 0;
}

.member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px dotted rgba(0, 0, 0, 0.18);
}

.member-remove {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0 0.3rem;
}

.invite-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.invite-form .handwriting-input { flex: 1 1 auto; }

/* ---- Modals ---- */
.modal-backdrop[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 45, 25, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 50;
}

.modal {
  max-width: 24rem;
  width: 100%;
  padding: 1.5rem 1.7rem;
  transform: rotate(-0.8deg);
}

.modal-title {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 1.9rem;
  margin: 0 0 0.4rem;
}

.modal-message { margin: 0 0 1.2rem; color: var(--ink-soft); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

/* ---- Mobile ---- */
@media (max-width: 760px) {
  body { font-size: 17px; }

  .list-page { grid-template-columns: 1fr; }

  .share-panel { transform: rotate(0deg); }

  .list-sheet { padding: 1.2rem 1rem 1.8rem 2.6rem; }

  .list-sheet {
    background-image:
      linear-gradient(to right, transparent 1.8rem, var(--margin-red) 1.8rem, var(--margin-red) calc(1.8rem + 2px), transparent calc(1.8rem + 2px)),
      repeating-linear-gradient(transparent, transparent 2.1em, var(--rule) 2.1em, var(--rule) calc(2.1em + 1px));
  }

  .item-delete { opacity: 0.7; }

  .site-header { padding: 0.7rem 1rem 0.2rem; }
  .brand { font-size: 2rem; }
}

/* ---- Print: a clean checklist page ---- */
@media print {
  body {
    background: #fff;
    font-size: 13pt;
    color: #000;
  }

  .site-header, .flash-stack, .no-print, .share-panel,
  .list-toolbar, .add-item-form, .item-delete, .modal-backdrop {
    display: none !important;
  }

  .page { max-width: none; padding: 0; }

  .list-page { display: block; }

  .paper-sheet {
    box-shadow: none;
    border-radius: 0;
    background-image: none;
    padding: 0;
    min-height: 0;
  }

  .sheet-title { transform: none; }

  .item { break-inside: avoid; }

  .item-check {
    border-color: #000;
    border-radius: 2px;
  }

  .item.done .item-text { color: #555; }

  .done-section { border-top-color: #999; }

  .done-toggle {
    color: #000;
    cursor: default;
  }

  .done-arrow { display: none; }
}
