/* ==========================================================================
   PEPTIDE WIKI - MEDIAWIKI LIGHT DESIGN SYSTEM (styles.css)
   Airtight Mobile Optimization for iOS Safari (iPhone 14/15/16/17 Pro & Max)
   ========================================================================== */

:root {
  --wiki-bg: #ffffff;
  --wiki-header-bg: #ffffff;
  --wiki-sidebar-bg: #f8f9fa;
  --wiki-border: #a2a9b1;
  --wiki-border-light: #eaecf0;
  --wiki-link: #3366cc;
  --wiki-link-hover: #0645ad;
  --wiki-text: #202122;
  --wiki-text-muted: #54595d;
  --wiki-infobox-bg: #f8f9fa;
  --wiki-toc-bg: #f8f9fa;
  
  --font-serif: 'Linux Libertine', 'Georgia', 'Times', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, Helvetica, Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: rgba(51, 102, 204, 0.15);
}

html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--wiki-bg);
  color: var(--wiki-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  cursor: pointer; /* Ensures touch/click event delegation works on iOS Safari */
}

a {
  color: var(--wiki-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  color: var(--wiki-link-hover);
}

/* Fix iOS Safari input auto-zoom when tapping search fields */
input, select, textarea {
  font-size: 16px !important;
  border-radius: 0; /* Prevents default iOS Safari rounded input shapes */
}

/* ==========================================================================
   WIKIPEDIA HEADER BAR
   ========================================================================== */
.wiki-header {
  min-height: 60px;
  background: var(--wiki-header-bg);
  border-bottom: 1px solid var(--wiki-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--wiki-text);
  text-decoration: none !important;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  display: block;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.brand-wrapper:hover .brand-logo-img {
  transform: scale(1.05);
}

.brand-text-main {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: bold;
  line-height: 1.1;
  color: #000;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--wiki-text-muted);
}

.wiki-search-box {
  position: relative;
  width: 320px;
}

.wiki-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem 0.4rem 2rem;
  font-size: 16px !important; /* Fixed 16px to prevent iOS Safari auto-zoom */
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  background: #fff;
  outline: none;
  -webkit-appearance: none;
}

.wiki-search-input:focus {
  border-color: var(--wiki-link);
  box-shadow: 0 0 0 1px var(--wiki-link);
}

.search-icon-fixed {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--wiki-text-muted);
  pointer-events: none;
}

/* Mobile Sandwich Navigation Toggle Button */
.mobile-nav-toggle {
  display: none;
  background: #fff;
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  color: var(--wiki-text);
  font-size: 0.95rem;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
  min-height: 44px; /* iOS Human Interface Guidelines 44px tap target */
  touch-action: manipulation;
}

.mobile-nav-toggle:active {
  background: #f8f9fa;
  border-color: var(--wiki-link);
}

.mobile-only-header {
  display: none;
}

/* Backdrop Overlay for iPhone Mobile Drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
}

.sidebar-backdrop.active {
  display: block;
}

/* ==========================================================================
   WIKIPEDIA MAIN WRAPPER & SIDEBAR (#mw-panel)
   ========================================================================== */
.wiki-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 175px 1fr;
  min-height: calc(100vh - 60px);
  width: 100%;
}

.wiki-sidebar {
  background: var(--wiki-sidebar-bg);
  border-right: 1px solid var(--wiki-border-light);
  padding: 1.25rem 0.75rem;
}

.sidebar-group {
  margin-bottom: 1.5rem;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--wiki-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--wiki-border-light);
  margin-bottom: 0.5rem;
}

.sidebar-list {
  list-style: none;
}

.sidebar-list li {
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
}

.sidebar-list a {
  color: var(--wiki-link);
}

/* ==========================================================================
   HERO SECTION & LANDING GRID
   ========================================================================== */
.wiki-hero {
  background: #f8f9fa;
  border: 1px solid var(--wiki-border);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
}

.wiki-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wiki-hero h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0;
  border: none;
  padding: 0;
}

.wiki-hero-badge {
  font-size: 0.72rem;
  background: #eaecf0;
  border: 1px solid var(--wiki-border);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-weight: bold;
  color: var(--wiki-text-muted);
}

.main-landing-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
  width: 100%;
}

.az-index-box {
  background: #f8f9fa;
  border: 1px solid #a2a9b1;
  padding: 1rem;
  font-size: 0.82rem;
}

/* ==========================================================================
   WIKIPEDIA ARTICLE CONTENT AREA (#content)
   ========================================================================== */
.wiki-content {
  padding: 1.25rem 2rem;
  background: var(--wiki-bg);
  min-width: 0; /* Prevents CSS Grid overflow on narrow screens */
}

.article-tabs {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--wiki-border);
  margin-bottom: 1rem;
}

.tab-group {
  display: flex;
  gap: 0.2rem;
}

.tab-item {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  color: var(--wiki-link);
  background: #f8f9fa;
  border: 1px solid var(--wiki-border-light);
  border-bottom: none;
  cursor: pointer;
}

.tab-item.active {
  background: #fff;
  color: var(--wiki-text);
  font-weight: bold;
  border-color: var(--wiki-border);
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
}

.first-heading {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: normal;
  border-bottom: 1px solid var(--wiki-border-light);
  padding-bottom: 0.25rem;
  margin-bottom: 0.2rem;
}

.site-sub {
  font-size: 0.78rem;
  color: var(--wiki-text-muted);
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   WIKIPEDIA INFOBOX TABLE
   ========================================================================== */
.infobox {
  float: right;
  width: 310px;
  background: var(--wiki-infobox-bg);
  border: 1px solid var(--wiki-border);
  border-spacing: 0;
  margin: 0 0 1rem 1.25rem;
  padding: 0.5rem;
  font-size: 0.82rem;
}

.infobox-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: bold;
  text-align: center;
  background: #eaecf0;
  padding: 0.4rem;
  border: 1px solid var(--wiki-border-light);
}

.infobox-image-box {
  text-align: center;
  padding: 0.75rem 0;
  background: #fff;
  border-bottom: 1px solid var(--wiki-border-light);
  overflow-x: auto;
}

.infobox-image-box svg {
  max-width: 100%;
  height: auto;
}

.infobox-section-header {
  background: #eaecf0;
  font-weight: bold;
  text-align: center;
  padding: 0.25rem;
  font-size: 0.78rem;
}

.infobox th {
  text-align: left;
  padding: 0.3rem 0.4rem;
  font-weight: bold;
  width: 40%;
  vertical-align: top;
  border-bottom: 1px solid var(--wiki-border-light);
}

.infobox td {
  padding: 0.3rem 0.4rem;
  vertical-align: top;
  border-bottom: 1px solid var(--wiki-border-light);
}

/* ==========================================================================
   ARTICLE BODY & TOC
   ========================================================================== */
.article-body {
  font-size: 0.92rem;
  line-height: 1.7;
}

.article-body p {
  margin-bottom: 1rem;
}

.toc {
  background: var(--wiki-toc-bg);
  border: 1px solid var(--wiki-border);
  padding: 0.75rem 1.25rem;
  display: inline-block;
  min-width: 260px;
  margin: 1rem 0 1.5rem 0;
  font-size: 0.82rem;
}

.toc-title {
  font-weight: bold;
  text-align: center;
  margin-bottom: 0.4rem;
}

.toc-toggle {
  color: var(--wiki-link);
  cursor: pointer;
  font-weight: normal;
  margin-left: 0.4rem;
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 0.25rem;
}

.toc-number {
  color: var(--wiki-text-muted);
  margin-right: 0.3rem;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: normal;
  border-bottom: 1px solid var(--wiki-border-light);
  padding-bottom: 0.25rem;
  margin: 1.75rem 0 0.75rem 0;
}

.catlinks {
  border: 1px solid var(--wiki-border);
  background: #f8f9fa;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  margin-top: 2rem;
  clear: both;
}

.catlinks-title {
  font-weight: bold;
  margin-right: 0.4rem;
}

.wiki-footer {
  border-top: 1px solid var(--wiki-border-light);
  background: #f8f9fa;
  padding: 1.5rem 0;
  font-size: 0.75rem;
  color: var(--wiki-text-muted);
  text-align: center;
  margin-top: 3rem;
  width: 100%;
}

.references-list {
  padding-left: 1.5rem;
  font-size: 0.8rem;
  color: var(--wiki-text-muted);
}

.wiki-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

/* ==========================================================================
   iOS SAFARI & IPHONE TAILORED RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* Modern iPhones & Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: flex;
  }

  .mobile-only-header {
    display: flex;
  }

  .wiki-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }

  .header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .brand-text-main {
    font-size: 1.18rem;
  }

  .brand-sub {
    font-size: 0.68rem;
  }

  .brand-logo-img {
    width: 36px;
    height: 36px;
  }

  .wiki-search-box {
    width: 100%;
  }

  .wiki-search-input {
    height: 42px;
    font-size: 16px !important; /* iOS Safari zoom fix */
  }

  .wiki-wrapper {
    grid-template-columns: 1fr !important; /* Strict 1-column layout for iPhone */
    width: 100% !important;
  }

  /* Slide-In Off-Canvas Drawer for iPhone Sandwich Menu */
  .wiki-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 290px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: -webkit-fill-available !important;
    z-index: 9999 !important;
    background: #ffffff !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    transform: translateX(-100%) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: block !important;
    padding: 1.25rem 1rem !important;
    padding-top: max(1.25rem, env(safe-area-inset-top)) !important;
  }

  .wiki-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .sidebar-list li a {
    display: block;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    min-height: 42px; /* Touch friendly tap target */
  }

  .wiki-content {
    padding: 1rem 0.85rem !important;
    padding-left: max(0.85rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.85rem, env(safe-area-inset-right)) !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .article-tabs {
    flex-direction: column;
    gap: 0.4rem;
  }

  .tab-group {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .first-heading {
    font-size: 1.45rem;
    word-break: break-word;
    line-height: 1.25;
  }

  /* Full Width Stacked Hero Section on iPhone */
  .wiki-hero {
    padding: 1rem;
    margin-bottom: 1.25rem;
  }

  .wiki-hero h2 {
    font-size: 1.2rem;
  }

  /* Full Width Main Landing Stack on iPhone */
  .main-landing-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.25rem !important;
    width: 100% !important;
  }

  .az-index-box {
    width: 100% !important;
    margin-top: 0 !important;
  }

  .infobox {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 1rem 0 1.25rem 0 !important;
    display: table !important;
    border-collapse: collapse;
  }

  .infobox-image-box svg {
    max-width: 100% !important;
    height: auto !important;
  }

  .toc {
    width: 100% !important;
    min-width: 100% !important;
    display: block !important;
    margin: 1rem 0 !important;
  }

  .wiki-footer {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* Small iPhone Screens (<= 414px) */
@media (max-width: 414px) {
  .wiki-content {
    padding: 0.75rem 0.6rem !important;
  }

  .infobox th, .infobox td {
    font-size: 0.78rem;
    padding: 0.3rem;
  }

  .first-heading {
    font-size: 1.35rem;
  }
}
