/* ============================================================
   TWP Base Structure — layout, sizing, spacing, typography
   Loaded by ALL themes. Contains no color values.
   ============================================================ */

/* Utility clamps */
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-5 { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.tile-img { height: 140px; object-fit: cover; }

/* Sizing variables (no colors) */
:root {
  --aperture-container-max: 1450px;
  --aperture-sidebar-w: 250px;
  --aperture-content-max: 1200px;

  --twp-nav-z: 1030;
  --twp-nav-pad: 18px;
  --twp-nav-pad-scrolled: 8px;
  --twp-logo-max: 96px;
  --twp-logo-max-scrolled: 52px;
  --twp-masthead-sm: 240px;
  --twp-masthead-lg: 420px;
}

/* Base font */
html, body {
  font-family: "Roboto", system-ui, sans-serif;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.aperture-navbar .container { max-width: var(--aperture-container-max); }

/* Navbar search input */
.aperture-search-input {
  width: 180px;
  border-radius: 4px;
  padding: 4px 8px;
}
.aperture-search-input:focus {
  outline: none;
  box-shadow: none;
}

/* Layout */
.layout-container {
  display: flex;
  justify-content: center;
  padding: 0 2rem;
}

/* Sidebar */
.sidebar {
  flex: 0 0 var(--aperture-sidebar-w);
  max-width: var(--aperture-sidebar-w);
  padding: 0;
}

/* Card structure */
.aperture-card {
  overflow: hidden;
}

.aperture-card::before {
  content: "";
  position: absolute;
  display: none;
}

.aperture-card .card-header {
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
}
.aperture-card .card-header i {
  opacity: 0.9;
}

.aperture-card .list-group-item {
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
}

.sidebar .card:not(:last-child) {
  margin-bottom: 1rem;
}

.main-wrapper {
  flex: 1;
  max-width: var(--aperture-content-max);
  padding-left: 30px;
}
.main-content {
  padding: 20px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Footer */
.footer {
  font-size: 0.9em;
  margin-top: 40px;
  padding: 20px 0;
}

/* ===== News Page Styling ===== */

.news-card {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.news-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  opacity: 0.85;
}

.news-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.news-content {
  line-height: 1.7;
}

.news-quote {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-radius: 0 4px 4px 0;
}

.news-card .card-footer {
  font-size: 0.9rem;
}

.news-card img {
  border-radius: 4px;
  max-height: 400px;
  object-fit: cover;
}

@media (max-width: 768px) {
  .news-card .card-header h5 { font-size: 1rem; }
  .news-card .card-header .small { font-size: 0.8rem; }
}

/* Forum index */
.board-title-link {
  font-weight: 600;
  text-decoration: none;
}

.board-row,
.thread-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  transition: background-color 0.15s ease;
}

.board-info h6, .thread-info h6 { margin: 0; font-weight: 600; }

.board-last, .thread-last {
  text-align: right;
  min-width: 220px;
  flex-shrink: 0;
  font-size: 0.85rem;
}
@media (max-width: 768px) {
  .board-last, .thread-last { display: none; }
}

/* Forum sections */
.forum-section {
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.board-header, .thread-header {
  font-weight: 600;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
}
.thread-header i { opacity: 0.9; }

/* Forum stats */
.forum-stats-container {
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
}
.forum-stats-header {
  padding: 0.5rem 1rem;
  border-radius: 4px 4px 0 0;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ===== Individual Thread / Posts ===== */

.post-container {
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border-left: none;
  padding-left: 0;
  scroll-margin-top: var(--twp-nav-offset, 80px);
}

/* Accent bar pseudo-element */
.post-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  opacity: 0.85;
}

/* Inner content padding accounts for accent bar */
.post-container > .post-header,
.post-container > .post-body,
.post-container > .post-footer {
  padding-left: 1.25rem;
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
}
.post-header .author {
  display: flex;
  align-items: center;
}
.post-header .author img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-right: 1rem;
}
.post-header .author-name {
  font-weight: 600;
  font-size: 1rem;
}

.post-body {
  padding: 1rem 1.25rem;
  line-height: 1.6;
}
.post-body-content img {
  max-width: 100%;
  border-radius: 4px;
}
.post-body blockquote {
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.95rem;
}

.post-footer {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}
.post-footer .reactions span {
  margin-right: 1rem;
}

@media (max-width: 768px) {
  .post-header { flex-direction: column; align-items: flex-start; }
  .post-header .author img { width: 48px; height: 48px; }
  .post-body { font-size: 0.95rem; }
}

/* Ads */
.ad-container {
  border-radius: 4px;
  padding: 0.75rem;
}

/* Quick Reply textarea */
.card-body textarea {
  border-radius: 4px;
  resize: vertical;
}

blockquote {
  border-left-width: 4px;
  border-left-style: solid;
  margin: 0.75rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
}

blockquote blockquote {
  margin-top: 0.5rem;
}

blockquote p {
  margin-bottom: 0.5rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote strong em,
blockquote em strong {
  display: block;
  margin-bottom: 0.25rem;
  font-style: italic;
  font-weight: 600;
}

/* Discord-style spoiler tags */
.spoiler {
  border-radius: 3px;
  padding: 0 0.2em;
  cursor: pointer;
}

/* Fenced code blocks */
pre {
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0.375rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.45;
}

pre code {
  background: none;
  padding: 0;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
  font-size: inherit;
  white-space: pre;
}

/* Inline code */
code {
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

/* ===== Add Reply / New Topic Page Styling ===== */

.reply-card,
.new-topic-card {
  position: relative;
  overflow: hidden;
}

.reply-card::before,
.new-topic-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  opacity: 0.85;
}

.preview-box .preview-content {
  line-height: 1.6;
}

/* ===== Activity Page Styling ===== */

.activity-section {
  position: relative;
  overflow: hidden;
}

.activity-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  opacity: 0.85;
}

.activity-row {
  padding: 0.75rem 1rem;
  transition: background-color 0.15s ease;
}

.activity-info i {
  font-size: 1rem;
  vertical-align: middle;
}

.activity-section .board-header i {
  opacity: 0.9;
}

/* Pagination */
.pagination { margin-bottom: 0; }
.page-item .page-link {
  font-size: 0.875rem;
  padding: 0.25rem 0.6rem;
  transition: all 0.15s ease-in-out;
}
.page-link i { vertical-align: middle; }

/* Breadcrumbs */
nav.small.mb-3 a { text-decoration: none; }

/* ===== Navbar Branding ===== */
.navbar-brand { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.navbar-brand .display-6 { font-size: 1.85rem; line-height: 1.1; }
.navbar-brand small { font-size: 0.85rem; opacity: 0.85; }
.spotlight-image-wrapper { width: 100%; overflow: hidden; }
.spotlight-img { width: 100%; height: auto; object-fit: cover; display: block; }

/* ===== Masthead + Floating Navbar ===== */

.twp-masthead {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.twp-masthead.twp-masthead--sm { min-height: var(--twp-masthead-sm); }
.twp-masthead.twp-masthead--lg { min-height: var(--twp-masthead-lg); }
/* .twp-masthead::before cannot be moved — uses Jinja2 url_for(); remains in base.html */

.twp-float-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--twp-nav-z);
  transition: background-color 0.6s ease, box-shadow 0.6s ease,
              padding 0.6s, border-bottom-color 0.6s ease;
  padding: var(--twp-nav-pad) 0;
}
.twp-float-nav .navbar-brand img {
  max-height: var(--twp-logo-max);
  transition: max-height 0.6s;
}
.twp-float-nav.twp-nav-scrolled {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: var(--twp-nav-pad-scrolled) 0;
}
.twp-float-nav.twp-nav-scrolled .navbar-brand img {
  max-height: var(--twp-logo-max-scrolled);
}

/* ===== Home Hero ===== */
.hero-card { border: 0; overflow: hidden; }
.hover-shadow:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.12); transition: 0.2s ease; }
.social-post { white-space: pre-wrap; }

/* ===== Portal Brand Buttons ===== */
.btn-outline-portal-orange {
  border-width: 2px;
  transition: all 0.2s ease-in-out;
}
.btn-outline-portal-blue {
  border-width: 2px;
  transition: all 0.2s ease-in-out;
}

/* ===== Download Listing Rows ===== */
.download-row {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.download-row:hover {
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.thumbnail-wrapper img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

/* ===== Download Index Featured Card ===== */
.featured-card img {
  object-fit: cover;
  height: 300px;
}

/* ===== Download Comments ===== */
.comment-block { border-radius: 6px; padding: 10px 12px; }
.comment-child { margin-left: 30px; border-radius: 0; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.comment-username { font-weight: 600; font-size: 0.95rem; }
.comment-meta { font-size: 0.8rem; }
.comment-actions { margin-top: 5px; }
.reply-form { display: none; }
.edit-comment-form { display: none; }
.rating-buttons .btn { font-size: 1.75rem; border-width: 2px; }
.rating-buttons .btn i { vertical-align: middle; }

/* ===== Screenshot Lightbox ===== */
.screenshot-thumb:hover,
.post-image-thumb:hover {
  opacity: 0.85;
  transition: 0.2s;
}
#lightbox-close, #lightbox-prev, #lightbox-next,
#post-lightbox-close, #post-lightbox-prev, #post-lightbox-next {
  z-index: 3;
  opacity: 0.7;
  transition: 0.2s;
  border: none;
}
#lightbox-close, #lightbox-prev:hover, #lightbox-next:hover,
#post-lightbox-close, #post-lightbox-prev:hover, #post-lightbox-next:hover {
  opacity: 1;
}
.lightbox-main-img { max-height: 85vh; }

/* ===== Post Action Buttons ===== */
.post-action-btn {
  padding: 0.2rem 0.35rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.post-action-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  display: inline-block;
  transition: max-width 0.18s ease, opacity 0.12s ease;
}
.post-action-btn:hover .post-action-label {
  max-width: 60px;
  opacity: 1;
}

/* ===== Mod Tools Modal ===== */
#modToolsModal .board-radio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
}
@media (max-width: 768px) {
  #modToolsModal .board-radio-grid { grid-template-columns: 1fr; }
}
#modToolsModal .board-radio {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: start;
  gap: 0.5rem;
}
#modToolsModal .board-radio input { margin-top: 0.25rem; }
#modToolsModal .board-meta { line-height: 1.15; }
#modToolsModal .board-meta .board-name { font-weight: 600; }

/* ===== Emoji Accordion ===== */
.emoji-accordion .emoji-cell {
  cursor: pointer;
  user-select: none;
  border-radius: .5rem;
  padding: .25rem .5rem;
}
.emoji-accordion pre { padding: 0; }

/* ===== Emoji Images ===== */
.emoji-img {
  max-width: 100px;
  max-height: 100px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: inline-block;
}

/* ===== Layout Utilities ===== */
.form-narrow { max-width: 420px; }
.form-wide { max-width: 860px; }
.form-max { max-width: 900px; }
.sticky-save-bar { position: sticky; bottom: 0; z-index: 50; }
.error-icon-circle { width: 84px; height: 84px; }
.error-icon-circle i { font-size: 2rem; }
.error-traceback { max-height: 260px; white-space: pre-wrap; }
.avatar-preview-lg { width: 120px; height: 120px; object-fit: cover; }
.avatar-preview-sm { width: 100px; height: 100px; object-fit: cover; }
.sig-preview { white-space: pre-wrap; min-height: 1.4em; }
.screenshot-thumb-img { width: 320px; height: 200px; object-fit: cover; cursor: pointer; }
.lightbox-thumb-img { width: 120px; height: 75px; object-fit: cover; cursor: pointer; }
.dl-thumb-container { width: 160px; position: relative; overflow: hidden; }
.dl-thumb-container-sm { width: 200px; position: relative; overflow: hidden; }
.dl-thumb-container-attach { width: 140px; height: 100px; position: relative; overflow: hidden; cursor: pointer; }
.dl-thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-warning-accent { border-left-width: 3px !important; border-left-style: solid !important; }
.profile-avatar { object-fit: cover; }

/* ===== Mobile / Responsive ===== */

/* Sidebar overlay (mobile drawer backdrop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 991.98px) {
  /* Show overlay on mobile */
  .sidebar-overlay { display: block; }

  /* Sidebar becomes a fixed off-canvas drawer (slides in from right) */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 1040;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    padding: 1rem;
    background: var(--bs-body-bg, #fff);
    flex: none;
    max-width: none;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Layout: main content fills full width */
  .layout-container {
    padding: 0 0.75rem;
  }
  .main-wrapper {
    padding-left: 0;
    max-width: 100%;
  }
  .main-content {
    padding: 12px;
  }

  /* Masthead — shorter on mobile */
  .twp-masthead.twp-masthead--sm { min-height: 160px; }
  .twp-masthead.twp-masthead--lg { min-height: 260px; }

  /* Navbar — touch-friendly link height */
  .navbar-nav .nav-link {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }

  /* Notification badges: absolute positioning breaks in stacked collapsed nav */
  .nav-item .badge.position-absolute {
    position: static !important;
    transform: none !important;
    display: inline-flex;
    vertical-align: middle;
    margin-left: 0.35rem;
  }

  /* Align all collapsed nav items consistently to the left */
  .navbar-collapse .navbar-nav {
    align-items: flex-start;
  }

  /* Username display — slightly smaller in collapsed nav */
  .navbar-text {
    font-size: 0.9rem;
  }

  /* Screenshot thumbnails — prevent horizontal overflow */
  .screenshot-thumb-img {
    width: 100%;
    max-width: 320px;
    height: 180px;
  }

  /* Nested comment indentation — reduce on mobile */
  .comment-child {
    margin-left: 15px;
  }

  /* Forum rows — tighter spacing */
  .board-row, .thread-row {
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
  }

  /* Pagination — larger touch targets */
  .page-item .page-link {
    padding: 0.4rem 0.75rem;
    min-width: 36px;
    text-align: center;
  }

  /* Download thumb containers */
  .dl-thumb-container    { width: 120px; }
  .dl-thumb-container-sm { width: 140px; }
}

@media (min-width: 992px) {
  /* Desktop: ensure overlay is always hidden */
  .sidebar-overlay { display: none !important; }
}
