/* ==========================================================================
   FANDOM CORE DESIGN SYSTEM
   ========================================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Global Fandom Color Palette */
  --fd-bg-main: #090b10;
  --fd-bg-surface: #10141d;
  --fd-bg-card: #151a26;
  --fd-bg-card-hover: #1c2333;
  --fd-bg-input: #1e2433;
  --fd-border: #232b3d;
  --fd-border-light: #323d54;

  --fd-text-primary: #f2f5fa;
  --fd-text-secondary: #9ba7be;
  --fd-text-muted: #6b778d;

  --fd-brand-flame: #fa005a;
  --fd-brand-flame-hover: #e00050;
  --fd-brand-yellow: #ffc500;
  --fd-brand-cyan: #00d6d6;
  --fd-brand-blue: #0077ff;

  /* Dynamic Theme Accents (Overridden per subdomain) */
  --theme-accent: #fa005a;
  --theme-accent-hover: #e00050;
  --theme-accent-glow: rgba(250, 0, 90, 0.25);
  --theme-bg-tint: rgba(250, 0, 90, 0.05);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --max-width: 1320px;
  --header-height: 56px;
  --sub-bar-height: 38px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--fd-bg-main);
  color: var(--fd-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* ==========================================================================
   GLOBAL NETWORK & SUBDOMAIN RIBBON (TOPMOST BAR)
   ========================================================================== */

.fandom-network-ribbon {
  background: #06070a;
  border-bottom: 1px solid var(--fd-border);
  font-size: 0.8125rem;
  padding: 0 1.25rem;
  height: var(--sub-bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1001;
}

.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--fd-text-secondary);
  text-transform: uppercase;
}

.network-badge .pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #00f090;
  border-radius: 50%;
  box-shadow: 0 0 8px #00f090;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.subdomain-nav-list {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.sub-pill {
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--fd-bg-surface);
  color: var(--fd-text-secondary);
  font-size: 0.775rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.sub-pill:hover {
  background: var(--fd-bg-card-hover);
  color: var(--fd-text-primary);
  border-color: var(--fd-border-light);
}

.sub-pill.active {
  background: var(--theme-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 10px var(--theme-accent-glow);
}

.network-mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fd-text-muted);
  font-size: 0.75rem;
}

/* ==========================================================================
   GLOBAL FANDOM HEADER
   ========================================================================== */

.fandom-global-header {
  background-color: var(--fd-bg-surface);
  border-bottom: 1px solid var(--fd-border);
  height: var(--header-height);
  position: sticky;
  top: var(--sub-bar-height);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.fandom-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.fandom-flame {
  width: 26px;
  height: 26px;
  fill: var(--fd-brand-flame);
  filter: drop-shadow(0 0 6px rgba(250, 0, 90, 0.4));
}

.fandom-wordmark {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-transform: uppercase;
}

.fandom-wordmark span {
  color: var(--fd-brand-flame);
}

.global-nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.global-nav-links li a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fd-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.global-nav-links li a:hover {
  color: #ffffff;
}

.header-center {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  height: 38px;
  background-color: var(--fd-bg-input);
  border: 1px solid var(--fd-border);
  border-radius: var(--radius-full);
  padding: 0 2.5rem 0 2.5rem;
  font-size: 0.875rem;
  color: var(--fd-text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--theme-accent);
  background-color: #242c3d;
  box-shadow: 0 0 12px var(--theme-accent-glow);
}

.search-icon-left {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--fd-text-muted);
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  background: var(--fd-border);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--fd-text-muted);
}

/* Autocomplete Dropdown */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--fd-bg-surface);
  border: 1px solid var(--fd-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 2000;
}

.search-results-dropdown.show {
  display: block;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--fd-border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-item:hover {
  background: var(--fd-bg-card-hover);
}

.search-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-item-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.search-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fd-text-primary);
}

.search-item-sub {
  font-size: 0.75rem;
  color: var(--fd-text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-create-wiki {
  background-color: transparent;
  color: var(--fd-text-primary);
  border: 1px solid var(--fd-border-light);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-create-wiki:hover {
  background-color: var(--fd-bg-card-hover);
  border-color: var(--fd-text-secondary);
}

.btn-signin {
  background-color: var(--fd-brand-flame);
  color: #ffffff;
  border: none;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-signin:hover {
  background-color: var(--fd-brand-flame-hover);
  transform: translateY(-1px);
}

/* User Avatar / Profile Menu */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fa005a 0%, #ffc500 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  border: 2px solid var(--fd-border);
}

/* ==========================================================================
   COMMON COMPONENTS
   ========================================================================== */

.page-wrapper {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
}

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--fd-border);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background-color: var(--theme-accent);
  border-radius: var(--radius-sm);
}

.view-all-link {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--theme-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Badge Tags */
.badge-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.show {
  display: flex;
}

.modal-card {
  background: var(--fd-bg-surface);
  border: 1px solid var(--fd-border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--fd-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--fd-text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--fd-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--fd-bg-input);
  border: 1px solid var(--fd-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--fd-text-primary);
  outline: none;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--theme-accent);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--fd-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--fd-bg-main);
}

/* ==========================================================================
   GLOBAL FOOTER
   ========================================================================== */

.fandom-global-footer {
  background-color: #06070a;
  border-top: 1px solid var(--fd-border);
  padding: 3rem 1.25rem 2rem 1.25rem;
  margin-top: auto;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--fd-border);
  margin-bottom: 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.footer-col h4 {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-links li a {
  font-size: 0.8125rem;
  color: var(--fd-text-muted);
}

.footer-links li a:hover {
  color: var(--theme-accent);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  border-top: 1px solid var(--fd-border);
  font-size: 0.75rem;
  color: var(--fd-text-muted);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .global-nav-links {
    display: none;
  }
  .header-center {
    max-width: 280px;
  }
}

@media (max-width: 650px) {
  .header-center {
    display: none;
  }
  .subdomain-nav-list {
    max-width: 220px;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
}
