/* ===================================================================
   CRA FAQ Stylesheet  - Semantic Layout
   Basic layout styles using semantic HTML elements
   =================================================================== */

/* CSS Custom Properties */
:root {
    /* Brand Colors */
    --primary-color: #1cb1d1;
    --primary-dark: #006472;
    --secondary-color: #003963;
    --secondary-orange: #ff6b35;

    /* Semantic Color System */
    --color-info: #0969da;
    --color-success: #2e7d32;
    --color-warning: #f57c00;
    --color-danger: #c62828;
    --color-important: #8250df;

    /* Text Colors */
    --text-color: #333;
    --text-light: #666;

    /* Backgrounds & Borders */
    --background-light: #f8f9fa;
    --border-color: #e9ecef;
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Base & Reset */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    color: var(--text-color);
    background: #fff;
    font-weight: 400;
}

/* Typography */
h1 {
    font-size: 2.5em;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 30px;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--primary-dark);
    margin: 40px 0 20px 0;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--primary-dark);
    margin: 30px 0 15px 0;
}

h4 {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-color);
    margin: 20px 0 10px 0;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Header Layout */
.site-header {
    margin: 20px 0 30px 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.site-header>a {
    white-space: nowrap;
}

.site-header>a h1 {
    margin: 0;
    transition: color 0.2s ease;
}

.site-header>a:hover h1 {
    color: var(--primary-color);
}

.site-nav {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.site-nav a {
    color: var(--primary-dark);
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    background: var(--background-light);
    color: var(--primary-color);
}

.site-header>img {
    width: 90px;
    height: auto;
    align-self: center;
}

/* Main Content Area */
main {
    margin-bottom: 60px;
}

/* Section Components */
.section-intro {
    background: var(--background-light);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.section-intro p {
    margin: 0 0 10px 0;
}

.section-intro p:last-child {
    margin-bottom: 0;
}

/* Card Grid Component */
.card-grid {
    display: grid;
    gap: 20px;
    margin-top: 30px;
}

/* Card Component */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    transition: all 0.2s ease;
    color: inherit;
    display: block;
    position: relative;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.card::after {
    content: '→';
    position: absolute;
    top: 50%;
    right: 25px;
    transform: translateY(-50%) translateX(-10px);
    font-weight: bold;
    color: var(--primary-color);
    opacity: 0;
    transition: all 0.2s ease;
}

.card:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.card h2 {
    margin: 0 0 10px 0;
    color: var(--primary-dark);
}

.card p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9em;
}

/* Half-width card arrow positioning */
.half-width .card::after {
    top: auto;
    bottom: 15px;
    transform: translateX(-10px);
}

.half-width .card:hover::after {
    transform: translateX(0);
}


/* Section Card Component */
.section-card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 20px 30px 30px 30px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.section-card> :first-child {
    margin-top: 0;
}

.section-card> :last-child {
    margin-bottom: 0;
}

/* Section Card Header */
.section-card>.section-header {
    background: var(--background-light);
    padding: 25px 30px 15px 30px;
    border-bottom: 1px solid var(--border-color);
    margin: -20px -30px 25px -30px;
}

.section-card h1 {
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.3;
}

.section-card>h2 {
    font-size: 1.4em;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--primary-dark), var(--primary-color)) 1;
}

.section-card h2+.link-list {
    margin-top: 15px;
}

.section-card .link-list+h2 {
    margin-top: 40px;
}

.section-card>p {
    margin-bottom: 15px;
}

/* Link Lists */
.link-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.link-list li {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.link-list li a {
    display: flex;
    padding: 15px 20px;
    background: var(--background-light);
    border-radius: 6px;
    color: var(--text-color);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-weight: 500;
    font-size: 0.95em;
    min-height: 60px;
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    flex: 1;
}

.link-list li a:has(.badges:not([hidden])) {
    gap: 8px;
}

.link-list li a .question-text {
    width: 100%;
    text-align: left;
}

.link-list li a .badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.link-list li a .badges[hidden] {
    display: none;
}

.link-list li a::after {
    content: '→';
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%) translateX(-10px);
    font-weight: bold;
    color: var(--primary-color);
    opacity: 0;
    transition: all 0.2s ease;
}

.link-list li a:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(28, 177, 209, 0.1);
    transform: translateY(-1px);
    color: var(--primary-color);
}

.link-list li a:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Details/Summary (Accordions) */
.faq-accordion-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.faq-accordion-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.faq-accordion-item[open] {
    border-color: var(--primary-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.faq-accordion-item summary {
    padding: 18px 20px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1em;
    color: var(--text-color);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.faq-accordion-item summary .question-text {
    flex: 1;
    color: var(--text-color);
    font-weight: 500;
}

.faq-accordion-item summary .question-text p {
    margin: 0;
    display: inline;
}

.faq-accordion-item summary::-webkit-details-marker {
    display: none;
}

.faq-accordion-item summary::after {
    content: '▼';
    flex-shrink: 0;
    color: var(--primary-color);
    font-size: 0.8em;
    font-weight: bold;
    transition: transform 0.3s ease;
    margin-top: 2px;
}

.faq-accordion-item[open] summary::after {
    transform: rotate(-180deg);
}

/* Action Button Utility */
.action-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.85em;
    color: var(--text-light);
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 32px;
    box-sizing: border-box;
}

.action-button svg {
    flex-shrink: 0;
}

.action-button:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

/* Element-specific resets */
button.action-button {
    background: none;
    border: none;
    cursor: pointer;
}

a.action-button {
    text-decoration: none;
}

/* State modifiers */
.action-button.copied {
    color: var(--color-success);
}

/* FAQ Actions Container */
.faq-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.faq-actions .admin-links {
    display: flex;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.admin-mode .faq-actions .admin-links {
    opacity: 1;
    pointer-events: auto;
}

.faq-actions .regular-actions {
    display: flex;
    gap: 10px;
}

.faq-accordion-item summary:hover {
    background: rgba(28, 177, 209, 0.03);
}

.faq-accordion-item[open] summary {
    background: rgba(28, 177, 209, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.faq-accordion-item article {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}

.faq-accordion-item[open] article {
    grid-template-rows: 1fr;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.faq-accordion-item article>div {
    overflow: hidden;
}

.faq-accordion-item article p:first-child {
    margin-top: 0;
}

.faq-accordion-item article p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    background: white;
    color: var(--text-color);
    margin-top: 60px;
    padding: 40px 0 30px 0;
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

footer section h4 {
    color: var(--secondary-color);
    font-size: 0.8em;
    font-weight: 600;
    margin: 0 0 8px 0;
    letter-spacing: -0.01em;
}

footer section p {
    margin: 0 0 6px 0;
    line-height: 1.4;
    color: var(--text-light);
    font-size: 0.7em;
}

footer section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

footer section li {
    margin-bottom: 4px;
    font-size: 0.7em;
    color: var(--text-light);
}

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

footer section a:hover {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 20px 15px;
    }

    /* Mobile header layout: Title and Logo on first line, Nav on second line */
    .site-header {
        align-items: center;
    }

    .site-nav {
        order: 1;
        flex-basis: 100%;
    }

    footer {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

@media (max-width: 480px) {
    footer {
        grid-template-columns: 1fr;
    }
}

/* Admin Mode Toggle */
footer .admin-toggle {
    cursor: pointer;
}

footer .admin-toggle .toggle-text-on {
    display: none;
}

.admin-mode footer .admin-toggle .toggle-text-off {
    display: none;
}

.admin-mode footer .admin-toggle .toggle-text-on {
    display: inline;
}

/* Admin Content - Hidden by Default */
.admin-content {
    display: none;
}

.admin-mode .admin-content {
    display: block;
    margin-top: 30px;
    padding: 20px;
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
}

.admin-content summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-dark);
}

.admin-content[open] summary {
    margin-bottom: 15px;
}

/* Badges - Visible in Admin Mode */
.admin-mode .badges[hidden] {
    display: flex !important;
}

.admin-mode .link-list li a:has(.badges[hidden]) {
    gap: 8px;
}

/* Contributors List */
.contributors-list {
    text-align: center;
}

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

.contributors-list li {
    line-height: 1.6;
    transition: all 0.1s ease;
}

.contributors-list li:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* ===================================================================
   CODE BLOCKS
   =================================================================== */

/* Inline code */
code {
    background: #f1f3f4;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    border: 1px solid var(--border-color);
}

/* Code blocks */
pre {
    background: #f1f3f4;
    padding: 20px;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Reset inline code styles inside pre */
pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 1em;
}

/* ===================================================================
   UTILITY CLASSES
   =================================================================== */

/* Layout Utilities */
.full-width {
    grid-column: 1 / -1;
}

.half-width {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Semantic Color Utilities - Using color-mix for automatic backgrounds and borders */
.info {
    --color: var(--color-info);
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
}

.success {
    --color: var(--color-success);
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
}

.warning {
    --color: var(--color-warning);
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
}

.danger {
    --color: var(--color-danger);
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
}

.important {
    --color: var(--color-important);
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
}

/* First child inherits the color from utility class and gets emoji */
:is(.info, .success, .warning, .danger, .important)> :first-child {
    color: var(--color);
}

.info> :first-child::before {
    content: '💬 ';
}

.success> :first-child::before {
    content: '✅ ';
}

.warning> :first-child::before {
    content: '⚠️ ';
}

.danger> :first-child::before {
    content: '🛑 ';
}

.important> :first-child::before {
    content: '🔔 ';
}

/* Badge Component */
.badge {
    display: inline-block;
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    border: 1px solid;
    color: var(--color);
}

/* Badge icons based on utility classes */
.badge.success::before {
    content: '✅ ';
}

.badge.warning::before {
    content: '⚠️ ';
}

.badge.danger::before {
    content: '🛑 ';
}

/* ===================================================================
   GITHUB ALERTS & BLOCKQUOTES
   =================================================================== */

/* Regular blockquote */
blockquote {
    margin: 16px 0;
    padding: 0 31px 0 33px; /* Align with 3px left borders elsewhere */
    font-style: italic;
    color: var(--text-light);
}

/* Aside and alerts with frames */
aside,
.markdown-alert {
    border-style: solid;
    border-width: 1px;
    border-left-width: 3px;
    border-radius: 6px;
    margin: 16px 0;
    padding: 20px 30px;
    font-size: 0.92em;
    color: var(--text-color);
}

aside p,
.markdown-alert p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

aside p:first-child,
.markdown-alert p:first-child {
    margin-top: 0;
}

aside p:last-child,
.markdown-alert p:last-child {
    margin-bottom: 0;
}

/* Aside headings styled like alert titles */
aside h2,
aside h3 {
    margin-top: 0;
    font-weight: 600;
    font-size: 1em;
}

/* GitHub Alert Callouts - use utility classes for colors */
.markdown-alert-title {
    font-weight: 600;
}

/* Hide plugin-generated SVG icons */
.markdown-alert svg {
    display: none;
}

/* Map alert types to semantic colors - set --color variable */
.markdown-alert-note {
    --color: var(--color-info);
}

.markdown-alert-tip {
    --color: var(--color-success);
}

.markdown-alert-important {
    --color: var(--color-important);
}

.markdown-alert-warning {
    --color: var(--color-warning);
}

.markdown-alert-caution {
    --color: var(--color-danger);
}

/* Apply colors using --color variable (DRY) */
.markdown-alert-note,
.markdown-alert-tip,
.markdown-alert-important,
.markdown-alert-warning,
.markdown-alert-caution {
    background: color-mix(in srgb, var(--color) 10%, white);
    border-color: color-mix(in srgb, var(--color) 40%, white);
    border-left-color: var(--color);
}

/* Alert titles get color and emoji */
.markdown-alert-title {
    color: var(--color);
}

.markdown-alert-note .markdown-alert-title::before {
    content: '💬 ';
}

.markdown-alert-tip .markdown-alert-title::before {
    content: '✅ ';
}

.markdown-alert-important .markdown-alert-title::before {
    content: '🔔 ';
}

.markdown-alert-warning .markdown-alert-title::before {
    content: '⚠️ ';
}

.markdown-alert-caution .markdown-alert-title::before {
    content: '🛑 ';
}
