/* =============================================
   1. Global Styles & CSS Variables
   ============================================= */
:root {
    --primary-color: #2c3e50;       /* Dark blue — 11.4:1 on white */
    --accent-color: #e67e22;        /* Orange — decorative only */
    --accent-text: #b45309;         /* Dark amber — 5.0:1 on white (WCAG AA) */
    --bg-light: #f8f9fa;
    --bg-section: #f1f3f5;
    --text-main: #333333;           /* 10.4:1 on white */
    --text-muted: #5a6472;          /* 5.6:1 on white */
    --footer-link: rgba(255,255,255,0.82); /* ~8.5:1 on dark blue */
    --nav-height: 68px;
    --transition: 0.3s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.7;
    background-color: #ffffff;
}

/* =============================================
   2. Skip Navigation (Accessibility)
   ============================================= */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 0;
    background: var(--primary-color);
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    font-weight: 700;
    z-index: 9999;
    border-radius: 0 0 6px 0;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent-text);  /* #b45309 — 5.0:1 on white, consistent with all other focus styles */
    outline-offset: 2px;
}

/* =============================================
   3. Navigation
   ============================================= */
#mainNav {
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--primary-color) !important;
}

.navbar-nav .nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted) !important;   /* 5.6:1 on white — WCAG AA */
    padding: 0.4rem 0.8rem !important;
    border-radius: 4px;
    transition: color var(--transition), background-color var(--transition);
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color) !important;
    background-color: var(--bg-light);
}

.navbar-nav .nav-link.active {
    color: var(--accent-text) !important;  /* #b45309 — 5.0:1 on white — WCAG AA */
    font-weight: 700;
}

/* =============================================
   4. Hero Section (Home page)
   ============================================= */
#hero {
    padding: 110px 0 90px;
    background: linear-gradient(150deg, #ffffff 0%, #f4f5f7 100%);
    border-bottom: 1px solid #e9ecef;
}

#hero h1 {
    color: var(--primary-color);   /* 11.4:1 on white — WCAG AAA */
    letter-spacing: -1px;
}

#hero h2 {
    color: var(--accent-text);     /* #b45309 — 5.0:1 on light bg — WCAG AA */
    font-style: italic;
    font-weight: 400;
}

/* =============================================
   5. Page Header (inner pages)
   ============================================= */
.page-header {
    background: linear-gradient(150deg, var(--primary-color) 0%, #3d5166 100%);
    padding: 70px 0 60px;
    color: #ffffff;
}

.page-header h1 {
    color: #ffffff;                /* 12.6:1 on #2c3e50 — WCAG AAA */
}

.page-header .lead {
    color: rgba(255, 255, 255, 0.9); /* ~11:1 effective — WCAG AAA */
    max-width: 600px;
    margin: 0 auto;
}

/* =============================================
   6. Section Utilities
   ============================================= */
.section-pad {
    padding: 80px 0;
}

.bg-section {
    background-color: var(--bg-section);
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.section-divider {
    width: 50px;
    height: 4px;
    background-color: var(--accent-color); /* Decorative only — no contrast check needed */
    border-radius: 2px;
    margin: 0.75rem auto 2.5rem;
}

/* =============================================
   7. Portfolio Cards
   ============================================= */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    transition: transform var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.card-img-top {
    height: 220px;
    object-fit: cover;
}

.card-title {
    color: var(--primary-color);   /* 11.4:1 on white — WCAG AAA */
    font-weight: 700;
    font-size: 1.1rem;
}

/* =============================================
   8. Buttons
   ============================================= */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;     /* 11.4:1 on dark blue — WCAG AAA */
    padding: 0.6rem 1.6rem;
    font-weight: 600;
    transition: background-color var(--transition), border-color var(--transition), transform var(--transition);
}

.btn-primary:hover {
    background-color: #1a252f !important;
    border-color: #1a252f !important;
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-color) !important;   /* 11.4:1 on white */
    border-color: var(--primary-color) !important;
    font-weight: 600;
    border-width: 2px;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.btn-outline-secondary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    font-weight: 600;
    border-width: 2px;
}

.btn-outline-secondary:hover {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

/* btn-accent: white on #b45309 = 5.0:1 — WCAG AA */
.btn-accent {
    background-color: var(--accent-text);
    border-color: var(--accent-text);
    color: #ffffff;
    font-weight: 700;
    padding: 0.7rem 2rem;
    border-radius: 6px;
    transition: background-color var(--transition), transform var(--transition);
}

.btn-accent:hover {
    background-color: #92400e;
    border-color: #92400e;
    color: #ffffff;
    transform: translateY(-1px);
}

/* =============================================
   9. About Section
   ============================================= */
.about-img {
    border-radius: 10px;
    box-shadow: 10px 10px 0px var(--accent-color); /* Decorative */
    width: 100%;
}

/* =============================================
   10. Footer (Contact + Site Footer)
   ============================================= */
#contact {
    background-color: var(--primary-color);
    padding: 80px 0 40px;
    margin-top: 0;
}

.text-white-75 {
    color: rgba(255, 255, 255, 0.9); /* ~11:1 effective on dark blue */
}

.bg-accent {
    background-color: var(--accent-color) !important; /* Decorative */
}

.site-footer {
    background-color: var(--primary-color);
    padding: 0 0 0.5rem;
}

/* ~8.5:1 effective on #2c3e50 — WCAG AAA */
.footer-link {
    color: var(--footer-link);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.footer-link:hover {
    color: #fbbf24;                /* Bright yellow — 9.6:1 on dark blue */
    text-decoration: underline;
}

/* =============================================
   11. Drawing Tool (contact.html)
   ============================================= */
#drawingCanvas {
    display: block;
    width: 100%;
    height: auto;
    background-color: #ffffff;
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    cursor: crosshair;
    touch-action: none;
}

.draw-toolbar {
    background-color: var(--bg-section);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    border: 1px solid #dee2e6;
}

.color-btn {
    width: 85px;
    height: 38px;
    border: 2px solid transparent;
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.color-btn:hover,
.color-btn.selected {
    transform: scale(1.08);
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.3);
}

/* =============================================
   12. Community Gallery (drawback.html)
   ============================================= */
.community-img {
    height: auto;
    border-bottom: 1px solid #f1f1f1;
    image-rendering: pixelated;
}

#galleryContainer .card {
    border: 1px solid #e9ecef;
}

/* =============================================
   13. Bookmark Cards (bookmarks.html)
   ============================================= */
.bookmark-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 1rem 1.1rem;
    background: #ffffff;
    border: 1px solid #e2e6ea;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    height: 100%;
}

.bookmark-card:hover,
.bookmark-card:focus-visible {
    border-color: var(--accent-text);
    box-shadow: 0 4px 16px rgba(180, 83, 9, 0.12);
    transform: translateY(-3px);
    color: inherit;
    text-decoration: none;
}

.bookmark-domain {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-text);
    font-weight: 600;
}

.bookmark-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.3;
}

.bookmark-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 2px;
}

/* =============================================
   14. Featured Video Section
   ============================================= */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    background-color: #000;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* =============================================
   14. Wireframe Page (wireframe.html)
   ============================================= */
.wireframe-page {
    background-color: #f8f9fa;
    min-height: 100vh;
}

.wf-section {
    padding: 60px 0;
}

.wf-section:nth-child(even) {
    background-color: #eef0f2;
}

.wf-diagram {
    border: 2px solid #adb5bd;
    border-radius: 8px;
    background: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    overflow: hidden;
}

.wf-nav-bar {
    background: #2c3e50;
    color: #ffffff;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.wf-nav-links {
    display: flex;
    gap: 12px;
    font-weight: 400;
}

.wf-block {
    border: 1px dashed #6c757d;
    margin: 10px;
    border-radius: 4px;
    padding: 10px 14px;
    background: #f8f9fa;
    color: #495057;
    font-size: 0.75rem;
    text-align: center;
}

.wf-block.wf-hero {
    background: #e9ecef;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.wf-block.wf-dark {
    background: #495057;
    color: #ffffff;
    border-color: #343a40;
}

.wf-grid {
    display: grid;
    gap: 8px;
    margin: 10px;
}

.wf-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.wf-grid-2 { grid-template-columns: 1fr 1fr; }
.wf-grid-15 { grid-template-columns: 2fr 3fr; }

.wf-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 700;
    margin: 6px 10px 2px;
}

.wf-img {
    background: #dee2e6;
    min-height: 55px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #6c757d;
    border: 1px dashed #adb5bd;
}

.wf-btn {
    display: inline-block;
    background: #2c3e50;
    color: #ffffff;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin: 3px;
}

.wf-canvas {
    background: #ffffff;
    border: 2px solid #2c3e50;
    border-radius: 6px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 0.75rem;
    font-style: italic;
    margin: 10px;
}

.wf-page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.wf-page-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.wf-annotation {
    background: #fffbeb;
    border-left: 4px solid var(--accent-text);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: #555;
    border-radius: 0 4px 4px 0;
    margin-bottom: 1rem;
}

/* =============================================
   15. Recent Updates / Changelog Widget
   ============================================= */
.changelog-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.changelog-loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1.5rem 0;
}

.changelog-item {
    display: grid;
    grid-template-columns: 7.5rem 1fr 4rem;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #dee2e6;
    transition: background-color var(--transition);
}

.changelog-item:first-child {
    border-top: 1px solid #dee2e6;
}

.changelog-item:hover {
    background-color: rgba(44, 62, 80, 0.04);
}

.changelog-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

.changelog-msg {
    font-size: 0.95rem;
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    word-break: break-word;
    transition: color var(--transition);
}

.changelog-msg:hover,
.changelog-msg:focus-visible {
    color: var(--accent-text);
    text-decoration: underline;
}

.changelog-sha {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .changelog-item {
        grid-template-columns: 1fr;
        gap: 0.3rem;
        padding: 0.75rem 0.5rem;
    }

    .changelog-sha {
        text-align: left;
    }
}

/* =============================================
   16. Accessibility — Focus Styles
   ============================================= */
#drawingCanvas:focus {
    outline: 3px solid var(--accent-text);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--accent-text);
    outline-offset: 3px;
    border-radius: 3px;
}

/* =============================================
   16. Back-to-Top Button
   ============================================= */
#backToTop {
    position: fixed;
    bottom: 1.8rem;
    right: 1.8rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    font-size: 1.5rem;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
    z-index: 1050;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
}

#backToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#backToTop:hover {
    background: var(--accent-text);
}

#backToTop:focus-visible {
    outline: 3px solid var(--accent-text);
    outline-offset: 3px;
}

/* =============================================
   17. Responsive Media Queries
   ============================================= */

/* ---- Tablet: 768px–991px ----
   7 nav items are too wide at the default size;
   shrink font and padding so they all fit in one row. */
@media (min-width: 768px) and (max-width: 991.98px) {
    .navbar-brand {
        font-size: 1.1rem;
        letter-spacing: 2px;
    }

    .navbar-nav .nav-link {
        font-size: 0.74rem !important;
        padding: 0.25rem 0.38rem !important;
        letter-spacing: 0 !important;
    }

    /* Wireframe 3-col grid → 2 cols on tablet */
    .wf-grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    /* Hero padding reduced slightly on tablet */
    #hero {
        padding: 90px 0 75px;
    }
}

/* ---- Mobile landscape / small tablet: 576px–767px ---- */
@media (min-width: 576px) and (max-width: 767.98px) {
    #hero {
        padding: 80px 0 65px;
    }

    .page-header {
        padding: 58px 0 48px;
    }

    .section-pad {
        padding: 60px 0;
    }

    #contact {
        padding: 60px 0 35px;
    }

    .wf-section {
        padding: 45px 0;
    }
}

/* ---- Small mobile: < 576px ---- */
@media (max-width: 575.98px) {
    /* Hero */
    #hero {
        padding: 68px 0 55px;
    }

    #hero h1 {
        font-size: 2.1rem;
        letter-spacing: -0.5px;
    }

    #hero h2 {
        font-size: 1.35rem;
    }

    #hero .lead {
        font-size: 0.95rem;
    }

    /* Reduce gap between hero buttons so they wrap neatly */
    #hero .d-flex.gap-3 {
        gap: 0.6rem !important;
    }

    /* Page header (gallery, draw, community, bookmarks, wireframe) */
    .page-header {
        padding: 48px 0 38px;
    }

    .page-header h1 {
        font-size: 1.9rem;
    }

    .page-header .lead {
        font-size: 0.9rem;
    }

    /* Section padding */
    .section-pad {
        padding: 48px 0;
    }

    /* Contact/footer band */
    #contact {
        padding: 48px 0 28px;
    }

    /* About image: reduce shadow offset to prevent x-axis overflow */
    .about-img {
        box-shadow: 5px 5px 0px var(--accent-color);
    }

    /* Section headings */
    .section-title {
        font-size: 1.6rem;
    }

    /* Wireframe section padding */
    .wf-section {
        padding: 38px 0;
    }

    /* Wireframe diagrams: enable horizontal scroll rather than clipping */
    .wf-diagram {
        overflow-x: auto;
        overflow-y: hidden;
        font-size: 0.72rem;
    }

    /* Tighten wireframe internal blocks on small screens */
    .wf-block {
        margin: 6px;
        padding: 7px 10px;
    }

    /* Smaller canvas placeholder height in wireframe */
    .wf-canvas {
        min-height: 60px;
    }
}

/* ---- All mobile: < 768px ---- */
@media (max-width: 767.98px) {
    /* Wireframe grids collapse to single column */
    .wf-grid-3 {
        grid-template-columns: 1fr;
    }

    .wf-grid-2 {
        grid-template-columns: 1fr;
    }

    .wf-grid-15 {
        grid-template-columns: 1fr;
    }

    /* Hide the fake nav link row in wireframe diagrams —
       too cramped to be readable at mobile widths */
    .wf-nav-links {
        display: none;
    }

    /* Footer link row: add vertical breathing room between wrapping links */
    .footer-link {
        margin-bottom: 0.2rem;
        display: inline-block;
    }
}

/* ---- Touch devices: disable transform-based hover effects ----
   hover: hover matches only devices with a true hover pointer
   (desktops/laptops). Touch phones/tablets won't match, so
   the card-lift and button-rise transforms won't fire on tap. */
@media (hover: none) {
    .card:hover {
        transform: none;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    }

    .bookmark-card:hover {
        transform: none;
        box-shadow: none;
        border-color: #e2e6ea;
    }

    .btn-primary:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .btn-accent:hover {
        transform: none !important;
        box-shadow: none !important;
    }
}
