/*
Theme Name:        Fantasy World Theme V1
Theme URI:         https://fantasyworld.example.com/
Description:       Dark, bold theme for the FantasyWorld fiction-novels site. Color scheme modeled on Pornhub: near-black backgrounds (#151515 / #000), signature red accent (#fd3548), white text, pill-shaped search bar and red buttons.
Author:            FantasyWorld
Author URI:        https://fantasyworld.example.com/
Version:           1.0.0
Requires at least: 6.0
Tested up to:      6.6
Requires PHP:      7.4
License:           GNU General Public License v2 or later
License URI:       http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       fantasyworld
Tags:              dark, custom-colors, custom-menu, featured-images, one-column, two-columns, translation-ready
*/

/* ==========================================================================
   1. PH-style design tokens
   ========================================================================== */
:root {
  --fw-bg:            #151515;   /* page background (PH dark) */
  --fw-bg-header:     #000000;   /* header strip (PH black) */
  --fw-bg-footer:     #1a1a1a;
  --fw-surface:       #222222;   /* cards */
  --fw-surface-hover: #2b2b2b;
  --fw-accent:        #fd3548;   /* signature red */
  --fw-accent-dark:   #d92a3c;
  --fw-text:          #ffffff;
  --fw-text-muted:    #888888;
  --fw-border:        #333333;
  --fw-input-bg:      #ffffff;
  --fw-radius:        8px;
  --fw-header-h:      70px;
}

/* ==========================================================================
   2. Reset / base
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fw-bg);
  color: var(--fw-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; border: 0; }

a { color: var(--fw-accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--fw-accent-dark); }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 .5em;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fw-text);
}

p { margin: 0 0 1em; }

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100px; left: 10px;
  background: var(--fw-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--fw-radius) var(--fw-radius);
  z-index: 100;
}
.skip-link:focus { top: 0; color: #fff; }

.site { min-height: 100vh; display: flex; flex-direction: column; }
.site-content { flex: 1; }

.container {
  width: min(1200px, 100% - 32px);
  margin-inline: auto;
}

/* ==========================================================================
   3. Header — PH-style black bar with centered search
   ========================================================================== */
/* Logged-in WP admin bar: core ships it `position: fixed` (always floating
   at the viewport top, overlapping our sticky header while scrolling).
   `absolute` instead pins it to the TOP OF THE PAGE only — visible at
   scroll position 0, it scrolls out of view with the rest of the page
   (core's body padding-top keeps the header from starting underneath it,
   so nothing overlaps). Core already does the same thing below 600px; this
   extends the behaviour to desktop viewports. */
#wpadminbar {
  position: absolute;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--fw-bg-header);
  border-bottom: 1px solid var(--fw-border);
  /* One flex ROW: branding + search + nav on the same line (desktop).
     The .header-inner bar dissolves into this row via `display: contents`
     (see below), so its children sit on this line between the row's other
     items. On mobile (<=900px) it switches to a flex COLUMN: row #1 is the
     bar (branding + menu button), row #2 is the collapsible drawer. */
  display: flex;
  align-items: center;
  min-height: var(--fw-header-h);
  padding: 0 32px;
  gap: 24px;
}

.header-inner {
  /* Desktop: dissolve the bar into .site-header's flex row so branding,
     search and nav share ONE line. The menu button is hidden on desktop
     (display:none until the mobile breakpoint), so nothing else changes.
     On mobile this is overridden back to `display: flex` (the bar row). */
  display: contents;
}

.site-branding { display: flex; align-items: center; gap: 10px; }

/* Wraps the search box + nav menu. On desktop it is a flex item of
   .site-header's single row (the .header-inner bar is `display: contents`),
   so branding, search and nav sit on ONE line. `flex: 1; min-width: 0` lets
   the inner search box (flex:1) grow into the remaining space. On mobile
   (<=900px) it becomes the collapsible drawer — a normal-flow sibling of
   the bar INSIDE the sticky header, so the two always stick together with
   no gap. */
.mobile-drawer {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
  min-width: 0;
}
.mobile-drawer .header-search { flex: 1; max-width: 480px; }
.mobile-drawer .main-navigation ul { flex: none; }

.site-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
}
.site-title a { color: #fff; }
.site-title a:hover { color: var(--fw-accent); }

.site-branding .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: var(--fw-accent);
  color: #fff;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

/* --- Search bar (PH pill) --- */
.header-search {
  flex: 1;
  max-width: 560px;
  margin-inline: auto;
}

.search-form {
  display: flex;
  background: #fff;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow .15s ease;
}
.search-form:focus-within { box-shadow: 0 0 0 2px var(--fw-accent); }

.search-field,
.search-form input[type="search"] {
  flex: 1;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: #222;
  font-size: 15px;
  padding: 10px 18px;
  min-width: 0;
}
.search-field::placeholder,
.search-form input[type="search"]::placeholder { color: #999; }
.search-field:focus,
.search-form input[type="search"]:focus {
  outline: none;
  border: 0;
  background: transparent;
}

/* WebKit renders search inputs with a rounded, non-transparent background and
   an inner cancel button that can leak white corners into the pill. */
.search-form input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
.search-form input[type="search"]::-webkit-search-cancel-button,
.search-form input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-submit {
  border: 0;
  background: var(--fw-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 22px;
  cursor: pointer;
  transition: background .15s ease;
}
.search-submit:hover,
.search-submit:focus { background: var(--fw-accent-dark); color: #fff; }

/* --- Mobile menu toggle (hidden on desktop; shown at <= 900px) --- */
.menu-toggle {
  display: none;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px;
  margin-left: auto;
  cursor: pointer;
  border-radius: var(--fw-radius);
}
.menu-toggle:hover,
.menu-toggle:focus { background: var(--fw-surface); }
.menu-toggle-icon,
.menu-toggle-icon::before,
.menu-toggle-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform .2s ease, opacity .2s ease;
}
.menu-toggle-icon { position: relative; }
.menu-toggle-icon::before,
.menu-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}
.menu-toggle-icon::before { top: -7px; }
.menu-toggle-icon::after { top: 7px; }
/* Hamburger morphs into a close (X) mark while the drawer is open. */
.site-header.nav-open .menu-toggle-icon { background: transparent; }
.site-header.nav-open .menu-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}
.site-header.nav-open .menu-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

/* --- Primary navigation --- */
.main-navigation { font-size: 0; }

.main-navigation ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  gap: 4px;
}

.main-navigation li { display: inline-block; font-size: 15px; }

.main-navigation a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--fw-radius);
  color: #ddd;
  font-weight: 600;
}
.main-navigation a:hover { color: #fff; background: var(--fw-surface); }

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
  color: #fff;
  background: var(--fw-accent);
}

/* ==========================================================================
   4. Buttons
   ========================================================================== */
.btn,
.button,
.wp-block-button__link,
button.wp-block-button__link {
  display: inline-block;
  background: var(--fw-accent);
  color: #fff;
  border: 0;
  border-radius: var(--fw-radius);
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover, .button:hover { background: var(--fw-accent-dark); color: #fff; }
.btn:active { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--fw-border);
  color: var(--fw-text);
}
.btn-outline:hover { border-color: var(--fw-accent); background: var(--fw-accent); color: #fff; }

/* ==========================================================================
   5. Content
   ========================================================================== */
/* Breathing room between the sticky nav header and the page content
   (post titles, archive headers, etc.) so titles don't sit flush
   against the nav bar. */
.site-main { padding-top: 32px; }

.entry-header { margin-bottom: 20px; }

.entry-title { font-size: 30px; margin-bottom: 8px; }
.entry-title a { color: var(--fw-text); }
.entry-title a:hover { color: var(--fw-accent); }

.entry-meta {
  color: var(--fw-text-muted);
  font-size: 14px;
}
.entry-meta a { color: var(--fw-text-muted); }
.entry-meta a:hover { color: var(--fw-accent); }
.entry-meta .sep { margin: 0 8px; color: var(--fw-border); }

.entry-content { color: #e6e6e6; }
.entry-content > :last-child { margin-bottom: 0; }
.entry-content h2 { font-size: 24px; }
.entry-content h3 { font-size: 20px; }
.entry-content blockquote {
  margin: 1.5em 0;
  padding: 12px 20px;
  border-left: 3px solid var(--fw-accent);
  background: var(--fw-surface);
  border-radius: 0 var(--fw-radius) var(--fw-radius) 0;
}
.entry-content pre {
  background: var(--fw-surface);
  border: 1px solid var(--fw-border);
  border-radius: var(--fw-radius);
  padding: 16px;
  overflow-x: auto;
}
.entry-content code {
  background: var(--fw-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.entry-content pre code { padding: 0; background: none; }

.post-navigation {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 40px 0;
  padding-top: 20px;
  border-top: 1px solid var(--fw-border);
}
.post-navigation a {
  flex: 1;
  max-width: 48%;
  color: var(--fw-text-muted);
  font-size: 14px;
}
.post-navigation a:hover { color: var(--fw-accent); }
.post-navigation .nav-label { display: block; color: var(--fw-text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* --- Novel metadata card (custom fields) --- */
.novel-meta {
  background: var(--fw-surface);
  border: 1px solid var(--fw-border);
  border-radius: var(--fw-radius);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
}
.novel-meta dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.novel-meta dt { color: var(--fw-text-muted); font-weight: 600; }
.novel-meta dd { margin: 0; }

/* ==========================================================================
   6. Novel grid — PH-style card tiles
   ========================================================================== */
.novel-grid {
  list-style: none;
  margin: 0 -8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.novel-card { margin: 0; }

.novel-card .thumb {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  background: var(--fw-surface);
  border-radius: var(--fw-radius);
  overflow: hidden;
  margin-bottom: 10px;
}
.novel-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s ease;
}
.novel-card .thumb:hover img { transform: scale(1.04); }

.novel-card .thumb .genre-badge {
  position: absolute;
  left: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 3px 8px;
  border-radius: 4px;
}

.novel-card .card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.novel-card .card-title a { color: var(--fw-text); }
.novel-card .card-title a:hover { color: var(--fw-accent); }

.novel-card .card-meta {
  font-size: 12px;
  color: var(--fw-text-muted);
}

/* Fallback placeholder when a novel has no cover */
.novel-card .thumb .thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #222 0%, #151515 100%);
  color: var(--fw-text-muted);
  font-size: 42px;
  font-weight: 900;
}

/* ==========================================================================
   7. Archive headers / section headings
   ========================================================================== */
.page-header {
  padding: 28px 0;
  border-bottom: 1px solid var(--fw-border);
  margin-bottom: 24px;
}
.page-title { margin: 0 0 4px; font-size: 26px; }
.page-description { color: var(--fw-text-muted); margin: 0; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 32px 0 16px;
}
.section-title h2 { font-size: 20px; margin: 0; }
.section-title a { font-size: 14px; font-weight: 600; }

/* ==========================================================================
   8. Pagination — PH-style numbered pills
   ========================================================================== */
.pagination,
.post-navigation .nav-links,
.wp-block-navigation .aligncenter { margin: 32px 0; }

.page-links,
.pagination { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.page-links .page-numbers,
.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--fw-radius);
  background: var(--fw-surface);
  color: var(--fw-text);
  font-weight: 600;
}
.page-links .page-numbers:hover,
.pagination .page-numbers:hover { background: var(--fw-surface-hover); color: #fff; }
.page-links .page-numbers.current,
.pagination .page-numbers.current { background: var(--fw-accent); color: #fff; }
.page-links .page-numbers.dots { background: transparent; color: var(--fw-text-muted); }

/* ==========================================================================
   9. Sidebar
   ========================================================================== */
.widget-area { padding-top: 8px; }

.widget {
  background: var(--fw-surface);
  border: 1px solid var(--fw-border);
  border-radius: var(--fw-radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.widget-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px;
  color: var(--fw-text);
}
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 7px 0; border-bottom: 1px solid var(--fw-border); }
.widget li:last-child { border-bottom: 0; }
.widget a { color: #ddd; }
.widget a:hover { color: var(--fw-accent); }

/* ==========================================================================
   10. Forms (contact / comment)
   ========================================================================== */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--fw-surface);
  border: 1px solid var(--fw-border);
  border-radius: var(--fw-radius);
  color: var(--fw-text);
  font-size: 15px;
  padding: 10px 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--fw-accent);
}
label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }

/* ==========================================================================
   11. Comments
   ========================================================================== */
.comments-area { margin-top: 40px; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .comment { padding: 16px 0; border-bottom: 1px solid var(--fw-border); }
.comment-author { font-weight: 700; }
.comment-metadata { font-size: 13px; color: var(--fw-text-muted); margin-bottom: 8px; }
.comment-metadata a { color: var(--fw-text-muted); }
.comment-reply-link { font-size: 13px; font-weight: 600; }

/* ==========================================================================
   12. Footer
   ========================================================================== */
.site-footer {
  background: var(--fw-bg-footer);
  border-top: 1px solid var(--fw-border);
  margin-top: 48px;
  padding: 32px 0;
  font-size: 14px;
  color: var(--fw-text-muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; }
.footer-nav a { color: var(--fw-text-muted); }
.footer-nav a:hover { color: var(--fw-accent); }
.site-info { margin: 0; }
.site-info a { color: var(--fw-text-muted); }
.site-info a:hover { color: var(--fw-accent); }

/* ==========================================================================
   13. 404 / search results
   ========================================================================== */
.error-404 .page-title { font-size: 64px; color: var(--fw-accent); }
.search-results-count,
.archive-meta { color: var(--fw-text-muted); font-size: 14px; }

/* ==========================================================================
   14. Alignment / misc
   ========================================================================== */
.alignleft { float: left; margin: 8px 24px 16px 0; }
.alignright { float: right; margin: 8px 0 16px 24px; }
.aligncenter { margin-inline: auto; }
.wp-caption { max-width: 100%; }
.wp-caption-text { color: var(--fw-text-muted); font-size: 13px; text-align: center; }
.sticky { /* used as a hook */ }
.sticky .card-title::before {
  content: "★ ";
  color: var(--fw-accent);
}
.byline, .updated:not(:first-child) { display: none; }
.page-content .wp-block-calendar { color: var(--fw-text); }

/* ==========================================================================
   15. Responsive
   ========================================================================== */
@media (max-width: 900px) {
  /* Mobile: one-line header (branding left, menu button right). Nav + search
     live in a collapsible drawer under the bar, hidden until the button
     is pressed. Desktop (>900px) is untouched. */
  .site-header {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding: 0;
    gap: 0;
  }
  .header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: var(--fw-header-h);
    padding: 10px 32px;
  }
  .menu-toggle { display: inline-flex; }

  /* The drawer lives INSIDE the sticky .site-header, as a normal-flow
     sibling of the .header-inner bar — one container, two parts. Because
     it is a static child of the header (not a separate fixed/sticky
     element), it sits flush against the bar's bottom edge by construction:
     zero gap on every screen size, scrolled or not, and it follows the
     header automatically when the logged-in WP admin bar (fixed on wide
     viewports, absolute on narrow ones) shifts the page. The bar's
     border-bottom is moved onto the bar itself so the divider stays
     between bar and drawer. The drawer is capped in height so a very long
     menu scrolls internally instead of covering the whole viewport.
     Hidden until the menu button opens it. */
  .header-inner {
    border-bottom: 1px solid var(--fw-border);
  }
  .site-header {
    border-bottom: 0;
  }
  /* Drawer switches from the desktop flex row (same line as branding) to a
     hidden vertical panel under the bar. `display: block` here overrides
     the desktop `display: flex` rule. */
  .mobile-drawer {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 16px 16px;
    min-height: 0;
    max-height: calc(100vh - var(--fw-header-h) - 21px - var(--wp-admin--admin-bar--height, 0px));
    background: var(--fw-bg-header);
    /* No border-top here: the .header-inner border-bottom directly above
       this drawer IS the divider (one 1px line between bar and drawer). */
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .site-header.nav-open .mobile-drawer {
    display: block;
  }

  /* Search box: full width inside the drawer (base flex:1 / max-width
     don't apply inside a block container, but keep them explicit). */
  .mobile-drawer .header-search {
    flex: none;
    max-width: none;
    margin: 0 0 12px;
  }
  .mobile-drawer .search-form {
    max-width: 480px;
    margin-inline: auto;
  }
  .main-navigation ul {
    flex-direction: column;
    gap: 2px;
  }
  .main-navigation li { display: block; }
  .main-navigation a {
    padding: 12px 14px;
    font-size: 16px;
  }

  .novel-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 560px) {
  .site-title { font-size: 18px; }
  .novel-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .novel-card .card-title { font-size: 13px; }
  .footer-inner { flex-direction: column; text-align: center; }
}
