/* Engineering Articles Styling */

/* Article Layout */
.engineering-article {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 250px;
    gap: 0;
}

.article-content {
    padding: 40px 50px;
}

.article-sidebar {
    background: rgba(255, 255, 255, 0.8);
    padding: 30px 20px;
    border-left: 1px solid rgba(102, 126, 234, 0.2);
}

/* Article Header */
.article-header {
    margin-bottom: 40px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
    padding-bottom: 30px;
}

.breadcrumb {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 15px;
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.separator {
    margin: 0 8px;
    color: #9ca3af;
}

.current {
    color: #374151;
    font-weight: 500;
}

.article-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1f2937;
    margin: 20px 0;
    line-height: 1.2;
}

.article-title i {
    color: #667eea;
    margin-right: 15px;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #6b7280;
}

.meta-item i {
    color: #667eea;
    width: 16px;
}

.difficulty {
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty.beginner {
    background: #10b981;
    color: white;
}

.difficulty.intermediate {
    background: #f59e0b;
    color: white;
}

.difficulty.advanced {
    background: #ef4444;
    color: white;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Article Content */
.article-intro {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 40px;
    border-left: 4px solid #0ea5e9;
}

.lead {
    font-size: 1.2rem;
    line-height: 1.7;
    color: #374151;
    margin-bottom: 25px;
    font-weight: 500;
}

.quick-nav {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.quick-nav h4 {
    color: #1f2937;
    margin-bottom: 15px;
    font-weight: 600;
}

.quick-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quick-nav li {
    margin-bottom: 8px;
}

.quick-nav a {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.quick-nav a:hover {
    color: #0284c7;
    text-decoration: underline;
}

.content-section {
    margin-bottom: 50px;
}

.article-content-main section {
    margin-bottom: 30px; /* Add spacing between sections */
}

.content-section h2 {
    font-size: 2rem;
    color: #1f2937;
    margin-bottom: 25px;
    font-weight: 700;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.content-section h2 i {
    color: #667eea;
    margin-right: 12px;
}

.content-section h3 {
    font-size: 1.5rem;
    color: #374151;
    margin: 30px 0 20px 0;
    font-weight: 600;
}

.content-section h4 {
    font-size: 1.2rem;
    color: #4b5563;
    margin: 25px 0 15px 0;
    font-weight: 600;
}

.content-section p {
    line-height: 1.7;
    color: #4b5563;
    margin-bottom: 15px;
}

/* Concept Boxes */
.concept-box {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.concept-box h3 {
    color: #1f2937;
    margin-top: 0;
    font-size: 1.3rem;
}

.key-points h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1rem;
}

.key-points ul {
    list-style-type: none;
    padding: 0;
}

.key-points li {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    padding-left: 20px;
}

.key-points li:before {
    content: "→";
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.key-points li:last-child {
    border-bottom: none;
}

/* Technical Details */
.technical-details {
    background: #f8fafc;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.detail-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.detail-item i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 12px;
}

.detail-item h5 {
    color: #1f2937;
    margin-bottom: 8px;
    font-weight: 600;
}

.detail-item p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Comparison Table */
.comparison-table {
    overflow-x: auto;
    margin: 20px 0;
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.comparison-table th,
.comparison-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.comparison-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.comparison-table tbody tr:hover {
    background: #f8f9fa;
}

/* Problem Solution Box */
.problem-solution-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin: 30px 0;
}

.problem,
.solution {
    padding: 25px;
    border-radius: 12px;
}

.problem {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-left: 4px solid #ef4444;
}

.solution {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid #10b981;
}

.problem h3,
.solution h3 {
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.problem h3 i {
    color: #ef4444;
}

.solution h3 i {
    color: #10b981;
}

.stats {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.stat {
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    flex: 1;
}

.stat .number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ef4444;
}

.stat .label {
    display: block;
    font-size: 14px;
    color: #6b7280;
    margin: 5px 0;
}

.stat .description {
    display: block;
    font-size: 12px;
    color: #9ca3af;
}

/* Timeline */
.leap-second-timeline {
    margin-top: 20px;
}

.timeline {
    list-style: none;
    padding: 0;
}

.timeline li {
    padding: 10px 0;
    padding-left: 20px;
    position: relative;
    border-left: 2px solid #10b981;
}

.timeline li:before {
    content: "";
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    position: absolute;
    left: -6px;
    top: 15px;
}

/* Code Examples */
.code-example {
    background: #1f2937;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    color: white;
}

.code-example h3 {
    color: white;
    margin-top: 0;
}

.code-example pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    margin: 15px 0;
}

.code-example code {
    color: #fbbf24;
}

.warning-box {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.warning-box i {
    color: #f59e0b;
    font-size: 1.2rem;
    margin-top: 2px;
}

.warning-box h4 {
    color: #92400e;
    margin: 0 0 8px 0;
}

.warning-box p {
    color: #92400e;
    margin: 0;
}

/* Clock Types */
.clock-types {
    margin: 30px 0;
}

.clock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.clock-type {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.clock-type h4 {
    color: #1f2937;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.clock-type h4 i {
    color: #667eea;
}

.specs {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.specs span {
    background: #f3f4f6;
    color: #374151;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.clock-type ul {
    list-style-type: none;
    padding: 0;
}

.clock-type li {
    padding: 6px 0 6px 20px;
    position: relative;
    color: #6b7280;
    font-size: 14px;
}

.clock-type li:before {
    content: "•";
    color: #667eea;
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* NTP Process Steps */
.ntp-process {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.step {
    text-align: center;
    padding: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    position: relative;
}

.step-number {
    width: 40px;
    height: 40px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin: 0 auto 15px auto;
    font-size: 1.2rem;
}

.step h4 {
    color: #1f2937;
    margin-bottom: 10px;
}

.step p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
    font-family: 'Courier New', monospace;
}

/* Formula Box */
.ntp-math {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
}

.formula-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.formula {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.formula code {
    background: #1f2937;
    color: #fbbf24;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    display: inline-block;
    margin-top: 8px;
}

/* Stratum Diagram */
.stratum-diagram {
    margin: 30px 0;
}

.stratum-level {
    margin-bottom: 20px;
    text-align: center;
}

.stratum-box {
    display: inline-block;
    padding: 20px 30px;
    border-radius: 12px;
    color: white;
    min-width: 250px;
    position: relative;
}

.stratum-0 { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); }
.stratum-1 { background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%); }
.stratum-2 { background: linear-gradient(135deg, #ca8a04 0%, #a16207 100%); }
.stratum-n { background: linear-gradient(135deg, #059669 0%, #047857 100%); }

.stratum-box h4 {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
}

.stratum-box p {
    margin: 0 0 10px 0;
    font-weight: 500;
}

.stratum-box .examples {
    font-size: 12px;
    opacity: 0.9;
    font-style: italic;
}

/* Best Practices */
.best-practices {
    margin: 40px 0;
}

.practice-category {
    margin-bottom: 35px;
    background: white;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.practice-category h4 {
    color: #1f2937;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
}

.practice-category h4 i {
    color: #667eea;
    font-size: 1.1rem;
}

.practice-list {
    list-style: none;
    padding: 0;
}

.practice-list li {
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    padding-left: 20px;
}

.practice-list li:before {
    content: "✓";
    color: #10b981;
    font-weight: bold;
    position: absolute;
    left: 0;
    top: 12px;
}

.practice-list li:last-child {
    border-bottom: none;
}

.practice-list strong {
    color: #1f2937;
}

/* Common Pitfalls */
.pitfall-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.pitfall-item {
    background: white;
    border: 1px solid #fee2e2;
    border-radius: 12px;
    padding: 25px;
    border-left: 4px solid #ef4444;
}

.pitfall-item i {
    color: #ef4444;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.pitfall-item h4 {
    color: #1f2937;
    margin: 0 0 10px 0;
}

.pitfall-item p {
    color: #6b7280;
    margin: 0 0 15px 0;
    font-size: 14px;
}

.solution {
    background: #f0fdf4;
    color: #166534;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #bbf7d0;
}

/* Tools Grid */
.tool-category {
    margin-bottom: 25px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tool-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-size: 14px;
}

.tool-item strong {
    color: #667eea;
}

/* Article Conclusion */
.article-conclusion {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 40px;
    margin: 50px 0;
    border: 1px solid #e2e8f0;
}

.article-conclusion h2 {
    color: #1f2937;
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.next-steps {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.8);
    padding: 25px;
    border-radius: 8px;
}

.next-steps h3 {
    color: #374151;
    margin-top: 0;
}

.next-steps ul {
    list-style: none;
    padding: 0;
}

.next-steps li {
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
}

.next-steps li:before {
    content: "📚";
    position: absolute;
    left: 0;
}

.external-link {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 500;
}

.external-link:hover {
    text-decoration: underline;
}

/* Sidebar */
.table-of-contents {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid #e5e7eb;
    position: sticky;
    top: 20px;
}

.table-of-contents h3 {
    color: #1f2937;
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.table-of-contents li {
    margin-bottom: 10px;
}

.table-of-contents a {
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.table-of-contents a:hover {
    color: #667eea;
    text-decoration: underline;
}

.related-articles {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid #e5e7eb;
}

.related-articles h3 {
    color: #1f2937;
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.related-article {
    padding: 15px 0;
    border-bottom: 1px solid #f3f4f6;
}

.related-article:last-child {
    border-bottom: none;
}

.related-article h4 {
    color: #374151;
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
}

.related-article p {
    color: #9ca3af;
    margin: 0;
    font-size: 12px;
    font-style: italic;
}

/* Reading Progress */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(102, 126, 234, 0.2);
    z-index: 1000;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* Algorithm and Challenge Boxes */
.algorithm-box {
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.algorithm-box h5 {
    color: #0c4a6e;
    margin: 0 0 15px 0;
}

.algorithm-box ol {
    margin: 0;
    padding-left: 20px;
}

.algorithm-box li {
    padding: 5px 0;
    color: #374151;
}

.example-scenario {
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.example-scenario h5 {
    color: #1f2937;
    margin: 0 0 15px 0;
}

.example-scenario pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    margin: 10px 0;
    font-size: 14px;
    overflow-x: auto;
}

.challenge-grid,
.cause-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.challenge-item,
.cause-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.challenge-item i,
.cause-item i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

.challenge-item h4,
.cause-item h5 {
    color: #1f2937;
    margin: 0 0 10px 0;
}

.challenge-item p,
.cause-item p {
    color: #6b7280;
    margin: 0;
    font-size: 14px;
}

/* Protocol Comparison */
.protocol-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.protocol {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.protocol h4 {
    color: #1f2937;
    margin: 0 0 15px 0;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.protocol ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.protocol li {
    padding: 10px 0 10px 25px;
    position: relative;
    color: #4b5563;
    font-size: 14px;
    border-bottom: 1px solid #f3f4f6;
}

.protocol li:before {
    content: "→";
    color: #667eea;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.protocol li:last-child {
    border-bottom: none;
}

/* Accuracy Table */
.accuracy-table {
    margin: 25px 0;
    overflow-x: auto;
}

.accuracy-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.accuracy-table th {
    background: #667eea;
    color: white;
    padding: 15px;
    font-weight: 600;
    text-align: left;
}

.accuracy-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
}

.accuracy-table tbody tr:hover {
    background: #f8f9fa;
}

.vector-example {
    background: #1f2937;
    color: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    margin: 15px 0;
}

.vector-example pre {
    margin: 10px 0 0 0;
    font-family: 'Courier New', monospace;
    color: #fbbf24;
}

.calculation-example {
    background: #f8fafc;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.calculation-example pre {
    background: #1f2937;
    color: #fbbf24;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
}

.drift-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
}

.drift-table th,
.drift-table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.drift-table th {
    background: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .engineering-article {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
    
    .article-sidebar {
        order: -1;
        border-left: none;
        border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    }
    
    .table-of-contents {
        position: relative;
        top: auto;
    }
}

@media (max-width: 768px) {
    .article-content {
        padding: 30px 25px;
    }
    
    .article-sidebar {
        padding: 25px 20px;
    }
    
    .article-title {
        font-size: 2rem;
    }
    
    .problem-solution-box {
        grid-template-columns: 1fr;
    }
    
    .detail-grid,
    .clock-grid,
    .challenge-grid,
    .cause-grid,
    .pitfall-grid,
    .protocol-comparison {
        grid-template-columns: 1fr;
    }
    
    .ntp-process {
        grid-template-columns: 1fr 1fr;
    }
    
    .formula-box {
        grid-template-columns: 1fr;
    }
    
    .stats {
        flex-direction: column;
    }
    
    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .ntp-process {
        grid-template-columns: 1fr;
    }
    
    .article-content {
        padding: 20px 15px;
    }
    
    .article-title {
        font-size: 1.75rem;
    }
    
    .content-section h2 {
        font-size: 1.5rem;
    }
}