/* =========================================================
   DESIGN TOKENS
   Ink:    #171310  (warm near-black, seperti tinta cetak)
   Paper:  #ece6d6  (kertas manga, hangat & sedikit abu)
   Red:    #c81d3a  (merah label tankobon / stempel hanko)
   Gold:   #d9a441  (aksen rating / highlight, dipakai sangat sedikit)
   Grey:   #57514a  (teks sekunder, garis halftone)
   ========================================================= */
:root {
  --ink: #171310;
  --paper: #ece6d6;
  --paper-alt: #e2dac4;
  --red: #c81d3a;
  --gold: #d9a441;
  --grey: #57514a;
  --line: rgba(23, 19, 16, 0.14);

  --font-display: 'Dela Gothic One', system-ui, sans-serif;
  --font-body: 'Zen Kaku Gothic New', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
  width: 100%;
}

img { max-width: 100%; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; text-decoration: none; }

/* Tekstur halftone dipakai berulang sebagai background-image data URI (dot grid) */
.halftone-bg {
  background-image: radial-gradient(var(--ink) 1px, transparent 1.4px);
  background-size: 10px 10px;
  opacity: 0.08;
}

/* =========================== HEADER =========================== */
.site-header {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--red);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.brand-mark {
  font-family: var(--font-display);
  font-size: 22px;
  background: var(--red);
  color: var(--paper);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transform: rotate(-4deg);
}
.brand-text {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.5px;
}
.brand-accent { color: var(--red); }

.header-search {
  display: flex;
  flex: 1;
  max-width: 420px;
  border: 2px solid var(--paper);
  border-radius: 4px;
  overflow: hidden;
}
.header-inner .autocomplete-wrapper {
  flex: 1;
  max-width: 420px;
}
.header-search input {
  flex: 1;
  border: none;
  background: var(--ink);
  color: var(--paper);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
.header-search input::placeholder { color: rgba(236,230,214,0.5); }
.header-search button {
  border: none;
  background: var(--red);
  color: var(--paper);
  width: 42px;
  font-size: 16px;
  cursor: pointer;
}
.header-search button:hover { background: #a91630; }

/* =========================== HERO =========================== */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  padding: 72px 24px 88px;
  border-bottom: 6px solid var(--ink);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--paper) 1px, transparent 1.4px);
  background-size: 14px 14px;
  opacity: 0.06;
  pointer-events: none;
}
.hero::after {
  /* garis kecepatan / speed lines khas panel aksi manga */
  content: "";
  position: absolute;
  top: -20%;
  right: -10%;
  width: 70%;
  height: 140%;
  background: repeating-linear-gradient(
    100deg,
    rgba(200,29,58,0.16) 0px,
    rgba(200,29,58,0.16) 2px,
    transparent 2px,
    transparent 22px
  );
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.08;
  margin: 0 0 18px;
  max-width: 760px;
}
.hero h1 .hero-highlight {
  color: var(--red);
  -webkit-text-stroke: 1.5px var(--paper);
}
.hero p {
  max-width: 560px;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(236,230,214,0.82);
  margin-bottom: 34px;
}
.hero-search-form {
  display: flex;
  gap: 0;
  max-width: 520px;
  border: 3px solid var(--paper);
  border-radius: 6px;
  overflow: hidden;
}
.hero .autocomplete-wrapper {
  max-width: 520px;
}
.hero-search-form input {
  flex: 1;
  border: none;
  padding: 16px 18px;
  font-size: 16px;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.hero-search-form button {
  border: none;
  background: var(--red);
  color: var(--paper);
  padding: 0 26px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.hero-search-form button:hover { background: #a91630; }

/* =========================== SECTION HEADINGS =========================== */
.section {
  padding: 56px 0;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 10px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0;
}
.section-head span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--grey);
}

/* =========================== PANEL / CARD GRID =========================== */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

/* Grid khusus rekomendasi manga serupa: dipaksa 5 judul per baris di layar besar */
.panel-grid.similar-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
}

.panel-card {
  position: relative;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 3px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 5px 5px 0 var(--ink);
}
.panel-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--red);
}
.panel-rank {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 13px;
  padding: 4px 10px 5px 8px;
  border-bottom-right-radius: 4px;
  z-index: 2;
}
.panel-thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: var(--paper-alt);
  border-bottom: 3px solid var(--ink);
}
.panel-thumb-fallback {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-alt);
  border-bottom: 3px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--grey);
  text-align: center;
  padding: 12px;
}
.panel-body {
  padding: 12px 14px 16px;
}
.panel-title {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--grey);
}
.tag {
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
}
.tag-score {
  background: var(--ink);
  color: var(--gold);
  border-color: var(--ink);
}
.tag-sim {
  background: var(--red);
  color: var(--paper);
  border-color: var(--red);
}

/* =========================== SEARCH RESULTS PAGE =========================== */
.results-header {
  padding: 40px 0 12px;
  border-bottom: 4px solid var(--ink);
}
.results-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--grey);
  letter-spacing: 1px;
}
.results-header h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 38px);
  margin: 6px 0 20px;
}
.error-box {
  background: var(--ink);
  color: var(--paper);
  border-left: 6px solid var(--red);
  padding: 18px 22px;
  margin: 24px 0;
  font-size: 15px;
}
.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--grey);
}

/* =========================== DETAIL PAGE =========================== */
.detail-hero {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 36px;
  padding: 44px 0;
  border-bottom: 4px solid var(--ink);
}
.detail-cover {
  width: 100%;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  aspect-ratio: 3/4;
  object-fit: cover;
}
.detail-cover-fallback {
  width: 100%;
  aspect-ratio: 3/4;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-alt);
  font-family: var(--font-mono);
  color: var(--grey);
  text-align: center;
  padding: 16px;
}
.detail-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.15;
  margin: 0 0 14px;
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.detail-stats {
  display: flex;
  gap: 28px;
  margin-bottom: 22px;
  font-family: var(--font-mono);
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--red); }
.stat-label { font-size: 11px; color: var(--grey); text-transform: uppercase; letter-spacing: 1px; }
.detail-synopsis {
  font-size: 15px;
  line-height: 1.7;
  max-width: 640px;
  color: #2a251f;
}
.detail-cta {
  margin-top: 24px;
}
.btn-primary {
  display: inline-block;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 13px;
  padding: 12px 22px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.btn-primary:hover { background: #a91630; }

/* =========================== FOOTER =========================== */
.site-footer {
  background: var(--ink);
  color: rgba(236,230,214,0.7);
  padding: 28px 24px;
  margin-top: 40px;
}
.footer-inner p { margin: 4px 0; font-size: 13px; }
.footer-sub { font-family: var(--font-mono); font-size: 11px !important; color: rgba(236,230,214,0.45); }

/* =========================== AUTOCOMPLETE DROPDOWN =========================== */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow: 6px 6px 0 var(--ink);
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
}
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.is-active {
  background: var(--paper-alt);
}
.autocomplete-thumb {
  flex: 0 0 auto;
  width: 34px;
  height: 46px;
  background: var(--paper-alt);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  overflow: hidden;
}
.autocomplete-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.autocomplete-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.autocomplete-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--grey);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdown pada search box di header (versi gelap) perlu warna disesuaikan */
.header-search .autocomplete-dropdown {
  border-color: var(--paper);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.4);
}

/* =========================== RESPONSIVE =========================== */

/* Tablet & bawah */
@media (max-width: 860px) {
  .panel-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }
  .panel-grid.similar-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
  .detail-hero {
    grid-template-columns: 220px 1fr;
    gap: 24px;
  }
}

/* HP (ponsel) */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }

  /* Header: brand + search jadi 2 baris, search full width */
  .header-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }
  .brand-text { font-size: 17px; }
  .brand-mark { width: 32px; height: 32px; font-size: 18px; }
  .header-search {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  /* Hero */
  .hero { padding: 44px 16px 56px; }
  .hero-inner { padding: 0 16px; }
  .hero h1 { font-size: clamp(28px, 9vw, 40px); }
  .hero p { font-size: 14.5px; }
  .hero-search-form {
    flex-direction: column;
    max-width: 100%;
    border-width: 2px;
  }
  .hero-search-form input { padding: 14px 16px; font-size: 15px; }
  .hero-search-form button {
    padding: 14px;
    width: 100%;
  }

  /* Section headings */
  .section { padding: 36px 0; }
  .section-head h2 { font-size: 21px; }

  /* Grid rekomendasi: 2 kolom rapi di layar kecil */
  .panel-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .panel-grid.similar-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .panel-title { font-size: 13px; }
  .panel-body { padding: 10px 10px 12px; }
  .panel-meta { font-size: 10px; gap: 4px; }
  .panel-card:hover {
    transform: none;
    box-shadow: 5px 5px 0 var(--ink);
  }

  /* Halaman hasil pencarian */
  .results-header { padding: 28px 0 8px; }
  .results-header h1 { font-size: 24px; }

  /* Halaman detail: cover di atas, teks di bawah, full width */
  .detail-hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 28px 0;
  }
  .detail-cover, .detail-cover-fallback {
    max-width: 200px;
    margin: 0 auto;
  }
  .detail-title { font-size: 26px; text-align: left; }
  .detail-stats {
    gap: 18px;
    flex-wrap: wrap;
  }
  .stat-num { font-size: 18px; }
  .detail-synopsis { font-size: 14px; }
  .btn-primary {
    display: block;
    text-align: center;
    font-size: 12px;
  }

  .site-footer { padding: 22px 16px; }
}

/* HP sangat kecil */
@media (max-width: 380px) {
  .panel-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .brand-text { font-size: 15px; }
}

/* Accessibility: visible focus */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .panel-card { transition: none; }
}
