/* ============================================
   Diary System — Detective's Notebook
   Scoped under #diaryPanel
   ============================================ */

/* fonts: css/fonts.css (shipped with the game) */

@keyframes diary-fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes diary-slideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes diary-fd { from { opacity: 0; } to { opacity: 1; } }

/* === OVERLAY (dossier palette) === */
#diaryPanel {
  position: fixed; inset: 0;
  background: rgba(58, 50, 56, 0.92); /* dossier overlay scrim */
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: diary-fadeIn 0.25s ease-out;

  --paper:           #EBE6D8;
  --paper-light:     #F2EDDF;
  --ink:             #3A3238;
  --ink-faded:       #5F5449;
  --ink-light:       #8E7F7F;
  --ink-muted:       #8E7F7F;
  --red-dark:        #8B0000;
  --red-light:       rgba(139, 0, 0, 0.10);
  --blue-pen:        #1b4fb0;
  --blue-pen-bg:     rgba(27, 79, 176, 0.08);
  --d-border:        rgba(142, 127, 127, 0.30);
  --d-border-strong: #8E7F7F;
  --highlight:       rgba(196, 168, 122, 0.18);
}

/* === DOSSIER DOCUMENT === */
#diaryPanel .diary-notebook {
  position: relative;
  width: 1100px;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--paper);
  border: 1px solid var(--d-border-strong);
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'Courier Prime', 'Courier New', monospace;
  color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: diary-slideIn 0.4s ease-out;
  /* Dossier paper — faint horizontal rule lines, same as v4 */
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 28px,
    rgba(142, 127, 127, 0.04) 28px, rgba(142, 127, 127, 0.04) 29px);
}

/* Noise / stains / margin line / coffee ring dropped — dossier paper is
 * clean, the rule-line gradient on the container is the only texture. */
#diaryPanel .diary-notebook::before,
#diaryPanel .diary-notebook::after,
#diaryPanel .diary-ruled-lines,
#diaryPanel .diary-margin-line,
#diaryPanel .diary-coffee-ring {
  content: none;
  display: none;
}

/* Close button */
#diaryPanel .diary-close-btn {
  position: absolute; top: 16px; right: 16px;
  background: none; border: 1px solid var(--d-border-strong);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 11px; color: var(--ink-faded);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 4px 12px; cursor: pointer; z-index: 5;
  transition: all 0.2s;
}
#diaryPanel .diary-close-btn:hover {
  color: var(--red-dark); border-color: var(--red-dark);
  background: var(--red-light);
}

/* Content wrapper — dossier padding (no left-side margin offset) */
#diaryPanel .diary-content-wrap {
  position: relative; z-index: 1;
  padding: 1.5rem 2rem 2rem;
}

/* === HEADER (dossier-style) === */
#diaryPanel .diary-hdr-top {
  display: block; text-align: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
}
#diaryPanel .diary-hdr-label {
  display: inline-block;
  background: var(--red-dark);
  color: var(--paper);
  padding: 0.3rem 1rem;
  font-size: 0.7rem; letter-spacing: 3px;
  text-transform: uppercase; font-weight: bold;
  margin-bottom: 0.5rem;
}
#diaryPanel .diary-hdr-date {
  display: inline-block;
  font-size: 0.7rem; color: var(--ink-light);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: bold;
  border: none; padding: 0 0 0 1rem;
  vertical-align: middle;
}
#diaryPanel .diary-hdr-title {
  font-weight: bold; font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: 4px; text-transform: uppercase;
  margin: 0.3rem 0 0.8rem;
  text-align: center;
  line-height: 1.2;
}
#diaryPanel .diary-hdr-sep {
  border: none; border-top: 1px dashed var(--d-border-strong);
  margin-bottom: 1.2rem;
}

/* === STATS ROW === */
#diaryPanel .diary-stats-row {
  display: flex; gap: 24px; margin-bottom: 24px;
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 11px; color: var(--ink-light); letter-spacing: 1px;
}
#diaryPanel .diary-stats-row .sv {
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-weight: 700; color: var(--ink-faded);
  font-size: 13px; margin-left: 4px;
}

/* === TABS (dossier folder-tabs) === */
#diaryPanel .diary-tabs {
  display: flex;
  border-bottom: 2px solid var(--d-border-strong);
  background: rgba(212, 200, 190, 0.20);
  margin-bottom: 0;
  padding: 0 0.5rem;
}
#diaryPanel .diary-tab {
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ink-light); padding: 0.8rem 1.5rem;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer; transition: all 0.2s;
  font-weight: bold;
}
#diaryPanel .diary-tab:hover {
  color: var(--ink); background: none;
}
#diaryPanel .diary-tab.on {
  color: var(--ink); border-bottom-color: var(--red-dark);
}
#diaryPanel .diary-tab .n {
  font-size: 0.6rem; font-weight: bold;
  background: var(--red-dark); color: var(--paper);
  padding: 1px 5px; border-radius: 0;
  margin-left: 6px; vertical-align: top; letter-spacing: 1px;
}

/* === PANELS === */
#diaryPanel .diary-pan {
  display: none; padding-top: 24px;
}
#diaryPanel .diary-pan.on {
  display: block; animation: diary-fd 0.25s ease;
}

/* === SECTION LABELS (dossier .st style) === */
#diaryPanel .diary-sl {
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-weight: bold;
  font-size: 0.85rem; color: var(--ink);
  text-transform: uppercase; letter-spacing: 3px;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--d-border-strong);
  margin: 1.2rem 0 0.8rem;
  display: flex; align-items: center; gap: 10px;
}
#diaryPanel .diary-sl::before {
  content: '\25A0';
  font-size: 0.55rem;
  color: var(--red-dark);
}

/* === QUEST ROWS === */
#diaryPanel .diary-qr {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 11px 14px; margin-bottom: 0;
  cursor: pointer; transition: background 0.12s;
  border-left: 3px solid transparent;
  user-select: none;
}
#diaryPanel .diary-qr:hover { background: rgba(0,0,0,0.025); }
#diaryPanel .diary-qr.act {
  border-left-color: var(--blue-pen);
  background: var(--blue-pen-bg);
}
#diaryPanel .diary-qr.dn { opacity: 0.4; cursor: default; }
#diaryPanel .diary-qr.dn .diary-qt {
  text-decoration: line-through;
  text-decoration-color: var(--ink-light);
}
#diaryPanel .diary-qr.expanded { background: rgba(0,0,0,0.03); }

/* Checkbox */
#diaryPanel .diary-qc {
  width: 14px; height: 14px;
  border: 1.5px solid var(--ink-muted);
  border-radius: 1px; flex-shrink: 0; margin-top: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--red-dark);
}
#diaryPanel .diary-qr.dn .diary-qc::after {
  content: '\2715'; font-family: 'Caveat', cursive; font-weight: 700;
}
#diaryPanel .diary-qr.act .diary-qc { border-color: var(--blue-pen); }

/* Quest body */
#diaryPanel .diary-qb { flex: 1; min-width: 0; }
#diaryPanel .diary-qt {
  font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.4;
}
#diaryPanel .diary-qd {
  font-family: 'Caveat', cursive; font-size: 14.5px;
  color: var(--ink-faded); margin-top: 2px; line-height: 1.3;
}
#diaryPanel .diary-qm {
  display: flex; gap: 10px; margin-top: 6px;
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 10px; color: var(--ink-light);
  letter-spacing: .5px; align-items: center;
}

/* Tags */
#diaryPanel .diary-tg {
  padding: 1px 7px; border: 1px solid var(--d-border);
  font-size: 9px; letter-spacing: 1px;
}
#diaryPanel .diary-tg.u {
  border-color: var(--red-dark); color: var(--red-dark);
  background: var(--red-light);
}

/* Priority badges */
#diaryPanel .diary-qp {
  flex-shrink: 0;
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 9px; text-transform: uppercase;
  letter-spacing: 1.5px; padding: 3px 10px;
  align-self: flex-start; margin-top: 3px;
}
#diaryPanel .diary-qp.pc { background: var(--red-dark); color: var(--paper-light); }
#diaryPanel .diary-qp.ph { color: var(--red-dark); border: 1px solid var(--red-dark); }
#diaryPanel .diary-qp.pt { color: #6b6040; border: 1px solid rgba(107,96,64,0.5); background: rgba(196,168,122,0.12); font-style: italic; }
#diaryPanel .diary-qp.pn { color: var(--ink-light); border: 1px solid var(--d-border); }

/* === EXPAND PANEL (accordion) === */
#diaryPanel .diary-expand {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  opacity: 0; margin-left: 28px;
  border-left: 2px solid var(--d-border);
}
#diaryPanel .diary-expand.open { opacity: 1; }
#diaryPanel .diary-expand-inner { padding: 14px 0 18px 20px; }

#diaryPanel .diary-ex-sl {
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 10px; color: var(--red-dark);
  text-transform: uppercase; letter-spacing: 3px;
  margin-bottom: 8px; margin-top: 14px;
}
#diaryPanel .diary-ex-sl:first-child { margin-top: 0; }

/* Full report content */
#diaryPanel .diary-ex-content {
  font-size: 12px; color: var(--ink-faded);
  line-height: 1.6; white-space: pre-line;
  padding: 4px 0 10px 0;
}

/* Task list items inside content */
#diaryPanel .diary-ex-content .task-list {
  margin: 6px 0;
  white-space: normal;
}
#diaryPanel .diary-ex-content .task-item {
  padding: 3px 0 3px 22px;
  position: relative;
  font-size: 12px;
  line-height: 1.5;
}
#diaryPanel .diary-ex-content .task-item::before {
  content: '\25CB'; position: absolute; left: 0;
  color: var(--ink-muted); font-size: 10px; top: 5px;
}

/* Handwritten note block */
#diaryPanel .diary-ex-note {
  font-family: 'Caveat', cursive; font-size: 15px;
  color: var(--blue-pen); padding: 10px 14px;
  margin-top: 10px; background: var(--blue-pen-bg);
  border-left: 2px solid rgba(26,42,80,0.22);
  line-height: 1.5;
}

/* Rewards row */
#diaryPanel .diary-ex-rew {
  display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap;
}
#diaryPanel .diary-ex-rew span {
  font-size: 10px; color: var(--ink-faded);
  padding: 4px 10px; border: 1px solid var(--d-border);
  background: rgba(0,0,0,0.015);
}

/* Objectives list */
#diaryPanel .diary-ex-ol { list-style: none; padding: 0; }
#diaryPanel .diary-ex-ol li {
  font-size: 12px; color: var(--ink-faded);
  padding: 5px 0 5px 22px; position: relative;
  line-height: 1.5; border-bottom: 1px solid rgba(90,75,55,0.06);
}
#diaryPanel .diary-ex-ol li::before {
  content: '\25CB'; position: absolute; left: 0;
  color: var(--ink-muted); font-size: 10px; top: 7px;
}
#diaryPanel .diary-ex-ol li.x { opacity: 0.35; text-decoration: line-through; }
#diaryPanel .diary-ex-ol li.x::before { content: '\25CF'; color: var(--red-dark); }

/* === CHARACTER CARDS === */
#diaryPanel .diary-cg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
#diaryPanel .diary-cc {
  border: 1px solid var(--d-border); padding: 16px 18px;
  cursor: pointer; transition: all 0.15s;
  position: relative; background: transparent;
}
#diaryPanel .diary-cc:hover {
  background: rgba(0,0,0,0.02); border-color: var(--d-border-strong);
}
#diaryPanel .diary-cc.expanded {
  background: rgba(0,0,0,0.03); border-color: var(--d-border-strong);
}
#diaryPanel .diary-cc::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
#diaryPanel .diary-cc.tc::before { background: #5a7a9a; }
#diaryPanel .diary-cc.tn::before { background: #8a8a6a; }
#diaryPanel .diary-cc.tw::before { background: #9a6a3a; }
#diaryPanel .diary-cc.th::before { background: var(--red-dark); }
#diaryPanel .diary-cc.tl::before { background: #aaa49a; }

#diaryPanel .diary-ct {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 10px;
}
#diaryPanel .diary-cn { font-weight: 700; font-size: 14px; color: var(--ink); }
#diaryPanel .diary-ca {
  font-family: 'Caveat', cursive; font-size: 12.5px;
  color: var(--ink-light); margin-top: 1px;
}
#diaryPanel .diary-ctr { text-align: right; }
#diaryPanel .diary-ctl {
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 9px; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 1.5px;
}
#diaryPanel .diary-tbg {
  width: 56px; height: 3px; background: var(--d-border);
  border-radius: 1px; margin-top: 5px; overflow: hidden;
}
#diaryPanel .diary-tb { height: 100%; border-radius: 1px; }
#diaryPanel .diary-tb.cold { background: #5a7a9a; }
#diaryPanel .diary-tb.neut { background: #8a8a6a; }
#diaryPanel .diary-tb.warm { background: #9a6a3a; }
#diaryPanel .diary-tb.hot  { background: var(--red-dark); }

#diaryPanel .diary-cql {
  font-size: 11.5px; color: var(--ink-faded);
  line-height: 1.5; margin-bottom: 8px;
}
#diaryPanel .diary-cbt {
  display: flex; justify-content: space-between; align-items: center;
}
#diaryPanel .diary-cqn {
  font-family: 'Special Elite', 'Courier New', cursive;
  font-size: 10px; color: var(--ink-light);
}
#diaryPanel .diary-pip { display: flex; gap: 3px; }
#diaryPanel .diary-pip i {
  display: block; width: 8px; height: 8px;
  border: 1px solid var(--d-border-strong); border-radius: 1px;
  font-style: normal;
}
#diaryPanel .diary-pip i.d {
  background: var(--ink-light); border-color: var(--ink-light);
}
#diaryPanel .diary-pip i.c {
  border-color: var(--blue-pen);
  box-shadow: 0 0 0 1px rgba(26,42,80,0.3);
}

/* Character expand — spans full grid width */
#diaryPanel .diary-cc-expand-wrapper {
  grid-column: 1 / -1;
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  opacity: 0; border-left: 2px solid var(--d-border);
  margin-left: 4px;
}
#diaryPanel .diary-cc-expand-wrapper.open { opacity: 1; }
#diaryPanel .diary-cc-expand-inner { padding: 14px 0 18px 20px; }

/* Character expand entry */
#diaryPanel .diary-char-entry {
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(90,75,55,0.1);
}
#diaryPanel .diary-char-entry:last-child { border-bottom: none; }
#diaryPanel .diary-char-entry-date {
  font-size: 11px; color: var(--ink-light); margin-bottom: 4px;
}
#diaryPanel .diary-char-entry-title {
  font-weight: 700; font-size: 12px; margin-bottom: 4px;
}
#diaryPanel .diary-char-entry-body {
  font-size: 12px; color: var(--ink-faded); line-height: 1.5;
}

/* === EMPTY STATE === */
#diaryPanel .diary-empty {
  text-align: center; padding: 50px 20px;
  color: var(--ink-muted);
  font-family: 'Caveat', cursive;
  font-size: 16px; font-style: italic;
}

/* === SCROLLBAR === */
#diaryPanel .diary-notebook::-webkit-scrollbar { width: 5px; }
#diaryPanel .diary-notebook::-webkit-scrollbar-track { background: transparent; }
#diaryPanel .diary-notebook::-webkit-scrollbar-thumb {
  background: rgba(142,127,127,0.3); border-radius: 3px;
}

/* === RESPONSIVE === */
@media (max-width: 800px) {
  #diaryPanel .diary-cg { grid-template-columns: 1fr; }
  #diaryPanel .diary-content-wrap { padding-left: 32px; }
  #diaryPanel .diary-margin-line { display: none; }
  #diaryPanel .diary-tab { padding: 10px 14px 8px; font-size: 10px; letter-spacing: 1px; }
}
