/* file: data/web/static/styles/base.css */
/* === GWAY BASE LAYOUT (REWRITTEN, THEME-AWARE, MOBILE-SAFE) === */

/* 1. General reset and typography */
* {
    box-sizing: border-box;
    scroll-behavior: smooth;
}
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: system-ui, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, 'Liberation Sans', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--fg, #202124);
    background: var(--bg, #fff);
    letter-spacing: 0.01em;
}
:root {
    --bg: #fff;
    --bg-alt: #f0f0f0;
    --main-bg: #fff;         /* used for mobile main background */
    --fg: #202124;
    --muted: #666;
    --accent: #007bff;
    --accent-alt: #007bff;
    --card-bg: #fafaff;
}

/* 2. App structural layout */
.page-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: none;
}
.layout {
    display: flex;
    flex: 1 0 auto;
    flex-direction: row;
    width: 100%;
    min-height: 0;
    background: none;
}
.layout.nav-right {
    flex-direction: row-reverse;
}

/* Nav on the right tweaks */
.layout.nav-right aside {
    border-right: none;
    border-left: 1px solid #ccc;
}

/* 3. Sidebar (aside) */
aside {
    width: 220px;
    padding: 2rem 1rem;
    flex-shrink: 0;
    background: var(--bg-alt, #f0f0f0);
    border-right: 1px solid #ccc;
    font-size: 1.08em;
    font-family: inherit;
    transition: background 0.2s;
    overflow-y: auto;
    scrollbar-width: none;
}

/* 4. Main content area */
main {
    flex: 1 1 0;
    padding: 1rem 2rem;
    min-width: 0;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    font-family: inherit;
    background: var(--main-bg, var(--bg, #fff));
    transition: background 0.2s;
}

/* 5. Footer */
footer {
    font-size: 0.92em;
    padding: 1em;
    color: var(--muted, #666);
    border-top: 1px solid #ccc;
    text-align: center;
    background: inherit;
    font-family: inherit;
}

/* 6. Typography */
h1, h2, h3, h4 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 700;
    line-height: 1.25;
    font-family: 'Segoe UI Semibold', 'Roboto Slab', 'Georgia', serif, system-ui;
    letter-spacing: 0.01em;
}
h1 { font-size: 2.2em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.22em; }
h4 { font-size: 1.08em; }
main > h1:first-child { margin-top: 1em; }
p { margin: 1em 0; }

pre {
    background: #111827;
    color: #a5f3fc;
    padding: 1rem;
    margin: 1em 0;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: 'Fira Mono', 'Fira Code', 'Consolas', 'Menlo', 'Monaco', 'Liberation Mono', monospace;
    font-size: 0.9em;
    line-height: 1.6;
}
pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
    border-radius: 0;
}
code {
    background: #111827;
    color: #a5f3fc;
    padding: 0.14em 0.32em;
    border-radius: 0.3em;
    font-family: 'Fira Mono', 'Fira Code', 'Consolas', 'Menlo', 'Monaco', 'Liberation Mono', monospace;
    font-size: 0.92em;
}
h1 + pre, h2 + pre, h3 + pre, h4 + pre { margin-top: 0.5em; }

/* 7. Lists and links */
aside ul { list-style: none; padding: 0; }
aside ul li a {
    display: block;
    padding: 0.3em 0;
    text-decoration: none;
    text-transform: uppercase;
    color: var(--fg, #000);
    letter-spacing: 0.02em;
    font-weight: 500;
    font-size: 0.92em;
    font-family: inherit;
    transition: color 0.15s;
}
aside ul li a:hover, aside ul li a.active {
    font-weight: 700;
    color: var(--accent, #007bff);
}
.current, li a.active {
    font-weight: bold;
    text-decoration: underline;
}
aside ul.sub-links {
    list-style: none;
    padding-left: 1em;
    margin: 0.2em 0 0.4em;
    font-size: 0.85em;
}
aside ul.sub-links li a {
    text-transform: none;
    padding: 0.2em 0.5em;
}

/* Project README tree */
.readme-list,
.readme-list ul {
    list-style: none;
    padding-left: 1em;
    margin: 0;
}
.readme-list > li { margin-bottom: 0.4em; }
@media (min-width: 700px) {
    .readme-list { display: flex; flex-wrap: wrap; }
    .readme-list > li { width: 50%; box-sizing: border-box; padding-right: 1em; }
}

/* 8. Buttons & form controls */
button, input[type="submit"], input[type="button"] {
    background: var(--accent-alt, #007bff);
    color: #fff;
    padding: 0.6em 1.2em;
    font-size: 1em;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}
button:hover, input[type="submit"]:hover {
    background: var(--accent, #0056b3);
    transform: scale(1.03);
}
button:active, input[type="submit"]:active {
    background: #004494;
    transform: scale(0.97);
}
input, textarea, select {
    width: 100%;
    padding: 0.5em;
    font-size: 1em;
    margin-bottom: 1em;
    border-radius: 0.5rem;
    border: 1px solid var(--muted, #ccc);
    font-family: inherit;
    box-sizing: border-box;
}
input[type="checkbox"], input[type="radio"] {
    width: auto;
}
label.checkbox-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 1em;
}

button.btn-block {
    display: block;
    width: 100%;
}
select {
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' width='14' height='14' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolygon points='0,0 140,0 70,70' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7em center;
    background-size: 0.8em;
}


/* 9. Responsive design: MOBILE OVERRIDES */
@media (max-width: 650px) {
    .layout {
        flex-direction: row !important;
        min-height: 100vh;
        position: relative;
        background: none;
    }
    .layout.nav-right {
        flex-direction: row-reverse !important;
    }
    aside {
        width: 76vw;
        max-width: 350px;
        min-width: 200px;
        position: absolute;
        left: 0; top: 0; bottom: 0; height: 100vh;
        border-right: 1px solid #222;
        background: var(--bg-alt, #191b23);
        z-index: 22;
        padding-bottom: 3rem;
        transition: background 0.22s;
        box-shadow: 3px 0 16px #0004;
    }
    .layout.nav-right aside {
        left: auto;
        right: 0;
        border-right: none;
        border-left: 1px solid #222;
        box-shadow: -3px 0 16px #0004;
    }
    main {
        padding: 0.8rem 0.3rem 0.3rem 0.7rem;
        width: 100%;
        min-width: 0;
        height: 100vh;
        overflow-x: auto;
        position: relative;
        z-index: 1;
        background: var(--main-bg, #fff); /* always light by default for readability */
        /* To support dark theme, set --main-bg via JS or a theme class */
    }
    .layout.nav-right main {
        padding: 0.8rem 0.7rem 0.3rem 0.3rem;
    }
}

/* 10. Print styles */
@media print {
    aside { display: none; }
    body { background: #fff; color: #000; }
    main { padding: 0; }
    pre { background: #f0f0f0; color: #000; }
}

/* 11. Basic link styles, theme-robust */
a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.13em;
    transition: color 0.18s, box-shadow 0.18s;
    text-shadow: 0 0 5px rgba(255,255,255,0.44),
                 0 0 12px rgba(255,255,255,0.15);
}
a:visited { color: inherit; opacity: 0.95; }
a:hover, a:focus {
    color: inherit;
    background: rgba(255,255,255,0.13);
    box-shadow: 0 0 7px 2px rgba(255,255,255,0.29);
    text-shadow: 0 0 7px rgba(255,255,255,0.50),
                 0 0 14px rgba(255,255,255,0.25);
    outline: none;
}

/* 12. Miscellaneous elements (images, forms, etc) */
img.compass {
    max-width: 180px;
    height: auto;
    margin: 1em auto 0 auto;
    display: block;
}
form.navbar { margin-bottom: 1em; }
div.compass { margin-top: 1em; text-align: center; }
p.compass { margin-bottom: 0.5em; }

/* 13. Utility classes */
.hidden { display: none !important; }
.full-code-block { position: relative; }


/* 15. Help System Styles (trimmed for brevity, can be extended as needed) */
.help-entry {
    margin: 1.2em 0 1.4em 0;
    border: 1.5px solid #e2e6ee;
    border-radius: 13px;
    background: var(--card-bg, #fafaff);
    box-shadow: 0 2px 8px 0 rgba(30,40,80,0.07);
    padding: 1.05em 1.25em 0.7em 1.25em;
    transition: box-shadow 0.15s;
}
.help-entry:hover {
    box-shadow: 0 4px 14px 1px rgba(38,60,140,0.13);
}

/* 16. Navbar/Navigation roll handling */
.layout.nav-rolled aside {
    transform: translateX(-110%);
    transition: transform 0.25s cubic-bezier(.4,2,.6,1), box-shadow 0.2s, opacity 0.2s;
    box-shadow: none !important;
    opacity: 1 !important;
    pointer-events: none;
    width: 0 !important;
    min-width: 0 !important;
}
.layout.nav-right.nav-rolled aside {
    transform: translateX(110%);
}
.layout aside {
    transform: none;
    opacity: 1 !important;
    pointer-events: auto;
    transition: transform 0.25s cubic-bezier(.4,2,.6,1), box-shadow 0.2s, opacity 0.2s;
}
.layout.nav-rolled main {
    margin-left: 0 !important;
    width: 100% !important;
    opacity: 1 !important;
    filter: none !important;
    transition: width 0.2s;
}

/* 17. Searchbox theme support (light/dark ready) */
:root {
    --search-bg: #fff;
    --search-fg: #202124;
    --search-border: #b8c2cc;
    --search-placeholder: #888;
    --search-border-focus: #1ad6a4;
}
[data-theme="dark"], .dark, body.dark {
    --bg: #191b23;
    --bg-alt: #11151a;
    --main-bg: #181820;
    --fg: #f3f8fc;
    --muted: #a3b2c2;
    --accent: #21c9ff;
    --accent-alt: #2483c8;
    --card-bg: #1a2330;
    --search-bg: #181c22;
    --search-fg: #f3f8fc;
    --search-border: #54ffcc;
    --search-placeholder: #a3b2c2;
    --search-border-focus: #9fffe5;
}
#help-search, .help-search {
    background: var(--search-bg) !important;
    color: var(--search-fg) !important;
    border: 2px solid var(--search-border);
    border-radius: 8px;
    padding: 0.5em 0.75em;
    font-size: 0.9em;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    width: 95%;
    margin: 0.2em auto 0.5em auto;
    display: block;
}
#help-search:focus, .help-search:focus {
    border-color: var(--search-border-focus);
    outline: none;
}
#help-search::placeholder, .help-search::placeholder {
    color: var(--search-placeholder);
    opacity: 1;
}

/* 18. Scrollbar styling (optional for modern look) */
::-webkit-scrollbar {
    width: 12px;
    background: #e0e0e0;
}
::-webkit-scrollbar-thumb {
    background: #b0b0b0;
    border: 2px solid #e0e0e0;
}

