/*
 * Dark mode for hotelbank.jp — only when the browser / OS asks for it (prefers-color-scheme: dark).
 * No toggle: light stays exactly as before. Loaded after wp_head() so it wins over the theme CSS and
 * WordPress' global styles. Charts and the inline colours of article bodies: cmn/js/hb-dark.js.
 */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --d-bg: #0e131b;
    --d-surface: #161d28;
    --d-surface2: #1e2634;
    --d-border: #2b3546;
    --d-text: #e2e7ee;
    --d-heading: #f0f3f8;
    --d-muted: #a3adbb;
    --d-link: #8db1ff;
    --d-accent: #2a7aa8;   /* #58aedd in light: white text on it needs the darker shade */
    --d-navy: #2a3d66;
  }

  /* ---------- page, header, footer ---------- */
  html, body { background-color: var(--d-bg) !important; color: var(--d-text); }
  header, header .container { background-color: var(--d-surface) !important; color: var(--d-text); }
  header .logo small, header h1.logo small, header .logo p { color: var(--d-muted) !important; }
  footer { background-color: #0a0e14 !important; }
  .main_contents { color: var(--d-text); }
  .bread { background-color: #0a0e14 !important; }

  /* the logo: header.php serves logo_white.svg through <picture> in dark. The PNG has white space around
     the letters and the SVG has none, so the SVG is drawn smaller inside the same box height. */
  header .logo picture img { box-sizing: content-box !important; height: 20px !important; padding: 5px 0 !important; }
  header h1.logo picture img { height: 26px !important; padding: 7px 0 !important; }

  /* ---------- search, buttons, forms ---------- */
  input.s, input[type="text"], input[type="email"], input[type="search"], input[type="tel"], textarea, select {
    background-color: var(--d-surface2) !important; color: var(--d-text) !important; border-color: var(--d-border) !important;
  }
  input::placeholder, textarea::placeholder { color: #7d8898 !important; }
  #submit, .btn_, a.btn_ { background-color: #2e3a4d !important; border-color: #3a475c !important; color: #fff !important; }

  /* ---------- cards / sidebar (old templates) ---------- */
  .white_wrap, .archive_area, nav.menu a, .hb-side-menu a, .famous_area, .category_area {
    background-color: var(--d-surface) !important; color: var(--d-text); box-shadow: 0 1px 0 rgba(255,255,255,.03), 0 3px 8px rgba(0,0,0,.35) !important;
  }
  nav.menu a, .hb-side-menu a, .archive_area li a, .archive_area a { color: var(--d-text) !important; }
  .archive_area li, .archive_area ul li { border-color: var(--d-border) !important; }
  h2.bg_blue, .archive_area h2, .famous_area h2, p.prefectures, .bg_blue,
  .white_wrap > h2[class*="icon_"], .white_wrap > h2.title_h2 { background-color: var(--d-accent) !important; color: #fff !important; }

  /* lists (category / search / newlist), pagination, the newsletter archive */
  ul.article_japan > li { color: var(--d-text); }
  ul.article_japan > li:nth-child(even) { background-color: #1a2230 !important; }
  .wp-pagenavi a, .wp-pagenavi span { color: var(--d-text) !important; border-color: var(--d-border) !important; }
  .wp-pagenavi span.current { background-color: #2e3a4d !important; color: #fff !important; }
  ul.arc_links { background-color: var(--d-surface2) !important; }
  ul.arc_links li a { color: #5cc8ff !important; }
  dl.flex > dt, dl.flex > dd { border-color: var(--d-border) !important; }
  p.prefectures a { color: #fff !important; }
  p.category { background-color: #2a3341 !important; color: #d5dbe4 !important; }
  .sns_area .date { color: var(--d-muted) !important; }
  p.category a { color: #d5dbe4 !important; }
  a.wpp-post-title, .wpp-list a, .wpp-list li { color: var(--d-text) !important; }
  .split_4 li, .split_4 li p, .split_4 li a { color: var(--d-text); }
  h5.icon_list, .content_title, h1, h2, h3, h4 { color: var(--d-heading); }

  /* sidebar / menu icons are dark line drawings on a white card */
  nav.menu a::before, .hb-side-menu a::before, h5.icon_list::before { filter: invert(.9) hue-rotate(180deg); }

  /* ---------- article (single.php) ---------- */
  main > .white_wrap .content, main > .white_wrap .content p, main > .white_wrap .content li,
  main > .white_wrap .content h2, main > .white_wrap .content h3, main > .white_wrap .content h4 { color: var(--d-text); }
  main > .white_wrap .content h2, main > .white_wrap .content h3 { color: var(--d-heading); }
  main > .white_wrap .content a:link, main > .white_wrap .content a:visited, main > .white_wrap .content a:focus { color: var(--d-link) !important; }
  main > .white_wrap .content table td { color: var(--d-text); border-color: var(--d-border); }
  main > .white_wrap .content table th { background-color: var(--d-navy); color: #fff; }
  main > .white_wrap .content hr { border-color: var(--d-border); }
  main > .white_wrap .content blockquote { background-color: var(--d-surface2); color: var(--d-text); border-color: var(--d-border); }
  .content img { opacity: .94; }

  /* Leaflet: CartoDB light tiles turned into a dark map; markers / labels keep their colours */
  .leaflet-container { background-color: #1b222c !important; }
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }
  .leaflet-popup-content-wrapper, .leaflet-popup-tip, .leaflet-tooltip {
    background-color: var(--d-surface2) !important; color: var(--d-text) !important; border-color: var(--d-border) !important;
  }
  .leaflet-tooltip-top::before { border-top-color: var(--d-surface2) !important; }
  .leaflet-tooltip-bottom::before { border-bottom-color: var(--d-surface2) !important; }
  .leaflet-tooltip-left::before { border-left-color: var(--d-surface2) !important; }
  .leaflet-tooltip-right::before { border-right-color: var(--d-surface2) !important; }
  .leaflet-bar a, .leaflet-control-zoom a { background-color: var(--d-surface2) !important; color: var(--d-text) !important; border-color: var(--d-border) !important; }
  .leaflet-control-attribution { background-color: rgba(14,19,27,.75) !important; color: var(--d-muted) !important; }
  .leaflet-control-attribution a { color: var(--d-link) !important; }

  /* ---------- magazine home (hb-magazine.css works on variables) ---------- */
  html body .hb-mag { --navy: #c3d1ee; --accent: #7fa8ff; --bg: var(--d-bg); --border: var(--d-border); --text: var(--d-text); --muted: var(--d-muted);
            background: var(--d-bg) !important; color: var(--d-text); }
  .hb-mag .hb-hero { background: linear-gradient(180deg, #121821 0%, var(--d-bg) 100%) !important; }
  .hb-mag .hb-popular, .hb-mag .hb-popular li, .hb-mag .hb-tabs, .hb-mag .hb-side-mod, .hb-mag .hb-card {
    background-color: var(--d-surface) !important;
  }
  .hb-mag .hb-card .thumb, .hb-mag .hb-popular li .img { background-color: #222b38 !important; }
  .hb-mag .hb-popular .rank { background: #3b5487 !important; color: #fff !important; }
  .hb-mag .hb-tab { color: var(--d-muted); }
  .hb-mag .hb-tab.is-active { background-color: #2a3a5c !important; color: #fff !important; }
  .hb-mag .hb-side-head { border-bottom-color: #3b5487 !important; }
  .hb-mag .hb-cat-head { border-bottom-color: #3b5487 !important; }
  .hb-mag .hb-pickup { background-color: #1a2233; }
  .hb-mag .hb-pickup .overlay { color: #fff; }
  .hb-mag .hb-side-menu a { color: var(--d-text) !important; }
  .hb-mag .hb-pickup.is-thumb { background-color: var(--d-surface) !important; }
  .hb-mag .hb-pickup.is-thumb .ti, .hb-mag .hb-pickup.is-thumb h3 { color: var(--d-text) !important; }
  /* category numbers keep their hue, lifted so they read on the dark surface */
  .hb-mag .num { filter: brightness(1.9) saturate(.75); }
  .sp_only_advertisement ul, .sp_only_advertisement li { background-color: var(--d-surface) !important; }

  /* ---------- small screens: the slide-in menu ---------- */
  .sp_menu p { background-color: var(--d-text) !important; }
  #sp_nav, .sp_nav, .sp_menu_area, nav.sp, .menu_wrap { background-color: var(--d-surface) !important; color: var(--d-text); }

  a.toTop img { filter: invert(.85); }
  ::selection { background: #3b5487; color: #fff; }
}
