/* ============================================================
   Call2Learn — Notes & Print Portal
   Design language: a phone call becomes a paper record. The visual
   anchor is a "call receipt" — a perforated ticket stub, dot-matrix
   texture, timestamped like a printout — because that is literally
   what this screen produces. Dark indigo (the call/night-time end of
   the product) meets a warm marigold accent (the paper/print end).
   ============================================================ */

:root {
  --ink:        #f4efe4;
  --ink-dim:    #b9b3c9;
  --night:      #191333;
  --night-2:    #221a44;
  --card:       #241c48;
  --card-line:  #382d63;
  --marigold:   #f2a33e;
  --marigold-2: #d97f1f;
  --paper:      #f4efe4;
  --paper-line: #d8cfb8;
  --paper-text: #241c48;
  --good:       #6fbf8b;
  --warn:       #e0995a;
  --danger:     #d9685f;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

@font-face {
  font-family: "Fraunces";
  src: local("Georgia");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(242, 163, 62, 0.10), transparent 45%),
    radial-gradient(circle at 85% 92%, rgba(111, 191, 139, 0.08), transparent 40%);
}

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

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* --- Header --- */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.top .mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--marigold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--night);
  flex-shrink: 0;
}

.top .brand {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.01em;
}

.top .brand span { color: var(--marigold); }

/* --- Receipt card: the signature element --- */

.receipt {
  background: var(--paper);
  color: var(--paper-text);
  border-radius: 4px;
  padding: 36px 28px 28px;
  position: relative;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.55);
}

.receipt::before,
.receipt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;
  background:
    radial-gradient(circle 7px at 10px 0, var(--night) 99%, transparent 100%) repeat-x;
  background-size: 24px 14px;
}
.receipt::before { top: -7px; }
.receipt::after   { bottom: -7px; transform: rotate(180deg); }

.receipt .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--marigold-2);
  margin: 0 0 6px;
}

.receipt h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 4px;
  line-height: 1.2;
}

.receipt p.sub {
  margin: 0 0 24px;
  color: #5b5378;
  font-size: 14px;
}

/* --- Code input --- */

.code-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 16px 12px;
  border: 2px dashed var(--paper-line);
  border-radius: 4px;
  background: #fffdf8;
  color: var(--paper-text);
  outline: none;
}
.code-input:focus { border-color: var(--marigold-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 18px;
  border: none;
  border-radius: 4px;
  background: var(--night);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: var(--night-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-accent {
  background: var(--marigold);
  color: var(--night);
}
.btn-accent:hover { background: var(--marigold-2); }

.error-msg {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  font-family: var(--font-mono);
}

.hint {
  margin-top: 18px;
  font-size: 12px;
  color: #7a7196;
  text-align: center;
}

/* --- Notes list page --- */

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.note-card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 8px;
  padding: 16px 16px 16px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.note-card:hover { border-color: var(--marigold); }
.note-card.checked { border-color: var(--marigold); background: #2b2154; }

.note-card .check {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid var(--card-line);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--night);
}
.note-card.checked .check {
  background: var(--marigold);
  border-color: var(--marigold);
}

.note-card .body { flex: 1; }
.note-card .type-label {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--marigold);
  margin-bottom: 3px;
}
.note-card h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 17px;
}
.note-card .view-link {
  font-size: 13px;
  color: var(--ink-dim);
  text-decoration: underline;
}

.print-bar {
  position: sticky;
  bottom: 16px;
  margin-top: 24px;
  background: var(--marigold);
  color: var(--night);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.6);
}
.print-bar button {
  background: var(--night);
  color: var(--paper);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.print-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.print-bar .count { font-family: var(--font-mono); font-size: 13px; }

/* --- Note detail view --- */

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.back-link {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-mono);
}

.note-content {
  background: var(--paper);
  color: var(--paper-text);
  border-radius: 8px;
  padding: 24px;
  line-height: 1.65;
}
.note-content h1, .note-content h2, .note-content h3 { font-family: var(--font-display); }
.note-content pre {
  background: #ece5d3;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
}
.note-content code { font-family: var(--font-mono); font-size: 0.9em; }
.note-content .mermaid {
  background: #fffdf8;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  padding: 12px;
  margin-top: 16px;
}

.loading {
  text-align: center;
  padding: 40px 0;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-dim);
}
.empty-state h2 { font-family: var(--font-display); color: var(--ink); }

/* --- Print output --- */

#print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }
  .print-section {
    page-break-after: always;
    break-after: page;
    padding: 24px;
  }
  .print-section:last-child { page-break-after: auto; break-after: auto; }
  .print-section h1 { font-family: Georgia, serif; }

  /* Keep summary points readable instead of collapsing the list into a paragraph. */
  .print-summary ul,
  .print-summary ol {
    margin: 0.5em 0 0.9em;
    padding-left: 1.5em;
  }
  .print-summary li {
    margin: 0 0 0.65em;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* A flowchart gets its own page and is kept as one printable image. */
  .print-flowchart-page {
    page-break-before: always;
    break-before: page;
    page-break-after: always;
    break-after: page;
    min-height: 9.5in;
    box-sizing: border-box;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-flowchart-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .print-flowchart-page .flowchart-print-placeholder {
    width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-flowchart-page .mermaid-print-image {
    display: block !important;
    visibility: visible !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: 8.9in !important;
    height: auto !important;
    margin: 0 auto;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

@media (max-width: 420px) {
  .receipt { padding: 28px 18px 20px; }
  .code-input { font-size: 18px; letter-spacing: 0.2em; }
}
