/* ========================================
   COLOR VARIABLES
   ======================================== */
:root {
  /* Purple scale */
  --color-purple-darkest: #4a148c;
  --color-purple-dark: #6a1b9a;
  --color-purple-medium: #7e57c2;
  --color-purple-light: #b39ddb;
  --color-purple-lightest: #d1c4e9;
  --color-purple-pale: #CCBEE7;
  
  /* Blue scale */
  --color-blue-dark: #1565c0;
  --color-blue-medium: #42a5f5;
  --color-blue-badge: #5C9ED1;
  
  /* Backgrounds */
  --bg-body: #BEC5E7;
  --bg-white: white;
  
  /* Borders */
  --border-primary: var(--color-purple-light);
  --border-secondary: var(--color-purple-lightest);
  
  /* Text Colors */
  --text-primary: #4a148c;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header header"
    "nav main aside"
    "footer footer footer";
  gap: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-weight: 300;
  font-size: 12px;
  color: var(--text-primary);
  background-color: var(--bg-body);
  padding: 0;
}



a {
  text-decoration: none;
  color: var(--text-primary);
}

a:hover, .page-article .internal-nav-bar a:hover {
  background-color: var(--color-purple-lightest);
}

h2, .page-article .internal-nav-bar h2 {
  padding: 2px 4px;
  background: linear-gradient(to top, var(--color-purple-pale), var(--bg-white));
  border-bottom: 2px solid var(--border-primary);
  font-weight: 400;
  font-size: 14px;
}

/* ========================================
   SITE-WIDE HEADER
   ======================================== */
body > header {
  grid-area: header;
  background: linear-gradient(to bottom, var(--color-purple-pale), var(--color-purple-medium));
  color: white;
  border-bottom: 2px solid var(--border-primary);
  padding: 2px 4px;
}

/* ========================================
   SITE-WIDE FOOTER
   ======================================== */
body > footer {
  grid-area: footer;
  background: var(--border-secondary);
  border-top: 2px solid var(--border-primary);
  padding: 2px 4px;
}

/* ========================================
   LEFT NAVIGATION (DEFAULT)
   ======================================== */
body > nav {
  grid-area: nav;
  background-color: var(--bg-white);
  border-right: 2px solid var(--border-primary);
}

body > nav li a, .page-article .internal-nav-bar, body > aside nav li a {
  display: block;
  padding: 2px 4px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.2s ease;
  border-bottom: 1px solid var(--border-secondary);
}

body > aside p {
  display: block;
  padding: 2px 4px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-secondary);
}

/* ========================================
   MAIN CONTENT (DEFAULT)
   ======================================== */
body > main {
  grid-area: main;
  background-color: var(--bg-body);
  padding: 2px 4px;
}

/* ========================================
   RIGHT ASIDE (DEFAULT)
   ======================================== */
body > aside {
  grid-area: aside;
  background-color: var(--bg-white);
  border-left: 2px solid var(--border-primary);
}

/* ========================================
   PORTAL PAGE
   ======================================== */

/* Portal: Main Content Grid */
.page-portal main {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

/* Portal: Link Cards & Text Cards */
.link-card, 
.text-card {
  background: white;
  border: 2px solid var(--border-primary);
  padding: 0;
}

.page-portal p {
  padding: 2px 4px;
}

/* Portal: Links in cards */
.page-portal main li a {
  display: block;
  padding: 2px 4px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.2s ease;
  border-bottom: 1px solid var(--border-secondary);
}

.page-portal main li:last-child a {
  border-bottom: 0;
}

/* Portal: Text card inline links */
.text-card a {
  display: inline;
  padding: 0;
  text-decoration: underline dashed;
  text-decoration-thickness: 1px;
  font-weight: 400;
}

/* Portal: Log Feed in Aside */
.log-feed {
  border-bottom: 1px solid var(--border-primary);
}

.log-feed time {
  display: block;
  font-weight: 500;
  font-size: 14px;
  background: linear-gradient(to bottom, var(--color-purple-pale), var(--bg-white));
  border-top: 1px solid var(--border-primary);
  padding: 2px 4px;
}

.log-feed article:first-child time {
  border-top: 0;
}

/* ========================================
   ARTICLE PAGE
   ======================================== */

/* Article: Grid Layout - wider main column */
body.page-article {
  grid-template-columns:2fr 1fr;
    grid-template-areas:
    "header header"
    "main aside"
    "footer footer";
  gap: 0;
}

/* Article: Header */
.page-article > header p {
  font-style: italic;
}

/* Article: Left Navigation */
.page-article nav {
  background: white;
  border: 2px solid var(--border-primary);
  border-top: 0;
  border-left: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 300;
}

.page-article .internal-nav-bar {
  width: 160px;
  margin: 0 12px 0 0;
  padding:0;
  width: 160px;
  float: left;
}

.page-article nav li a {
  display: block;
  padding: 2px 4px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.2s ease;
  border-bottom: 1px solid var(--border-secondary);
}

/* Article: TOC specific styling */
.page-article nav #toc {
  padding: 0;
  margin: 0;
  border:0;
}

.page-article nav #toc ul {
  padding: 0;
  margin: 0;
  list-style: none;
  border: 0;
}

.page-article nav #toc li {
  margin: 0;
  padding: 0;
  border: 0;
}

.page-article nav #toc li a {
  display: block;
  padding: 2px 4px;
  border-bottom: 1px solid var(--border-secondary);
}

/* Article: Main Content */
.page-article main {
  padding: 0;
  display: flex;
  gap: 0;
}

.page-article main article {
  background: white;
  color: black;
  font-size: 16px;
  font-weight: 400;
  border: 2px solid var(--border-primary);
  margin: 20px;
  flex: 1;
}

.page-article main article header {
  background: linear-gradient(to top, var(--color-purple-pale), var(--bg-white));
  padding: 2px 4px;
  border-bottom: 1px solid var(--border-primary);
}

.page-article main article header h1 {
  text-align: center;
}

.page-article main article header p {
  text-align: right;
}

.page-article main article p {
  padding: 8px 20px;
}

.page-article main article h2 {
  padding: 16px 20px 8px 20px;
  border-bottom: 1px solid var(--border-secondary);
  background: none;
  border-top: 0;
}

/* Article: Right Aside - Marginalia */
.page-article aside {
  position: relative;
  background-color: var(--bg-body);
  border-left: 0;
  padding: 0 4px;
  margin: 20px 25px 20px 0;
}

.marginalia {
  background: white;
  border: 2px solid var(--border-primary);
  padding: 0;
  margin-bottom: 8px;
}

.marginalia h2 {
  font-size: 12px;
  margin: 0;
  padding: 2px 4px;
}

.marginalia ul {
  padding: 0;
  margin: 0;
}

.marginalia li {
  margin: 0;
}

.marginalia li a {
  display: block;
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border-secondary);
}

.marginalia li:last-child a {
  border-bottom: 0;
}

/* ========================================
   FORUM INDEX PAGE
   ======================================== */

.page-forum main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

/* Forum category groups - rounded with spacing */
.forum-group {
  background: white;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  overflow: hidden;
}

/* Forum category headers - flat color, rounded top */
.forum-group header {
  background: var(--color-purple-medium);
  color: white;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-primary);
}

.forum-group header h2 {
  background: none;
  border: none;
  color: white;
  padding: 0;
  margin: 0;
}

/* Board list */
.forum-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Individual board items - TWO COLUMN LAYOUT */
.page-forum .forum-group li {
  display: grid !important;
  grid-template-columns: 1fr 200px !important;
  padding: 0 !important;
  border-bottom: 1px solid var(--border-secondary);
  position: relative;
}

.forum-group li:last-child {
  border-bottom: none;
}

/* Board link - takes up left portion with nested grid */
.board-link {
  display: grid;
  grid-template-columns: 40px 1fr 80px 80px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  text-decoration: none;
  color: inherit;
}

.board-link:hover {
  background-color: var(--color-purple-lightest);
}

/* Thread/Board icon */
.thread-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: white;
}

.thread-icon.has-essay {
  background: linear-gradient(to bottom, var(--color-purple-pale), white);
  color: var(--color-purple-dark);
}

.thread-icon.no-essay {
  background: #e8e8e8;
  color: #aaa;
  border-color: #bbb;
  filter: grayscale(100%);
  opacity: 0.5;
}

/* Board info */
.thread-info h3 {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.thread-info p {
  margin: 0;
  font-size: 12px;
  color: #666;
}

/* Board stats */
.thread-stats {
  text-align: center;
  font-size: 12px;
}

.thread-stats .number {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-purple-dark);
}

.thread-stats .label {
  display: block;
  color: #666;
}

/* Latest thread link - takes up right portion */
.thread-latest {
  font-size: 12px;
}

.thread-latest a {
  display: block;
  padding: 12px;
  text-decoration: none;
  color: var(--color-purple-dark);
  font-weight: 500;
  height: 100%;
}

.thread-latest a:hover {
  background-color: var(--color-purple-lightest);
}

.thread-latest .latest-label {
  font-weight: 400;
  color: #666;
}

.thread-latest .timestamp {
  display: block;
  color: #666;
  font-weight: 400;
  margin-top: 2px;
}

/* Remove bullets from aside */
.page-forum aside ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-forum ul, .page-forum nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ========================================
   FORUM BOARD VIEW PAGE
   ======================================== */

.page-forum-board main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Board Header */
.board-header {
  background: white;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  padding: 16px 20px;
}

.board-header h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
}

.board-header p {
  margin: 0;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

/* Thread List Container */
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: white;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  overflow: hidden;
}

/* Individual Thread Item */
.thread-item {
  display: grid;
  grid-template-columns: 40px 1fr 120px 200px;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-secondary);
  align-items: start;
}

.thread-item:last-child {
  border-bottom: none;
}

.thread-item:hover {
  background-color: var(--color-purple-lightest);
}

/* Thread Icon (reuse from forum index) */
.thread-item .thread-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: linear-gradient(to bottom, var(--color-purple-pale), white);
  color: var(--color-purple-dark);
  flex-shrink: 0;
}

/* Thread Main Info */
.thread-main h2 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
}

.thread-main h2 a {
  color: var(--text-primary);
  text-decoration: none;
}

.thread-main h2 a:hover {
  color: var(--color-purple-dark);
  text-decoration: underline;
}

.thread-meta {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: #666;
}

.thread-meta strong {
  font-weight: 500;
  color: var(--color-purple-dark);
}

.thread-preview {
  margin: 0;
  font-size: 13px;
  color: #444;
  line-height: 1.5;
}

/* Thread Stats */
.thread-item .thread-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.thread-item .stat {
  text-align: center;
}

.thread-item .stat .number {
  display: block;
  font-size: 18px;
  font-weight: 500;
  color: var(--color-purple-dark);
  line-height: 1;
}

.thread-item .stat .label {
  display: block;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Thread Latest Post */
.thread-item .thread-latest {
  padding-top: 4px;
}

.latest-post {
  margin: 0;
}

.post-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 4px;
}

.post-title:hover {
  color: var(--color-purple-dark);
  text-decoration: underline;
}

.post-meta {
  display: block;
  font-size: 11px;
  color: #666;
  margin-bottom: 2px;
}

.post-meta strong {
  font-weight: 500;
  color: var(--color-purple-dark);
}

.timestamp {
  display: block;
  font-size: 11px;
  color: #999;
}

/* Breadcrumb current item */
.page-forum-board nav a.current {
  font-weight: 500;
  background-color: var(--color-purple-lightest);
}

/* ========================================
   FORUM THREAD VIEW PAGE
   ======================================== */

.page-thread {
  grid-template-columns: 160px 1fr 200px;
}

.page-thread main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Thread Header */
.page-thread main > header {
  background: linear-gradient(to top, var(--color-purple-pale), var(--bg-white));
  border: 2px solid var(--border-primary);
  border-radius: 12px 12px 0 0;
  padding: 16px 20px;
  border-bottom: 0;
}

.page-thread main > header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
}

.page-thread main > header p {
  margin: 0;
  font-size: 14px;
  color: #666;
  font-style: italic;
}

/* Individual Post */
.post {
  display: grid;
  grid-template-columns: 160px 1fr;
  background: white;
  border: 2px solid var(--border-primary);
  border-top: 0;
  gap: 0;
}

.post:last-child {
  border-radius: 0 0 12px 12px;
}

/* Post Sidebar - User Info */
.post-sidebar {
  background: linear-gradient(to right, var(--bg-white), var(--color-purple-lightest));
  border-right: 2px solid var(--border-primary);
  padding: 16px 12px;
  text-align: center;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--border-primary);
  background: linear-gradient(to bottom, var(--color-purple-pale), white);
  margin: 0 auto 12px auto;
}

.username {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-title {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: #666;
  font-style: italic;
}

.post-count {
  margin: 0;
  font-size: 11px;
  color: #999;
}

/* Post Content */
.post-content {
  padding: 16px 20px;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-secondary);
}

.post-number {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-purple-dark);
}

.post-date {
  font-size: 11px;
  color: #999;
}

.post-body {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}

.post-body p {
  margin: 0 0 12px 0;
}

.post-body p:last-child {
  margin-bottom: 0;
}

/* Thread Navigation - Key Exchanges */
.page-thread nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-thread nav li {
  margin: 0;
}

.page-thread nav a.current {
  font-weight: 500;
  background-color: var(--color-purple-lightest);
}

/* Right Aside */
.page-thread aside {
  background-color: var(--bg-white);
  border-left: 2px solid var(--border-primary);
}

.page-thread aside section {
  border-bottom: 1px solid var(--border-secondary);
}

.page-thread aside nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

ul, nav ul, nav, aside nav {
  list-style: none;
}