/*
Theme Name: StoryOnline
Theme URI: https://storyonline.ai
Author: StoryOnline
Author URI: https://storyonline.ai
Description: A lightweight, Wattpad-inspired WordPress theme for StoryOnline.ai — featuring story browsing, collections, and AI-powered story creation.
Version: 1.0.1
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: storyonline
Tags: blog, custom-colors, custom-logo, custom-menu, featured-images, footer-widgets, full-width-template, sticky-post, threaded-comments, two-columns
*/

:root {
  --so-orange:      #FF6122;
  --so-orange-dark: #E04E0F;
  --so-orange-light:#FFF0EA;
  --so-dark:        #1A1A2E;
  --so-text:        #2D2D3A;
  --so-muted:       #6B7080;
  --so-border:      #E8E8EF;
  --so-bg:          #F8F8FC;
  --so-white:       #FFFFFF;
  --so-card-shadow: 0 2px 12px rgba(26,26,46,.07);
  --so-radius:      10px;
  --so-radius-sm:   6px;
  --font-display:   'Merriweather', Georgia, serif;
  --font-body:      ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --transition:     0.2s ease;
}
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--so-text);
  background: var(--so-bg);
  margin: 0;
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--so-orange); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--so-orange-dark); }

img { max-width: 100%; height: auto; display: block; }

h1,h2,h3,h4,h5,h6 {
  color: var(--so-dark);
  line-height: 1.25;
  margin-top: 0;
}

.text-so-primary {
  color: var(--so-orange);
}
.so-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.so-badge-genre  { background: var(--so-orange-light); color: var(--so-orange-dark); }
.so-badge-new    { background: #E8F5E9; color: #2E7D32; }
.so-badge-hot    { background: #FFF3E0; color: #E65100; }
.so-badge-ai     { background: #F3E5F5; color: #6A1B9A; }

.so-divider { border: 0; border-top: 1px solid var(--so-border); margin: 2rem 0; }

/* ============================================================
   NAVBAR
   ============================================================ */
.so-navbar {
  background: var(--so-white);
  border-bottom: 1px solid var(--so-border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.logged-in .so-navbar {
  top: 32px;
}

.so-navbar .navbar-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--so-orange) !important;
  letter-spacing: -0.02em;
}
.so-navbar .navbar-brand span { color: var(--so-dark); }

.so-navbar .nav-link {
  color: var(--so-text) !important;
  font-weight: 500;
  font-size: .92rem;
  padding: 1.1rem .85rem !important;
  transition: color var(--transition);
}
.so-navbar .nav-link:hover,
.so-navbar .nav-link.active { color: var(--so-orange) !important; }

.so-navbar .nav-link.active {
  border-bottom: 2.5px solid var(--so-orange);
}

.so-search-bar {
  background: var(--so-bg);
  border: 1.5px solid var(--so-border);
  border-radius: var(--so-radius-sm);
  padding: .36rem 1rem;
  font-size: .88rem;
  width: 220px;
  transition: border-color var(--transition), width var(--transition);
  outline: none;
}
.so-search-bar:focus {
  border-color: var(--so-orange);
}

.btn-so-primary {
  background: var(--so-orange);
  color: #fff !important;
  border: none;
  border-radius: var(--so-radius-sm);
  padding: .42rem 1.1rem;
  font-size: .88rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
}
.btn-so-primary:hover { background: var(--so-orange-dark); transform: translateY(-1px); }

.btn-so-outline {
  background: transparent;
  color: var(--so-orange) !important;
  border: 1.5px solid var(--so-orange);
  border-radius: var(--so-radius-sm);
  padding: .38rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
}
.btn-so-outline:hover {
  background: var(--so-orange);
  color: #fff !important;
  transform: translateY(-1px);
}

/* ============================================================
   STORY CARD
   ============================================================ */
.story-card {
  background: var(--so-white);
  border-radius: var(--so-radius);
  box-shadow: var(--so-card-shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--so-border);
}
.story-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(26,26,46,.13);
}

.story-card-cover {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: linear-gradient(135deg, #f0eeff 0%, #ffe8df 100%);
  flex-shrink: 0;
}
.story-card-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.story-card:hover .story-card-cover img { transform: scale(1.05); }

.story-card-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}

.story-card-badge-wrap {
  position: absolute; top: 8px; left: 8px;
}

.story-card-body {
  padding: .9rem 1rem 1rem;
  display: flex; flex-direction: column; flex: 1;
}

.story-card-title {
  font-family: var(--font-display);
  font-size: .92rem;
  font-weight: 700;
  color: var(--so-dark);
  margin-bottom: .2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-card-author {
  font-size: .8rem;
  color: var(--so-muted);
  margin-bottom: .5rem;
}
.story-card-author a { color: var(--so-orange); }

.story-card-meta {
  margin-top: auto;
  display: flex;
  gap: .8rem;
  font-size: .75rem;
  color: var(--so-muted);
}
.story-card-meta span { display: flex; align-items: center; gap: .25rem; }

/* ============================================================
   SECTION HEADING
   ============================================================ */
.section-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-heading h2 {
  font-size: 1.25rem;
  margin: 0;
}
.section-heading a {
  font-size: .83rem;
  color: var(--so-orange);
  font-weight: 500;
}

/* ============================================================
   HERO BANNER
   ============================================================ */
.so-hero {
  background: linear-gradient(135deg, var(--so-dark) 0%, #2D2050 100%);
  color: #fff;
  padding: 3.5rem 0 3rem;
  position: relative;
  overflow: hidden;
}
.so-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.so-hero-eyebrow {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--so-orange);
  margin-bottom: .6rem;
  display: block;
}
.so-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  color: #fff;
  margin-bottom: .8rem;
  line-height: 1.2;
}
.so-hero p {
  color: rgba(255,255,255,.72);
  font-size: 1.05rem;
  max-width: 480px;
  margin-bottom: 1.6rem;
}

.so-hero-search {
  display: flex; gap: .6rem; max-width: 460px;
}
.so-hero-search input {
  flex: 1;
  background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: var(--so-radius-sm);
  padding: .6rem 1rem;
  color: #fff;
  font-size: .92rem;
  outline: none;
  backdrop-filter: blur(6px);
}
.so-hero-search input::placeholder { color: rgba(255,255,255,.5); }
.so-hero-search input:focus { border-color: var(--so-orange); }

.so-hero-visual {
  display: flex; gap: 1rem; align-items: flex-end;
  justify-content: center;
}
.so-hero-book {
  background: var(--so-white);
  border-radius: var(--so-radius-sm);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  transform-origin: bottom center;
}
.so-hero-book:nth-child(1) { width: 85px; transform: rotate(-6deg) translateY(8px); }
.so-hero-book:nth-child(2) { width: 95px; transform: rotate(0deg); }
.so-hero-book:nth-child(3) { width: 80px; transform: rotate(5deg) translateY(12px); }
.so-hero-book-cover {
  height: 120px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
}

/* ============================================================
   GENRE PILLS
   ============================================================ */
.genre-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.genre-pill {
  padding: .35rem .9rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  border: 1.5px solid var(--so-border);
  background: var(--so-white);
  color: var(--so-text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.genre-pill:hover, .genre-pill.active {
  background: var(--so-orange);
  border-color: var(--so-orange);
  color: #fff;
}

/* ============================================================
   FEATURED STORY (horizontal card)
   ============================================================ */
.featured-story {
  background: var(--so-white);
  border-radius: var(--so-radius);
  border: 1px solid var(--so-border);
  overflow: hidden;
  display: flex;
  box-shadow: var(--so-card-shadow);
  transition: box-shadow var(--transition);
}
.featured-story:hover { box-shadow: 0 6px 24px rgba(26,26,46,.12); }

.featured-story-cover {
  width: 120px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #f0eeff, #ffe8df);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}
.featured-story-body { padding: 1rem 1.2rem; flex: 1; }
.featured-story-body h3 { font-size: 1rem; margin-bottom: .25rem; }
.featured-story-body p { font-size: .83rem; color: var(--so-muted); margin-bottom: .6rem; }

.story-blog-cover {
  width: 100%;
  height: 400px;
  flex-shrink: 0;
  border-radius: var(--so-radius);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.15);
  background: linear-gradient(135deg, #f0eeff, #ffe8df);
  aspect-ratio: 2/3;
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
}
/* ============================================================
   STORY DETAIL PAGE
   ============================================================ */
.story-detail-cover {
  width: 180px;
  flex-shrink: 0;
  border-radius: var(--so-radius);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.15);
  background: linear-gradient(135deg, #f0eeff, #ffe8df);
  aspect-ratio: 2/3;
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
}

.story-meta-row {
  display: flex; flex-wrap: wrap; gap: 1rem;
  font-size: .84rem; color: var(--so-muted);
  margin: .75rem 0;
}
.story-meta-row span { display: flex; align-items: center; gap: .3rem; }

.story-chapter-list { list-style: none; padding: 0; margin: 0; }
.story-chapter-list li {
  padding: .7rem 0;
  border-bottom: 1px solid var(--so-border);
  display: flex; align-items: center; justify-content: space-between;
}
.story-chapter-list li:last-child { border-bottom: none; }
.story-chapter-list a {
  color: var(--so-text); font-weight: 500; font-size: .92rem;
  transition: color var(--transition);
}
.story-chapter-list a:hover { color: var(--so-orange); }
.story-chapter-list .ch-meta { font-size: .78rem; color: var(--so-muted); }

/* ============================================================
   STORIES COLLECTION PAGE
   ============================================================ */
.collection-hero {
  background: linear-gradient(135deg, #f0eeff 0%, #ffeadf 100%);
  border-radius: var(--so-radius);
  padding: 2rem;
  margin-bottom: 2rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.collection-hero-icon { font-size: 3.5rem; }
.collection-hero-text h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.collection-hero-text p { color: var(--so-muted); margin: 0; font-size: .9rem; }

.filter-bar {
  background: var(--so-white);
  border: 1px solid var(--so-border);
  border-radius: var(--so-radius);
  padding: .75rem 1rem;
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1.5rem;
}
.filter-bar label { font-size: .8rem; color: var(--so-muted); font-weight: 600; }
.filter-select {
  border: 1.5px solid var(--so-border);
  border-radius: var(--so-radius-sm);
  padding: .3rem .65rem;
  font-size: .82rem;
  color: var(--so-text);
  background: var(--so-bg);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--so-orange); }

/* ============================================================
   AI STORY CREATION PAGE
   ============================================================ */
.ai-create-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  height: calc(100vh - 64px);
  max-height: 820px;
}

.ai-sidebar {
  background: var(--so-white);
  border: 1px solid var(--so-border);
  border-radius: var(--so-radius);
  padding: 1.2rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.2rem;
}
.ai-sidebar h3 { font-size: 1rem; margin-bottom: .75rem; }

.ai-form-group { margin-bottom: .9rem; }
.ai-form-group label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--so-muted); margin-bottom: .3rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.ai-form-group input,
.ai-form-group select,
.ai-form-group textarea {
  width: 100%;
  border: 1.5px solid var(--so-border);
  border-radius: var(--so-radius-sm);
  padding: .45rem .75rem;
  font-size: .88rem;
  font-family: var(--font-body);
  color: var(--so-text);
  background: var(--so-bg);
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}
.ai-form-group input:focus,
.ai-form-group select:focus,
.ai-form-group textarea:focus { border-color: var(--so-orange); background: var(--so-white); }

.ai-chat-area {
  background: var(--so-white);
  border: 1px solid var(--so-border);
  border-radius: var(--so-radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.ai-chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--so-border);
  display: flex; align-items: center; gap: .75rem;
}
.ai-chat-header h2 { font-size: 1rem; margin: 0; }
.ai-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4CAF50;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(76,175,80,.2);
}

.ai-messages {
  flex: 1; overflow-y: auto;
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
  scroll-behavior: smooth;
}

.ai-msg {
  display: flex; gap: .75rem; max-width: 88%;
}
.ai-msg.user { flex-direction: row-reverse; align-self: flex-end; }

.ai-msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
}
.ai-msg.ai   .ai-msg-avatar { background: var(--so-orange-light); }
.ai-msg.user .ai-msg-avatar { background: var(--so-dark); color: #fff; font-size: .8rem; font-weight: 700; }

.ai-msg-bubble {
  padding: .65rem .95rem;
  border-radius: 14px;
  font-size: .88rem;
  line-height: 1.55;
}
.ai-msg.ai   .ai-msg-bubble { background: var(--so-bg); border: 1px solid var(--so-border); border-bottom-left-radius: 4px; }
.ai-msg.user .ai-msg-bubble { background: var(--so-orange); color: #fff; border-bottom-right-radius: 4px; }

.ai-msg.ai .ai-msg-bubble pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: var(--so-radius-sm);
  padding: .75rem 1rem;
  font-size: .8rem;
  overflow-x: auto;
  margin: .5rem 0 0;
}

.ai-typing-indicator {
  display: flex; gap: .3rem; align-items: center; padding: .4rem 0;
}
.ai-typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--so-muted);
  animation: typingBounce 1.2s infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: .2s; }
.ai-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

.ai-input-area {
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--so-border);
  display: flex; gap: .6rem; align-items: flex-end;
}

.ai-input-box {
  flex: 1;
  border: 1.5px solid var(--so-border);
  border-radius: 22px;
  padding: .55rem 1rem;
  font-size: .9rem;
  font-family: var(--font-body);
  color: var(--so-text);
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color var(--transition);
  background: var(--so-bg);
}
.ai-input-box:focus { border-color: var(--so-orange); background: #fff; }

.ai-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--so-orange);
  border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  font-size: 1rem;
}
.ai-send-btn:hover { background: var(--so-orange-dark); transform: scale(1.08); }

.ai-action-chips {
  display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 1.1rem .75rem;
}
.ai-chip {
  padding: .28rem .75rem;
  border: 1.5px solid var(--so-border);
  border-radius: 16px;
  font-size: .76rem;
  font-weight: 500;
  color: var(--so-muted);
  background: var(--so-white);
  cursor: pointer;
  transition: all var(--transition);
}
.ai-chip:hover { border-color: var(--so-orange); color: var(--so-orange); background: var(--so-orange-light); }

/* ============================================================
   SIDEBAR WIDGETS
   ============================================================ */
.so-widget {
  background: var(--so-white);
  border: 1px solid var(--so-border);
  border-radius: var(--so-radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.25rem;
}
.so-widget h4 { font-size: .92rem; margin-bottom: .9rem; padding-bottom: .5rem; border-bottom: 1px solid var(--so-border); }

/* ============================================================
   FOOTER
   ============================================================ */
.so-footer {
  background: var(--so-dark);
  color: rgba(255,255,255,.6);
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
  font-size: .83rem;
}
.so-footer .footer-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--so-orange);
  margin-bottom: .4rem;
}
.so-footer h5 { color: rgba(255,255,255,.85); font-size: .88rem; margin-bottom: .8rem; }
.so-footer a { color: rgba(255,255,255,.55); display: block; margin-bottom: .4rem; }
.so-footer a:hover { color: var(--so-orange); }
.so-footer-bottom {
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: 1.5rem; padding-top: 1.2rem;
  text-align: center;
  font-size: .78rem;
}
.so-pagination .page-link,
.so-pagination .post-page-numbers {
  border-color: var(--so-border);
  color: var(--so-text);
  border-radius: var(--so-radius-sm) !important;
  margin: 0 2px;
  font-size: .85rem;
  border: 1px solid var(--so-orange);
  padding: 5px 10px;
}
.so-pagination .page-item.active .page-link,
.so-pagination .post-page-numbers.current {
  background: var(--so-orange);
  border-color: var(--so-orange);
  color: var(--so-white);
}
.so-pagination .page-link:hover,
.so-pagination .post-page-numbers:hover { 
  color: var(--so-orange); 
  background: var(--so-orange-light); 
}
.rank-math-breadcrumb {
  font-size: .8rem;
}
@media (max-width: 991px) {
  .ai-create-layout { grid-template-columns: 1fr; height: auto; max-height: none; }
  .ai-sidebar { max-height: none; }
  .ai-chat-area { height: 520px; }
  .so-hero-visual { display: none; }
}
@media (max-width: 767px) {
  .story-detail-cover { width: 130px; }
  .collection-hero { flex-direction: column; text-align: center; }
  .so-search-bar { width: 160px; }
  .so-search-bar:focus { width: 200px; }
  .featured-story-cover { width: 90px; }
}
