/* drekka: an old explorer's field journal. aged paper, ink, a leather cover.
   everything is lowercase and handwritten, on purpose. */
:root {
  --paper: #f1e6cc;
  --paper-dark: #e3d2ad;
  --ink: #2b1d12;
  --ink-soft: #5c4532;
  --faded: #8a7258;
  --leather: #4a3121;
  --leather-light: #6b4630;
  --brass: #b08d57;
  --accent: #7a2e1f;   /* deep red ink */
  --line: rgba(43, 29, 18, 0.25);
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: "Caveat", cursive; font-size: 21px; line-height: 1.3; text-transform: lowercase;
  background: var(--noise), radial-gradient(ellipse at 50% 0%, var(--paper) 40%, var(--paper-dark) 100%) fixed;
  background-color: var(--paper);
}
button, input, textarea { font: inherit; color: inherit; text-transform: lowercase; }
::placeholder { text-transform: lowercase; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Leather header with stitching */
.leather {
  background: var(--noise), linear-gradient(160deg, var(--leather-light), var(--leather) 60%, #3a2518);
  color: #f3e3c3;
}
header.leather {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 2px dashed rgba(243, 227, 195, 0.35);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
.brand { text-align: center; }
.brand h1 { margin: 0; font-family: "Caveat", cursive; font-weight: 700; font-size: 36px; line-height: 1; }
.brand p { margin: 0; font-size: 15px; opacity: 0.8; }
.header-right { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.icon-btn:active { background: rgba(255, 255, 255, 0.12); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: #f3e3c3; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 640px; margin: 0 auto; padding: 18px 16px 60px; }
.view { animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

h2.ink { font-family: "Caveat", cursive; font-weight: 700; font-size: 34px; color: #1d120a; line-height: 1.15; margin: 8px 0 6px; }
.hand { font-family: "Caveat", cursive; font-size: 22px; color: var(--ink-soft); margin: 6px 0 10px; line-height: 1.2; }
.addr { color: var(--faded); margin: 0 0 12px; font-size: 18px; }
.small { font-size: 17px; color: var(--faded); }

/* Search */
#search, #key-input, #jina-input, textarea, .drink-label {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 6px;
  background: rgba(255, 252, 240, 0.6); outline: none;
}
#search:focus, #key-input:focus, textarea:focus { border-color: var(--ink-soft); }
.results { list-style: none; padding: 0; margin: 10px 0; }
.results li button {
  width: 100%; text-align: left; padding: 11px 6px; border: 0; border-bottom: 1px dashed var(--line); background: transparent;
}
.results li button:active { background: rgba(122, 46, 31, 0.08); }
.results b { font-weight: 600; }
.results span { display: block; color: var(--faded); font-size: 17px; }
.results .none { color: var(--faded); padding: 8px 2px; }

/* Buttons */
.ink-btn {
  display: block; width: 100%; margin: 14px 0 0; padding: 12px; text-align: center;
  border: 1.5px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--paper);
  font-size: 22px;
}
.ink-btn.ghost { background: transparent; color: var(--ink); border-style: dashed; }
.ink-btn:active { transform: translateY(1px); }
.link-btn { border: 0; background: none; padding: 4px 0; color: var(--ink-soft); }
.link-btn.danger { color: var(--accent); }
.mini { border: 1px solid var(--line); background: rgba(255, 252, 240, 0.7); border-radius: 4px; padding: 3px 9px; font-size: 14px; }

/* Status / loading */
.status { font-family: "Caveat", cursive; font-size: 23px; color: var(--ink-soft); min-height: 4px; }
.status .dots-loading::after { content: ""; animation: dotdot 1.2s steps(4) infinite; }
@keyframes dotdot { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.favorite { border: 1.5px dashed var(--accent); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; color: var(--accent); font-family: "Caveat", cursive; font-size: 21px; }

/* The three pick cards: specimen labels pinned in the journal */
.cards { display: grid; gap: 14px; }
.card {
  position: relative; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: rgba(255, 251, 238, 0.75); box-shadow: 2px 3px 0 rgba(43, 29, 18, 0.12);
  animation: pin 0.45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.card:nth-child(2) { animation-delay: 0.12s; transform: rotate(0.4deg); }
.card:nth-child(3) { animation-delay: 0.24s; transform: rotate(-0.5deg); }
@keyframes pin { from { opacity: 0; transform: translateY(14px) rotate(-2deg); } }
.card .kind { font-size: 19px; color: var(--accent); margin: 0; letter-spacing: 0.03em; }
.card h3 { font-family: "Caveat", cursive; font-weight: 700; font-size: 29px; color: #1d120a; margin: 0 0 2px; line-height: 1.15; }
.card .desc { margin: 4px 0; }
.card .why { color: var(--ink-soft); margin: 4px 0; }
.card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 15px; color: var(--faded); }
.rarity { display: inline-flex; gap: 3px; align-items: center; }
.rarity i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--ink-soft); display: inline-block; }
.rarity i.on { background: var(--ink-soft); }
.card .have { margin-top: 10px; font-size: 17px; padding: 8px; }

/* Flavor chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px dashed var(--ink-soft); border-radius: 999px; background: transparent; padding: 5px 13px; font-family: "Caveat", cursive; font-size: 20px; }
.chip.on { background: var(--ink); color: var(--paper); border-style: solid; }

/* Journal list: a scrapbook */
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-top: 18px; }
.entry { background: rgba(255, 251, 238, 0.8); border: 1px solid var(--line); padding: 10px; box-shadow: 2px 3px 0 rgba(43, 29, 18, 0.1); }
.entry:nth-child(odd) { transform: rotate(-0.8deg); }
.entry:nth-child(even) { transform: rotate(0.7deg); }
.entry .pic { aspect-ratio: 1; background: #fffaf0; border: 6px solid #fffaf0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); display: grid; place-items: center; overflow: hidden; }
.entry .pic img, .entry .pic .sketch { width: 100%; height: 100%; object-fit: cover; }
.entry h4 { font-family: "Caveat", cursive; font-weight: 700; font-size: 22px; color: #1d120a; margin: 8px 0 0; line-height: 1.1; }
.entry .where { font-size: 16px; color: var(--faded); }
.entry .scrib { width: 100%; display: block; margin-top: 4px; }
.entry .score { font-family: "Caveat", cursive; font-size: 24px; color: var(--accent); }
.entry .note { font-family: "Caveat", cursive; font-size: 19px; color: var(--ink-soft); line-height: 1.1; }
.entry .del { float: right; font-size: 13px; }
.empty { font-family: "Caveat", cursive; font-size: 22px; color: var(--faded); text-align: center; margin-top: 30px; }

/* The journal book that opens and closes */
.book-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(30, 20, 12, 0.55); overflow-y: auto; }
.book { position: relative; width: min(560px, 100%); perspective: 1600px; }
.page {
  position: relative; padding: 22px 18px 18px; border-radius: 4px 10px 10px 4px;
  background: var(--noise), linear-gradient(90deg, #e6d6b2, var(--paper) 6%, var(--paper) 94%, #e8d8b4);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 8px 0 14px -8px rgba(60, 40, 20, 0.5);
}
.cover {
  position: absolute; inset: -6px; border-radius: 6px 12px 12px 6px; transform-origin: left center;
  display: grid; place-items: center; backface-visibility: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); border: 2px dashed rgba(243, 227, 195, 0.3);
  transition: transform 0.75s cubic-bezier(.6, .05, .3, 1);
}
.cover-title { font-family: "Caveat", cursive; font-weight: 700; font-size: 58px; }
.cover .key { position: absolute; right: 18px; top: 50%; width: 70px; fill: none; stroke: var(--brass); stroke-width: 2.4; }
.book.open .cover { transform: rotateY(-178deg); pointer-events: none; }
.close { position: absolute; top: 6px; right: 10px; border: 0; background: none; font-size: 28px; color: var(--ink-soft); }
.drink-label { font-family: "Caveat", cursive; font-weight: 700; font-size: 28px; background: transparent; border: 0; border-bottom: 1.5px solid var(--line); border-radius: 0; padding: 4px 2px; margin-right: 26px; width: calc(100% - 26px); }
.page-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.polaroid { width: 150px; flex: none; background: #fffaf0; padding: 7px 7px 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transform: rotate(-2deg); }
.polaroid video { filter: grayscale(1) sepia(0.9) contrast(0.95) brightness(1.02); }
.polaroid video, .polaroid img, .polaroid .sketch { width: 136px; height: 136px; object-fit: cover; display: block; background: #2a2018; }
.sketch svg { width: 100%; height: 100%; display: block; }
.sketch { background: #fffaf0 !important; fill: none; stroke: var(--ink-soft); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cam-btns { display: flex; gap: 6px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.rating-box { flex: 1; min-width: 170px; }
.rating-box .hand { margin: 0 0 4px; }
#scribble { width: 100%; height: 120px; border: 1.5px dashed var(--line); border-radius: 4px; background: rgba(255, 252, 240, 0.5); touch-action: none; display: block; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots button { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--ink-soft); background: transparent; font-family: "Caveat", cursive; font-size: 19px; padding: 0; }
.dots button.on { background: var(--ink); color: var(--paper); }
textarea { margin-top: 12px; font-family: "Caveat", cursive; font-size: 21px; resize: vertical; }

/* Settings */
dialog { width: min(480px, calc(100% - 32px)); border: 0; border-radius: 8px; padding: 18px 20px; color: var(--ink); background: var(--noise), var(--paper); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); }
dialog::backdrop { background: rgba(30, 20, 12, 0.55); }
dialog a { color: var(--accent); }
.dialog-btns { display: flex; gap: 14px; align-items: center; }
.dialog-btns .ink-btn { width: auto; padding: 8px 22px; margin-top: 12px; }
hr { border: 0; border-top: 1px dashed var(--line); margin: 16px 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 10px 20px; border-radius: 999px;
  font-family: "Caveat", cursive; font-size: 22px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); animation: fade 0.3s ease;
}

/* Welcome quiz: a full journal page, one question at a time */
.quiz-overlay { position: fixed; inset: 0; z-index: 25; overflow-y: auto; background: var(--noise), radial-gradient(ellipse at 50% 0%, var(--paper) 40%, var(--paper-dark) 100%); }
.quiz-page { max-width: 560px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 20px 40px; animation: fade 0.35s ease; }
.quiz-page h2.ink { font-size: 38px; }
.quiz-page.done { text-align: center; padding-top: 22vh; }
.hand.big { font-size: 27px; color: var(--ink); }
.quiz-dots { display: flex; gap: 6px; margin-bottom: 18px; }
.quiz-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink-soft); }
.quiz-dots i.done { background: var(--ink-soft); }
.quiz-dots i.now { background: var(--accent); border-color: var(--accent); transform: scale(1.25); }
.quiz-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 6px; }
.chip.big { font-size: 24px; padding: 8px 18px; transition: transform 0.15s; }
.chip.big:active { transform: scale(0.95); }
.chip.big.on { transform: rotate(-1.5deg); }
.quiz-input { width: 100%; margin-top: 16px; padding: 10px 4px; border: 0; border-bottom: 2px solid var(--ink-soft); background: transparent; font-family: "Caveat", cursive; font-weight: 700; font-size: 40px; outline: none; }
.quiz-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 26px; }
.quiz-nav .ink-btn { width: auto; min-width: 140px; margin: 0; padding: 10px 26px; }
.quiz-skip { display: block; margin: 26px auto 0; color: var(--faded); }
#dev-keys .ink-btn { width: auto; padding: 8px 22px; }
#feedback .chips { margin-bottom: 4px; }
#feedback textarea { margin-top: 2px; }
.drink-label { resize: none; field-sizing: content; line-height: 1.15; overflow: hidden; }
