/* ==========================================
   Global Stylesheet — opencode.ai inspired
   ========================================== */

/* ---------- CSS Variables ---------- */

:root {
    /* Light mode */
    --color-background: hsl(0, 20%, 99%);
    --color-background-weak: hsl(0, 8%, 97%);
    --color-background-weak-hover: hsl(0, 8%, 94%);
    --color-background-strong: hsl(0, 5%, 12%);
    --color-background-strong-hover: hsl(0, 5%, 18%);
    --color-background-interactive: hsl(62, 84%, 88%);
    --color-background-interactive-weaker: hsl(64, 74%, 95%);
    --color-text: hsl(0, 1%, 39%);
    --color-text-weak: hsl(0, 1%, 60%);
    --color-text-weaker: hsl(30, 2%, 81%);
    --color-text-strong: hsl(0, 5%, 12%);
    --color-text-inverted: hsl(0, 20%, 99%);
    --color-border: hsl(30, 2%, 81%);
    --color-border-weak: hsla(0, 100%, 3%, 0.12);
    --color-icon: hsl(0, 1%, 55%);

    --font-mono: "IBM Plex Mono", "SF Mono", "Fira Code", monospace;
    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --header-height: 80px;
    --container-max-width: 67.5rem;
    --radius-sm: 4px;
    --radius-md: 6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-background: hsl(0, 9%, 7%);
        --color-background-weak: hsl(0, 6%, 10%);
        --color-background-weak-hover: hsl(0, 6%, 15%);
        --color-background-strong: hsl(0, 15%, 94%);
        --color-background-strong-hover: hsl(0, 15%, 97%);
        --color-background-interactive: hsl(62, 100%, 90%);
        --color-background-interactive-weaker: hsl(64, 74%, 15%);
        --color-text: hsl(0, 4%, 71%);
        --color-text-weak: hsl(0, 2%, 49%);
        --color-text-weaker: hsl(30, 2%, 35%);
        --color-text-strong: hsl(0, 15%, 94%);
        --color-text-inverted: hsl(0, 9%, 7%);
        --color-border: hsl(0, 3%, 28%);
        --color-border-weak: hsl(0, 4%, 23%);
        --color-icon: hsl(0, 2%, 55%);
    }
}

/* ---------- Reset ---------- */

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

/* ---------- Base ---------- */

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-background);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- Container ---------- */

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 5rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
}

/* ---------- Sticky Header ---------- */

.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border-weak);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 5rem;
    transition: background-color 0.3s ease;
}

@media (max-width: 768px) {
    .header {
        padding: 0 1.5rem;
    }
}

.header-inner {
    max-width: var(--container-max-width);
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-strong);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo:hover {
    opacity: 0.8;
}

.header-logo em {
    font-size: 18px;
    color: var(--color-text-weak);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
    margin-left: auto;
}

.header-nav a {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--color-text-weak);
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.header-nav a:hover {
    color: var(--color-text-strong);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 1px;
}

/* ---------- Hero Section ---------- */

.hero {
    padding: 6rem 0 4rem;
    text-align: center;
}

.hero h1 {
    font-family: var(--font-sans);
    font-size: 38px;
    font-weight: 700;
    color: var(--color-text-strong);
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 22px;
    }
}

.hero p {
    font-size: 16px;
    color: var(--color-text-weak);
    max-width: 48rem;
    margin: 0 auto 2rem;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
    background: var(--color-background-strong);
    color: var(--color-text-inverted);
}

.btn-primary:hover {
    background: var(--color-background-strong-hover);
}

.btn-secondary {
    background: var(--color-background);
    color: var(--color-text-strong);
    border: 1px solid var(--color-border-weak);
}

.btn-secondary:hover {
    background: var(--color-background-weak);
}

.btn-icon {
    font-size: 16px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--color-background-weak);
    border: 1px solid var(--color-border-weak);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: background-color 0.2s ease;
}

.card:hover {
    background: var(--color-background-weak-hover);
}

.card-header {
    padding: 0 0 12px;
    border-bottom: 1px solid var(--color-border-weak);
    margin-bottom: 12px;
}

.card-header h5 {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-strong);
}

.card-body {
    padding: 0;
}

/* ---------- Sections ---------- */

.section {
    padding: 4rem 0;
    border-top: 1px solid var(--color-border-weak);
}

.section:last-child {
    border-bottom: 1px solid var(--color-border-weak);
}

.section-title {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-strong);
    margin-bottom: 1rem;
}

.section-content {
    color: var(--color-text);
    line-height: 1.8;
}

/* ---------- Forms ---------- */

.form-group {
    margin-bottom: 1rem;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--color-text-strong);
    background: var(--color-background-weak);
    border: 1px solid var(--color-border-weak);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-background-strong);
    box-shadow: 0 0 0 3px var(--color-background-interactive);
    background: var(--color-background-interactive-weaker);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-weak);
    opacity: 1;
}

/* ---------- Links ---------- */

a {
    color: var(--color-text-strong);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 1px;
    transition: color 0.2s ease;
}

a:hover {
    opacity: 0.8;
}

/* ---------- Typography ---------- */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    color: var(--color-text-strong);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 38px; }
h2 { font-size: 32px; }
h3 { font-size: 24px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

@media (max-width: 768px) {
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    h3 { font-size: 16px; }
}

/* ---------- Grid (Bootstrap compatible) ---------- */

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

[class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ---------- Code ---------- */

code,
pre {
    font-family: var(--font-mono);
}

code {
    font-size: 0.9em;
    padding: 2px 6px;
    background: var(--color-background-weak);
    border: 1px solid var(--color-border-weak);
    border-radius: 3px;
}

pre {
    padding: 16px;
    background: var(--color-background-weak);
    border: 1px solid var(--color-border-weak);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    padding: 0;
    background: none;
    border: none;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 16px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.alert-success {
    color: var(--color-text-strong);
    background: var(--color-background-interactive-weaker);
    border-color: var(--color-border-weak);
}

.alert-danger {
    color: var(--color-text-strong);
    background: var(--color-background-weak);
    border-color: var(--color-border-weak);
}

/* ---------- Utility ---------- */

.text-center { text-align: center; }
.text-muted { color: var(--color-text-weak); }
.text-strong { color: var(--color-text-strong); }
.text-weak { color: var(--color-text-weak); }

.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }

.w-100 { width: 100%; }

/* ---------- Footer ---------- */

.footer {
    padding: 3rem 0;
    border-top: 1px solid var(--color-border-weak);
    text-align: center;
    color: var(--color-text-weak);
    font-size: 13px;
}

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-background);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-weak);
}

/* ---------- Selection ---------- */

::selection {
    background: var(--color-background-interactive);
    color: var(--color-text-strong);
}
