/*
 * Victorian Formula Compendium — compendium.css
 * OutPost51X | Vintage book typography, aged paper aesthetic
 */

@import url('https://fonts.googleapis.com/css2?family=IM+Fell+English:ital@0;1&family=IM+Fell+English+SC&family=Cinzel+Decorative:wght@400;700&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Variables ─────────────────────────────────────── */
#vfc-root.vfc-wrap {
  --vfc-paper:       #f5f0e8;
  --vfc-paper2:      #ede8db;
  --vfc-paper3:      #e4ddd0;
  --vfc-ink:         #1c1208;
  --vfc-ink2:        #3a2e1c;
  --vfc-ink3:        #6b5a3e;
  --vfc-ink4:        #9a8060;
  --vfc-rule:        #8b7040;
  --vfc-rule2:       #c4a96a;
  --vfc-accent:      #7a2020;
  --vfc-accent2:     #c04020;
  --vfc-gold:        #b8860b;
  --vfc-blue:        #1a3a5c;
  --vfc-border:      #c4a96a;
  --vfc-shadow:      rgba(60,40,10,0.18);

  --vfc-font-title:  'Cinzel Decorative', serif;
  --vfc-font-head:   'IM Fell English SC', serif;
  --vfc-font-body:   'IM Fell English', serif;
  --vfc-font-alt:    'Libre Baskerville', serif;

  background: var(--vfc-paper);
  color: var(--vfc-ink);
  font-family: var(--vfc-font-body);
  border: 2px solid var(--vfc-border);
  border-radius: 2px;
  max-width: 1100px;
  margin: 0 auto;
  box-shadow: 0 4px 32px var(--vfc-shadow), inset 0 0 80px rgba(180,140,60,0.06);
  position: relative;
  overflow: hidden;
}

/* Aged paper texture overlay */
#vfc-root.vfc-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(180,140,60,0.04) 28px,
      rgba(180,140,60,0.04) 29px
    );
  pointer-events: none;
  z-index: 0;
}

/* ── Book Cover ─────────────────────────────────────── */
.vfc-cover {
  text-align: center;
  padding: 2.5rem 2rem 1.75rem;
  background: linear-gradient(180deg, #1c1208 0%, #2c1e0a 40%, #1c1208 100%);
  color: var(--vfc-paper);
  position: relative;
  overflow: hidden;
}

.vfc-cover::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(196,169,106,0.3);
  pointer-events: none;
}

.vfc-cover::after {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(196,169,106,0.15);
  pointer-events: none;
}

.vfc-cover-ornament {
  font-size: 0.75rem;
  letter-spacing: 0.5em;
  color: var(--vfc-rule2);
  margin-bottom: 0.75rem;
}

.vfc-cover-rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--vfc-rule2) 20%, var(--vfc-gold) 50%, var(--vfc-rule2) 80%, transparent);
  margin: 0.6rem auto;
  max-width: 480px;
}

.vfc-cover-rule-thin {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--vfc-rule2) 30%, var(--vfc-rule2) 70%, transparent);
  max-width: 320px;
}

.vfc-cover-title {
  font-family: var(--vfc-font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--vfc-gold);
  line-height: 1.4;
  letter-spacing: 0.06em;
  margin: 0.5rem 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.vfc-cover-subtitle {
  font-family: var(--vfc-font-head);
  font-size: 0.78rem;
  color: var(--vfc-paper2);
  letter-spacing: 0.06em;
  line-height: 1.7;
  margin: 0.3rem 0;
}

.vfc-cover-edition {
  font-family: var(--vfc-font-alt);
  font-size: 0.65rem;
  color: var(--vfc-ink4);
  letter-spacing: 0.08em;
  margin-top: 0.5rem;
  font-style: italic;
}

.vfc-cover-categories {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.vfc-cat-badge {
  font-family: var(--vfc-font-head);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.6rem;
  border: 1px solid;
  border-radius: 1px;
}

.vfc-cat-domestic   { color: #a8c8a8; border-color: #a8c8a8; }
.vfc-cat-cosmetics  { color: #e8b8c8; border-color: #e8b8c8; }
.vfc-cat-industrial { color: #b8c8e8; border-color: #b8c8e8; }
.vfc-cat-medical    { color: #e8d8a8; border-color: #e8d8a8; }

/* ── Search Bar ─────────────────────────────────────── */
.vfc-search-bar {
  background: var(--vfc-paper3);
  border-bottom: 2px solid var(--vfc-border);
  padding: 0.6rem 1rem;
  position: relative;
  z-index: 1;
}

.vfc-search-inner {
  display: flex;
  align-items: center;
  background: var(--vfc-paper);
  border: 1px solid var(--vfc-border);
  border-radius: 1px;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
}

.vfc-search-icon {
  color: var(--vfc-ink4);
  padding: 0 0.6rem;
  font-size: 1.1rem;
  flex-shrink: 0;
}

#vfc-root .vfc-search-input,
#vfc-root input.vfc-search-input {
  flex: 1;
  background: transparent !important;
  background-image: none !important;
  border: none !important;
  outline: none !important;
  color: var(--vfc-ink) !important;
  -webkit-text-fill-color: var(--vfc-ink) !important;
  font-family: var(--vfc-font-alt) !important;
  font-size: 0.85rem !important;
  font-style: italic !important;
  padding: 0.5rem 0 !important;
  box-shadow: none !important;
}

#vfc-root input.vfc-search-input::placeholder {
  color: var(--vfc-ink4) !important;
  -webkit-text-fill-color: var(--vfc-ink4) !important;
  font-style: italic !important;
}

.vfc-search-clear {
  background: transparent;
  border: none;
  color: var(--vfc-ink4);
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  font-size: 0.75rem;
  transition: color 0.15s;
}
.vfc-search-clear:hover { color: var(--vfc-accent); }

/* ── Main Body Layout ───────────────────────────────── */
.vfc-body {
  display: flex;
  min-height: 600px;
  position: relative;
  z-index: 1;
}

/* ── Index Panel ────────────────────────────────────── */
.vfc-index {
  width: 240px;
  flex-shrink: 0;
  border-right: 2px solid var(--vfc-border);
  background: var(--vfc-paper2);
  display: flex;
  flex-direction: column;
}

.vfc-index-header {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--vfc-border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: var(--vfc-paper3);
}

.vfc-index-title {
  font-family: var(--vfc-font-head);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--vfc-ink2);
  text-transform: uppercase;
}

.vfc-index-count {
  font-family: var(--vfc-font-alt);
  font-size: 0.65rem;
  color: var(--vfc-ink4);
  font-style: italic;
}

/* A–Z Nav */
.vfc-alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--vfc-border);
  background: var(--vfc-paper3);
}

.vfc-alpha-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 1px;
  color: var(--vfc-ink3);
  font-family: var(--vfc-font-head);
  font-size: 0.68rem;
  padding: 0.18rem 0.32rem;
  cursor: pointer;
  transition: all 0.12s;
  letter-spacing: 0.04em;
  min-width: 20px;
  text-align: center;
}

.vfc-alpha-btn:hover {
  background: var(--vfc-paper);
  border-color: var(--vfc-border);
  color: var(--vfc-ink);
}

.vfc-alpha-btn.vfc-alpha-active {
  background: var(--vfc-accent);
  border-color: var(--vfc-accent);
  color: var(--vfc-paper);
}

.vfc-alpha-btn.vfc-alpha-empty {
  color: var(--vfc-paper3);
  cursor: default;
  pointer-events: none;
}

/* Formula List */
.vfc-formula-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.vfc-letter-group {
  margin-bottom: 0.25rem;
}

.vfc-letter-heading {
  font-family: var(--vfc-font-title);
  font-size: 0.8rem;
  color: var(--vfc-gold);
  padding: 0.3rem 0.9rem 0.15rem;
  background: var(--vfc-paper3);
  border-top: 1px solid var(--vfc-border);
  border-bottom: 1px solid rgba(196,169,106,0.3);
  letter-spacing: 0.1em;
  position: sticky;
  top: 0;
}

.vfc-formula-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(196,169,106,0.2);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s;
}

.vfc-formula-item:hover {
  background: var(--vfc-paper);
}

.vfc-formula-item.vfc-item-active {
  background: var(--vfc-paper);
  border-left: 3px solid var(--vfc-accent);
  padding-left: calc(0.9rem - 3px);
}

.vfc-item-title {
  display: block;
  font-family: var(--vfc-font-body);
  font-size: 0.82rem;
  color: var(--vfc-ink2);
  line-height: 1.3;
}

.vfc-item-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 2px;
}

.vfc-item-no {
  font-family: var(--vfc-font-alt);
  font-size: 0.6rem;
  color: var(--vfc-ink4);
  font-style: italic;
}

.vfc-item-cat {
  font-family: var(--vfc-font-head);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  padding: 0.08rem 0.3rem;
  border-radius: 1px;
}

.vfc-item-cat[data-cat="Domestic"]   { background: rgba(100,160,100,0.15); color: #3a6a3a; }
.vfc-item-cat[data-cat="Cosmetics"]  { background: rgba(180,80,120,0.12);  color: #8a3050; }
.vfc-item-cat[data-cat="Industrial"] { background: rgba(40,80,140,0.12);   color: #1a3a6a; }
.vfc-item-cat[data-cat="Medical"]    { background: rgba(160,120,30,0.15);  color: #6a4a10; }

/* ── Detail Panel ───────────────────────────────────── */
.vfc-detail {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: 800px;
}

/* Welcome -->*/
.vfc-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  padding: 3rem 2rem;
  text-align: center;
}

.vfc-welcome-ornament {
  font-size: 3rem;
  color: var(--vfc-ink4);
  margin-bottom: 1rem;
  opacity: 0.4;
}

.vfc-welcome-title {
  font-family: var(--vfc-font-head);
  font-size: 1.1rem;
  color: var(--vfc-ink3);
  letter-spacing: 0.1em;
  margin: 0 0 0.75rem;
}

.vfc-welcome-text {
  font-family: var(--vfc-font-body);
  font-size: 0.88rem;
  color: var(--vfc-ink3);
  line-height: 1.75;
  max-width: 380px;
  font-style: italic;
}

.vfc-welcome-rule {
  width: 80px;
  height: 1px;
  background: var(--vfc-border);
  margin: 1rem auto;
}

.vfc-welcome-hint {
  font-family: var(--vfc-font-alt);
  font-size: 0.75rem;
  color: var(--vfc-ink4);
  font-style: italic;
}

/* Formula Page -->*/
.vfc-page {
  padding: 2rem 2.5rem 1.5rem;
  max-width: 680px;
  margin: 0 auto;
}

/* Page header/footer rules */
.vfc-page-header,
.vfc-page-footer {
  margin-bottom: 1.25rem;
}

.vfc-page-toprule {
  height: 0;
  border-top: 3px double var(--vfc-rule);
  margin: 0 0 0.4rem;
}

.vfc-page-midrule {
  height: 0;
  border-top: 1px solid var(--vfc-rule2);
  margin: 0.5rem 0;
}

.vfc-page-header-text {
  text-align: center;
  padding: 0.2rem 0;
}

.vfc-page-bookname {
  display: block;
  font-family: var(--vfc-font-head);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--vfc-ink2);
  margin-bottom: 0.2rem;
}

.vfc-page-edition {
  display: block;
  font-family: var(--vfc-font-body);
  font-size: 0.67rem;
  font-style: italic;
  color: var(--vfc-ink4);
  letter-spacing: 0.04em;
}

/* Entry -->*/
.vfc-entry-meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.vfc-entry-no {
  font-family: var(--vfc-font-body);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--vfc-ink4);
}

.vfc-entry-category {
  font-family: var(--vfc-font-head);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--vfc-border);
  color: var(--vfc-ink3);
}

.vfc-entry-source {
  font-family: var(--vfc-font-alt);
  font-size: 0.65rem;
  font-style: italic;
  color: var(--vfc-ink4);
}

.vfc-entry-title {
  font-family: var(--vfc-font-head);
  font-size: 1.25rem;
  color: var(--vfc-ink);
  margin: 0 0 1rem;
  line-height: 1.3;
  letter-spacing: 0.02em;
  border-bottom: 1px dotted var(--vfc-rule2);
  padding-bottom: 0.6rem;
}

/* Sections -->*/
.vfc-section {
  margin-bottom: 1.1rem;
}

.vfc-section-head {
  font-family: var(--vfc-font-head);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--vfc-accent);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.vfc-section-body {
  font-family: var(--vfc-font-body);
  font-size: 0.92rem;
  line-height: 1.85;
  color: var(--vfc-ink2);
  text-align: justify;
  hyphens: auto;
  margin: 0;
}

.vfc-cautions {
  background: rgba(122,32,32,0.04);
  border-left: 3px solid var(--vfc-accent);
  padding: 0.5rem 0.75rem;
  border-radius: 1px;
}

/* Ingredients Table -->*/
.vfc-ingredients-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--vfc-font-body);
  font-size: 0.85rem;
  margin: 0.25rem 0;
}

.vfc-ingredients-table tr {
  border-bottom: 1px dotted var(--vfc-rule2);
}

.vfc-ingredients-table tr:last-child {
  border-bottom: none;
}

.vfc-ingredients-table td {
  padding: 0.3rem 0.5rem;
  vertical-align: top;
}

.vfc-ingredients-table td:first-child {
  color: var(--vfc-ink2);
  width: 65%;
}

.vfc-ingredients-table td:last-child {
  color: var(--vfc-ink4);
  font-style: italic;
  text-align: right;
  white-space: nowrap;
}

/* Colophon -->*/
.vfc-colophon {
  text-align: center;
  font-family: var(--vfc-font-body);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--vfc-ink4);
  margin: 1.25rem 0 0.5rem;
  letter-spacing: 0.06em;
}

/* Page Footer -->*/
.vfc-page-footnote {
  text-align: center;
  font-family: var(--vfc-font-alt);
  font-size: 0.62rem;
  color: var(--vfc-ink4);
  letter-spacing: 0.05em;
  margin: 0.4rem 0 0.75rem;
  font-style: italic;
}

.vfc-page-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* Buttons -->*/
.vfc-btn {
  background: transparent;
  border: 1px solid var(--vfc-border);
  border-radius: 1px;
  color: var(--vfc-ink3);
  font-family: var(--vfc-font-head);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

.vfc-btn:hover {
  background: var(--vfc-ink2);
  color: var(--vfc-paper);
  border-color: var(--vfc-ink2);
}

.vfc-btn-print {
  border-color: var(--vfc-accent);
  color: var(--vfc-accent);
}

.vfc-btn-print:hover {
  background: var(--vfc-accent);
  color: var(--vfc-paper);
}

/* Loading -->*/
.vfc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 200px;
  font-family: var(--vfc-font-body);
  font-style: italic;
  color: var(--vfc-ink4);
  font-size: 0.9rem;
}

.vfc-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--vfc-rule2);
  border-top-color: var(--vfc-accent);
  border-radius: 50%;
  animation: vfc-spin 0.9s linear infinite;
}

@keyframes vfc-spin { to { transform: rotate(360deg); } }

/* No results -->*/
.vfc-no-results {
  padding: 1.5rem;
  text-align: center;
  font-family: var(--vfc-font-body);
  font-style: italic;
  color: var(--vfc-ink4);
  font-size: 0.88rem;
}

/* ── Print Popup ────────────────────────────────────── */
@media print {
  .vfc-cover, .vfc-search-bar, .vfc-index,
  .vfc-page-actions, .vfc-loading { display: none !important; }
  .vfc-detail { max-height: none; overflow: visible; }
  .vfc-page { padding: 1cm; }
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 680px) {
  .vfc-body { flex-direction: column; }
  .vfc-index { width: 100%; border-right: none; border-bottom: 2px solid var(--vfc-border); }
  .vfc-formula-list { max-height: 240px; }
  .vfc-page { padding: 1.25rem 1rem; }
  .vfc-cover-title { font-size: 1.1rem; }
}
