/* Inkwell — Library Card Catalog Drawer theme */

:root {
  --primary: #5d4037;
  --primary-dark: #3e2723;
  --secondary: #ffd54f;
  --accent: #c62828;
  --gold: #b8860b;
  --paper: #f6eeda;
  --ink: #2c231d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--primary-dark);
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}

/* ---------- Wooden drawer ---------- */
.drawer {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.10), transparent 30%),
    linear-gradient(180deg, #6d4c41, #4e342e 55%, #3e2723);
  padding-top: var(--safe-t);
}

.drawer-rim {
  position: relative;
  height: 46px;
  flex: 0 0 auto;
  background:
    repeating-linear-gradient(90deg,
      rgba(255,255,255,.06) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #7a5548, #5d4037);
  box-shadow: 0 2px 6px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.18);
  border-bottom: 3px solid #3e2723;
  border-radius: 10px 10px 0 0;
}
.drawer-rim::after {
  content: "";
  position: absolute;
  inset: 8px 18px 4px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(255,255,255,.05));
  box-shadow: inset 0 1px 3px rgba(0,0,0,.4);
}

/* ---------- Paper / content ---------- */
#content.paper {
  flex: 1 1 auto;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
  padding: 16px 14px 96px;
  background:
    radial-gradient(circle at 50% -10%, rgba(0,0,0,.05), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(160,130,90,.28) 27px 29px),
    repeating-linear-gradient(90deg,
      rgba(120,90,55,.05) 0 2px, transparent 2px 8px),
    linear-gradient(180deg, #f8f1e0, #efe3c8);
}
/* fine paper crease lines */
#content.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(93deg, transparent 0 40px, rgba(90,60,30,.05) 40px 41px),
    repeating-linear-gradient(175deg, transparent 0 60px, rgba(90,60,30,.04) 60px 61px);
}

/* ---------- Tabs ---------- */
.tab-view { display: none; }
.tab-view.active { display: block; animation: rise .3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

.tab-title {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 30px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 14px;
  text-shadow: 0 1px 0 #fff;
}

/* ---------- Dashboard / inkwell ---------- */
.dashboard { margin-bottom: 6px; }

.inkwell-row { display: flex; justify-content: center; }
.inkwell { width: 300px; }

.inkwell-glass {
  position: relative;
  height: 118px;
  border-radius: 24px 24px 30px 30px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.06) 60%),
    linear-gradient(160deg, #9fb6bd, #eef6f8 45%, #b8cbd1);
  box-shadow:
    inset 0 -10px 18px rgba(20,40,50,.35),
    inset 0 4px 10px rgba(255,255,255,.5),
    0 6px 14px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.6);
}
.ink-surface {
  position: absolute;
  left: 8px; right: 8px; bottom: 12px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 50%, #2a2320 20%, #3a2f2a 70%);
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
}

/* calligraphy nibs resting in the glass */
.nib {
  position: absolute;
  transform-origin: bottom center;
  font-family: Georgia, serif;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nib.gold {
  width: 44px; height: 118px; left: 34px; top: 0;
  transform: rotate(6deg);
  background:
    linear-gradient(180deg, #fff3c4, #d4af37 40%, #a67c00 100%);
  border-radius: 6px 6px 10px 10px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,.25), 0 4px 8px rgba(0,0,0,.3);
}
.nib.steel {
  width: 42px; height: 110px; right: 36px; top: 2px;
  transform: rotate(-6deg);
  background: linear-gradient(180deg, #f7fbfd, #c9d4d8 40%, #8fa4ab 100%);
  border-radius: 6px 6px 10px 10px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.3);
}
.nib-count {
  font-family: "Brush Script MT", cursive;
  font-size: 26px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.5);
}
.nib.gold .nib-count { color: #5d4037; text-shadow: 0 1px 0 #fff; }
.nib-tip {
  position: absolute;
  bottom: -4px;
  width: 8px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #1a1310, #000);
  box-shadow: 0 0 4px #000;
}

.inkwell-caption {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px 0;
}
.cap {
  font-family: "Brush Script MT", cursive;
  font-size: 17px;
  color: var(--primary-dark);
  text-align: center;
  line-height: 1.1;
}
.cap.gold { color: #8a6d00; }
.cap.steel { color: #3f5560; }

.board-head {
  font-family: "Brush Script MT", cursive;
  font-size: 20px;
  color: var(--primary);
  margin: 14px 0 8px;
  border-bottom: 1px dashed rgba(90,60,30,.35);
  padding-bottom: 4px;
}

.recent-list { list-style: none; }
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 2px;
  border-bottom: 1px dotted rgba(90,60,30,.3);
  font-size: 14px;
}
.recent-item .r-title {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 18px;
  font-style: italic;
}
.recent-item .r-status {
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
}

/* ---------- Toolbar / search ---------- */
.toolbar { margin: 10px 0 12px; }
.search {
  width: 100%;
  padding: 12px 14px;
  font-family: Georgia, serif;
  font-size: 15px;
  color: var(--ink);
  background: rgba(255,250,235,.9);
  border: 1px solid rgba(90,60,30,.4);
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 2px 4px rgba(0,0,0,.08);
  outline: none;
}
.search:focus { border-color: var(--secondary); }

/* ---------- Note list / checkout cards ---------- */
.note-list { list-style: none; }
.note-item {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0)),
    #fbf4e3;
  border-radius: 6px;
  border: 1px solid rgba(120,90,50,.5);
  box-shadow: 0 2px 5px rgba(60,40,20,.18), inset 0 0 0 1px rgba(255,255,255,.6);
  margin-bottom: 14px;
  padding: 10px 12px 8px;
  touch-action: pan-y;
  overflow: hidden;
  transform: translateZ(0);
}
.note-item.swiping { transition: none; }
.note-item.settling { transition: transform .3s ease, opacity .3s ease; }

.note-item .n-title {
  font-family: "Segoe Print", "Brush Script MT", cursive;
  font-style: italic;
  font-size: 20px;
  color: #1c1a3a;
  text-shadow: 0 0 1px rgba(0,0,0,.2);
}
.note-item .n-author {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 16px;
  color: #4a3b2f;
  margin: 1px 0 6px;
}
.note-item .n-date {
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 1px;
  opacity: .85;
}

/* vintage due-date stamp pattern corner */
.note-item .stamp {
  position: absolute;
  top: 8px; right: 8px;
  width: 44px;
  font-family: "Courier New", monospace;
  font-size: 7px;
  line-height: 1.5;
  color: rgba(120,60,40,.35);
  text-align: right;
  pointer-events: none;
  white-space: pre;
}

/* gold embossed library seal (no checkmarks) */
.note-item .seal {
  position: absolute;
  bottom: 6px; right: 8px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(150,110,20,.6);
  background: radial-gradient(circle at 35% 30%, rgba(255,215,120,.5), rgba(184,134,11,.15) 70%);
  box-shadow: inset 0 1px 3px rgba(255,255,255,.5), 0 1px 2px rgba(90,70,10,.4);
  pointer-events: none;
}
.seal::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(150,110,20,.5);
}
.seal::after {
  content: "📖";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: .8;
  filter: sepia(.5);
}

.note-empty {
  text-align: center;
  color: rgba(70,50,30,.6);
  font-family: "Brush Script MT", cursive;
  font-size: 18px;
  font-style: italic;
  padding: 22px 0;
}

/* swipe action hints */
.swipe-hint {
  font-size: 10px;
  color: rgba(90,60,30,.5);
  font-style: italic;
  margin-top: 4px;
  letter-spacing: .3px;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(88px + var(--safe-b));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  line-height: 1;
  color: #fff;
  background: linear-gradient(180deg, var(--accent), #8e1f1f);
  box-shadow: 0 5px 12px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.3);
  z-index: 20;
  cursor: pointer;
}

/* ---------- Bottom ribbon tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 74px;
  padding-bottom: var(--safe-b);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  z-index: 30;
  pointer-events: none;
}
.ribbon {
  pointer-events: auto;
  position: relative;
  width: 25%;
  height: 62px;
  border: none;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  transform-origin: top center;
  transition: height .25s ease, filter .25s ease, transform .25s ease;
  -webkit-tap-highlight-color: transparent;
}
/* satin ribbons with varied colors */
.ribbon:nth-child(1) { background: linear-gradient(180deg,#e05252,#a32828 55%,#7c1c1c); }
.ribbon:nth-child(2) { background: linear-gradient(180deg,#7e4f3c,#5d4037 55%,#46302a); }
.ribbon:nth-child(3) { background: linear-gradient(180deg,#5f8f9e,#3f6370 55%,#2f4b56); }
.ribbon:nth-child(4) { background: linear-gradient(180deg,#c99a2a,#a87c14 55%,#8a640e); }
.ribbon::after { /* notched tail */
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 14px;
  background: inherit;
  clip-path: polygon(0 0, 38% 0, 50% 60%, 62% 0, 100% 0, 100% 100%, 50% 65%, 0 100%);
  filter: brightness(.85);
}
.sheen {
  position: absolute;
  top: 4px; left: 12%;
  width: 30%; height: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  opacity: 0;
  transition: opacity .25s ease;
}
.rib-label { position: relative; top: 22px; display: block; }

/* active: pulled out ~2cm, glossy, drop shadow */
.ribbon.active {
  height: 100px;
  filter: saturate(1.05);
  box-shadow: 0 -6px 20px rgba(0,0,0,.5);
  animation: sheenMove 3s ease infinite;
}
.ribbon.active .sheen { opacity: 1; }
@keyframes sheenMove {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 40px 0; }
}
/* inactive: flat, matte, shorter */
.ribbon:not(.active) {
  height: 52px;
  filter: saturate(.7) brightness(.9);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30,20,10,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
}
.modal-card {
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  background:
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(160,130,90,.15) 25px 27px),
    linear-gradient(180deg, #fbf4e3, #efe3c8);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(22px + var(--safe-b));
  box-shadow: 0 -8px 30px rgba(0,0,0,.4);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  border: none; background: none;
  font-size: 26px; color: var(--primary); cursor: pointer;
}
.modal-card h2 {
  font-family: "Brush Script MT", cursive;
  font-size: 26px;
  color: var(--primary);
  margin-bottom: 12px;
}
.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  font-family: Georgia, serif;
  font-size: 15px;
  color: var(--ink);
  background: rgba(255,250,235,.9);
  border: 1px solid rgba(90,60,30,.4);
  border-radius: 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--secondary); }
.field .error {
  display: none;
  color: var(--accent);
  font-size: 12px;
  margin-top: 3px;
}
.field.invalid .error { display: block; }
.field.invalid input, .field.invalid select { border-color: var(--accent); }

.form-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(180deg, var(--accent), #8e1f1f); color: #fff; }
.btn.ghost { background: rgba(90,60,30,.12); color: var(--primary); }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(84px + var(--safe-b));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
  font-size: 14px;
  animation: snackIn .25s ease;
}
@keyframes snackIn { from { transform: translateY(20px); opacity: 0;} to { transform: none; opacity: 1;} }
.snackbar button {
  border: none; background: none;
  color: var(--secondary);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  text-transform: uppercase;
}

/* ---------- Confirm dialog (delete) ---------- */
.confirm {
  position: fixed; inset: 0;
  background: rgba(30,20,10,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.confirm-card {
  width: 86%; max-width: 340px;
  background: #fbf4e3;
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.confirm-card h3 {
  font-family: "Brush Script MT", cursive;
  font-size: 24px; color: var(--primary);
}
.confirm-card p { margin: 10px 0 18px; font-size: 14px; color: var(--ink); }
.confirm-card .row { display: flex; gap: 10px; }

@media (min-width: 600px) {
  #content.paper { padding-left: 8vw; padding-right: 8vw; }
  .note-list { max-width: 560px; margin: 0 auto; }
  .dashboard { max-width: 560px; margin: 0 auto 6px; }
  .toolbar { max-width: 560px; margin-left: auto; margin-right: auto; }
  .modal-card { max-width: 520px; border-radius: 20px; margin-bottom: 40px; }
}