/* External Validity - Main Stylesheet */

:root {
  --primary: #2c5282;
  --primary-dark: #1a365d;
  --primary-light: #4299e1;
  --accent: #ed8936;
  --text: #2d3748;
  --text-light: #718096;
  --bg: #ffffff;
  --bg-alt: #f7fafc;
  --border: #e2e8f0;
  --code-bg: #edf2f7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  line-height: 1.7;
  background: var(--bg);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75em;
  color: var(--primary-dark);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; margin-top: 2rem; }
h3 { font-size: 1.35rem; margin-top: 1.5rem; }

p { margin-bottom: 1.25rem; }

a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

a:hover { border-bottom-color: var(--primary); }

nav {
  background: var(--primary-dark);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav .logo {
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 1rem 0;
  border: none;
}

nav .logo:hover { border: none; opacity: 0.9; }

nav ul {
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

nav ul li a {
  color: rgba(255,255,255,0.85);
  padding: 1rem 1.25rem;
  display: block;
  border: none;
  font-size: 0.95rem;
  transition: background 0.2s, color 0.2s;
}

nav ul li a:hover,
nav ul li a.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
}

.hero h1 {
  color: white;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.hero .subtitle {
  font-size: 1rem;
  opacity: 0.85;
  max-width: 700px;
  margin: 0 auto;
  font-style: italic;
}

.hero .subtitle-line2 {
  display: none;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}

.card-grid-3 .card {
  padding: 1.25rem;
}

.card-grid-3 .card p {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.card h3 {
  margin-top: 0;
  color: var(--primary);
}

.card .label {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25em 0.6em;
  border-radius: 3px;
  margin-bottom: 0.75rem;
}

.framework-grid-mstout {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr 1fr 1fr 1fr;
  gap: 0.5rem;
  margin: 2rem 0;
  align-items: center;
}

.framework-dash {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  padding: 0 0.25rem;
}

.framework-item {
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 1rem 0.5rem;
  text-align: center;
  transition: all 0.2s;
}

.framework-item:hover {
  border-color: var(--primary);
  background: white;
}

.framework-item.mechanism {
  background: #ebf8ff;
  border-color: var(--primary-light);
}

.framework-item .letter {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.framework-item .name {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

dl { margin: 1.5rem 0; }
dt { font-weight: 600; color: var(--primary-dark); margin-top: 1rem; }
dd { margin-left: 1.5rem; color: var(--text); }

code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border-radius: 5px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-outline { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover { background: var(--primary); color: white; }

.paper {
  border-left: 4px solid var(--primary);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg-alt);
}

.paper h3 { margin-top: 0; font-size: 1.1rem; }
.paper .authors { color: var(--text-light); font-size: 0.95rem; }
.paper .venue { font-style: italic; color: var(--text-light); font-size: 0.9rem; }
.paper .links { margin-top: 0.75rem; }
.paper .links a { margin-right: 1rem; font-size: 0.9rem; }

.callout {
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  margin: 1.5rem 0;
}

.callout-info { background: #ebf8ff; border-left: 4px solid var(--primary-light); }
.callout-warning { background: #fffaf0; border-left: 4px solid var(--accent); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 2rem 0;
}

/* Team cards with photo */
.team-row {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: flex-start;
}

.team-photo {
  width: 150px;
  height: 150px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.team-photo-placeholder {
  width: 150px;
  height: 150px;
  border-radius: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.team-info {
  flex: 1;
}

.team-info h3 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.team-info .title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.team-info .affiliation {
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.team-info .contact {
  font-size: 0.9rem;
}

.team-info .contact a {
  display: inline-block;
  margin-right: 1rem;
}

/* Tool cards for Shiny */
.tool-section {
  margin-bottom: 2.5rem;
}

.tool-section h3 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
}

.tool-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--primary);
}

.tool-card p {
  margin: 0;
  color: var(--text-light);
  font-size: 0.85rem;
  line-height: 1.5;
}

footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 4rem;
}

footer a { color: var(--text-light); }

@media (max-width: 900px) {
  .card-grid-3, .tool-grid { grid-template-columns: 1fr; }
  .team-row { flex-direction: column; align-items: center; text-align: center; }
  .team-info .contact { text-align: center; }
}

@media (max-width: 768px) {
  html { font-size: 16px; }
  nav .nav-container { flex-direction: column; padding: 0.5rem 0; }
  nav ul { flex-wrap: wrap; justify-content: center; }
  .hero h1 { font-size: 2rem; }
  .hero .subtitle { font-size: 1.1rem; }
  .framework-grid-mstout { grid-template-columns: 1fr auto 1fr 1fr; gap: 0.4rem; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .framework-grid-mstout { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .framework-dash { display: none; }
}

/* Dropdown Menu Styles */
nav ul li {
  position: relative;
}

nav ul li .dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--primary-dark);
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-radius: 0 0 6px 6px;
  z-index: 200;
}

nav ul li:hover .dropdown {
  display: block;
}

nav ul li .dropdown a {
  padding: 0.75rem 1.25rem;
  display: block;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

nav ul li .dropdown a:last-child {
  border-bottom: none;
  border-radius: 0 0 6px 6px;
}

nav ul li .dropdown a:hover {
  background: rgba(255,255,255,0.15);
}

/* Dropdown arrow indicator */
nav ul li.has-dropdown > a::after {
  content: " ▾";
  font-size: 0.7em;
  opacity: 0.7;
}

/* Fix dropdown - hide by default, show on hover */
nav ul li .dropdown {
  display: none !important;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--primary-dark);
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-radius: 0 0 6px 6px;
  z-index: 200;
  padding: 0;
  margin: 0;
}

nav ul li.has-dropdown:hover .dropdown {
  display: block !important;
}

nav ul li .dropdown a {
  padding: 0.75rem 1.25rem;
  display: block;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* R Package page styles */
.badge-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
  border: none;
}

.badge-cran { background: #4CAF50; color: white; }
.badge-github { background: #333; color: white; }
.badge-lifecycle { background: #FFC107; color: #333; }

.code-block {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-block code {
  background: none;
  padding: 0;
}

.function-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.function-item {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
}

.function-item code {
  font-weight: 600;
  color: var(--primary);
}

.function-item p {
  margin: 0.5rem 0 0 0;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Library table styles */
.library-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.library-table th {
  background: var(--primary-dark);
  color: white;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
}

.library-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.library-table tr:hover {
  background: var(--bg-alt);
}

.library-table .link-cell {
  display: flex;
  gap: 0.5rem;
}

.library-table .link-cell a {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-alt);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.library-table .link-cell a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Causal cakes figure styles */
.cake-example {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.cake-example h4 {
  margin-top: 0;
  color: var(--primary);
}

.cake-example img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 4px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 2rem 0;
}

.feature-box {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.feature-box .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.feature-box h4 {
  margin: 0 0 0.5rem 0;
  color: var(--primary);
}

.feature-box p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-light);
}

@media (max-width: 768px) {
  .feature-grid { grid-template-columns: 1fr; }
}
