@import "inline_code.css";

/* Quotations */
blockquote {
    background: linear-gradient(135deg, var(--ps-gray-pale) 0%, var(--ps-white) 100%);
    border: 1px solid #e9ecef;
    border-left: 4px solid var(--ps-green);
    border-radius: 0 12px 12px 0;
    color: var(--ps-gray);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    font-style: italic;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
blockquote:before {
    color: var(--ps-green);
    content: "\201C";
    font-size: 3em;
    line-height: 0.1em;
    margin-right: 0.25em;
    vertical-align: -0.4em;
    opacity: 0.3;
}

/* Note */
.note {
    background: linear-gradient(135deg, var(--ps-green-light) 0%, #f1f8f2 100%);
    border: 1px solid var(--ps-green-subtle);
    border-left: 4px solid var(--ps-green);
    border-radius: 0 12px 12px 0;
    color: var(--ps-gray);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    font-style: normal;
    box-shadow: 0 2px 4px rgba(45, 122, 62, 0.1);
}
.note:before {
    content: "💡 NOTA: ";
    color: var(--ps-green);
    font-size: 1em;
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}

/* Code Link */
.code-link {
    background: linear-gradient(135deg, var(--ps-gold-light) 0%, #fffbeb 100%);
    border: 1px solid #fde68a;
    border-left: 4px solid var(--ps-gold);
    border-radius: 0 12px 12px 0;
    color: var(--ps-gray);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    font-style: normal;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.1);
}
.code-link:before {
    content: "📦 Código: ";
    color: #b45309;
    font-size: 1em;
    font-weight: 600;
    display: block;
    margin-bottom: 0.5rem;
}
.code-link a {
    color: #b45309;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}
.code-link a:hover {
    color: #92400e;
    text-decoration-style: solid;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid var(--ps-gray-pale);
    margin-top: 1.5em;
    margin-bottom: 1.5em;
}
table td, table th {
    border: 1px solid var(--ps-gray-pale);
    padding: 0.75rem 1rem;
}

caption {
    font-weight: bold;
    padding: 1em;
}
  
thead {
    background-color: var(--ps-gray-pale);
}

/* Table of Contents */
.toc {
    background: linear-gradient(135deg, var(--ps-gray-pale) 0%, var(--ps-white) 100%);
    border: 1px solid #e9ecef;
    border-left: 4px solid var(--ps-green);
    border-radius: 0 16px 16px 0;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toc ul li {
    padding: 0.5rem 0;
}

.toc ul {
    font-size: 1em;
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.toctitle {
    font-size: 1.2em;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--ps-gray);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toctitle:before {
    content: "📋";
    font-size: 1.2em;
}

.toc a {
    color: var(--ps-green);
    text-decoration: none;
}

.toc a:hover {
    color: var(--ps-green-dark);
    text-decoration: underline;
}

/* Syntax highlighter for code */
.highlighttable {
    width: 100%;
    margin: 0;
}

td.linenos {
    width: 1px;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    user-select: none;
    border-right: 1px solid var(--ps-green-subtle);
    color: var(--ps-gray-light);
    text-align: right;
    vertical-align: top;
}

td.code {
    padding-left: 0.5rem !important;
    vertical-align: top;
}

.linenos pre {
    margin: 0;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    line-height: 1.5;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
}

.highlight .hll { 
    background-color: #ffffcc;
    display: block;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.highlight { 
    background: linear-gradient(135deg, var(--ps-gray-pale) 0%, var(--ps-white) 100%);
    border: 1px solid #e9ecef;
    border-radius: 16px;
    margin-top: 2rem;
    margin-bottom: 2rem;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden; /* To clip the title header */
    position: relative;
}

/* Code block title / filename */
.highlight th.filename,
.highlight > span.filename {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    background: var(--ps-green-light);
    color: var(--ps-green-dark);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.85em;
    font-weight: 600;
    padding: 0.5rem 1rem;
    display: block;
    text-align: left;
    border-bottom: 1px solid var(--ps-green-subtle);
    margin: 0;
    z-index: 1;
}

.filename-mono {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 1.05em;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 500;
}

/* Clear any duplicated styles on the inner span */
.highlight th.filename span.filename {
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 1em;
    font-weight: inherit;
    padding: 0;
    display: inline;
    border: none;
}

/* Make space for the absolute header */
.highlight:has(.filename) .highlighttable {
    margin-top: 2.2rem;
}

.highlight pre {
    padding: 1.5rem;
    margin: 0;
    overflow-x: auto;
    line-height: 1.5;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
}

/* Specific styling for when titles are present */
.highlight:has(.filename) > pre {
    padding-top: 3.2rem;
}

.highlight .code {
    width: 100%;
}
.highlight .c { color: #8f5902; font-style: italic } /* Comment */
.highlight .err { color: #a40000; border: 1px solid #ef2929 } /* Error */
.highlight .g { color: #000000 } /* Generic */
.highlight .k { color: #204a87; font-weight: bold } /* Keyword */
.highlight .l { color: #000000 } /* Literal */
.highlight .n { color: #000000 } /* Name */
.highlight .o { color: #ce5c00; } /* Operator */
.highlight .x { color: #000000 } /* Other */
.highlight .p { color: #000000; font-weight: bold } /* Punctuation */
.highlight .ch { color: #8f5902; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #8f5902; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #8f5902; font-style: italic } /* Comment.Preproc */
.highlight .cpf { color: #8f5902; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #8f5902; font-style: italic } /* Comment.Single */
.highlight .cs { color: #8f5902; font-style: italic } /* Comment.Special */
.highlight .gd { color: #a40000 } /* Generic.Deleted */
.highlight .ge { color: #000000; font-style: italic } /* Generic.Emph */
.highlight .gr { color: #ef2929 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: var(--ps-green) } /* Generic.Inserted */
.highlight .go { color: #000000; font-style: normal } /* Generic.Output */
.highlight .gp { color: #8f5902 } /* Generic.Prompt */
.highlight .gs { color: #000000; font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #a40000; font-weight: bold } /* Generic.Traceback */
.highlight .kc { color: #204a87; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #204a87; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #204a87; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #204a87; font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { color: #204a87; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #204a87; font-weight: bold } /* Keyword.Type */
.highlight .ld { color: #000000 } /* Literal.Date */
.highlight .m { color: #0000cf } /* Literal.Number */
.highlight .s { color: #4e9a06 } /* Literal.String */
.highlight .na { color: #c4a000 } /* Name.Attribute */
.highlight .nb { color: #204a87 } /* Name.Builtin */
.highlight .nc { color: #000000 } /* Name.Class */
.highlight .no { color: #000000 } /* Name.Constant */
.highlight .nd { color: #5c35cc; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #ce5c00 } /* Name.Entity */
.highlight .ne { color: #cc0000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: var(--ps-gray) } /* Name.Function */
.highlight .nl { color: #f57900 } /* Name.Label */
.highlight .nn { color: #000000 } /* Name.Namespace */
.highlight .nx { color: #000000 } /* Name.Other */
.highlight .py { color: #000000 } /* Name.Property */
.highlight .nt { color: #204a87; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #000000 } /* Name.Variable */
.highlight .ow { color: #204a87; font-weight: bold } /* Operator.Word */
.highlight .pm { color: #000000; font-weight: bold } /* Punctuation.Marker */
.highlight .w { color: #f8f8f8 } /* Text.Whitespace */
.highlight .mb { color: #0000cf; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000cf; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000cf; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000cf; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000cf; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #4e9a06 } /* Literal.String.Affix */
.highlight .sb { color: #4e9a06 } /* Literal.String.Backtick */
.highlight .sc { color: #4e9a06 } /* Literal.String.Char */
.highlight .dl { color: #4e9a06 } /* Literal.String.Delimiter */
.highlight .sd { color: #8f5902; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4e9a06 } /* Literal.String.Double */
.highlight .se { color: #4e9a06 } /* Literal.String.Escape */
.highlight .sh { color: #4e9a06 } /* Literal.String.Heredoc */
.highlight .si { color: #4e9a06 } /* Literal.String.Interpol */
.highlight .sx { color: #4e9a06 } /* Literal.String.Other */
.highlight .sr { color: #4e9a06 } /* Literal.String.Regex */
.highlight .s1 { color: #4e9a06 } /* Literal.String.Single */
.highlight .ss { color: #4e9a06 } /* Literal.String.Symbol */
.highlight .bp { color: #3465a4 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #000000 } /* Name.Function.Magic */
.highlight .vc { color: #000000 } /* Name.Variable.Class */
.highlight .vg { color: #000000 } /* Name.Variable.Global */
.highlight .vi { color: #000000 } /* Name.Variable.Instance */
.highlight .vm { color: #000000 } /* Name.Variable.Magic */
.highlight .il { color: #0000cf; font-weight: bold } /* Literal.Number.Integer.Long */

/* ========================================
   ARTICLE BODY WIDTH CONSTRAINT
   ======================================== */

.article-body {
    max-width: 48rem;
}

/* ========================================
   STICKY TOC SIDEBAR
   ======================================== */

.toc-sidebar {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding-left: 1.5rem;
}

.toc-sidebar .toc {
    border-left: 3px solid var(--ps-green);
    border-radius: 0;
    box-shadow: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    background: transparent;
    padding: 1rem 0 1rem 1rem;
    margin: 0;
    font-size: 0.9em;
}

.toc-sidebar .toc ul {
    padding-left: 1rem;
}

.toc-sidebar .toc ul li {
    padding: 0.25rem 0;
}

/* ========================================
   PREV/NEXT ARTICLE NAVIGATION
   ======================================== */

.article-nav-link {
    display: block;
    padding: 1.25rem;
    background: var(--ps-gray-pale);
    border: 1px solid var(--ps-green-subtle);
    border-radius: 12px;
    transition: all 0.3s ease;
    color: var(--ps-gray-strong);
}

.article-nav-link:hover {
    background: var(--ps-green-subtle);
    border-color: var(--ps-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 122, 62, 0.15);
    color: var(--ps-gray-strong);
}

.article-nav-title {
    color: var(--ps-green-dark);
    font-size: 1.05rem;
    line-height: 1.4;
    font-weight: 700;
}

/* ========================================
   COPY BUTTON ON CODE BLOCKS
   ======================================== */

.highlight {
    position: relative;
}

.highlight .copy-btn {
    top: 0.35rem; /* Adjusted for filename header */
}

.highlight:has(.filename) .copy-btn {
    top: 0.25rem;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--ps-green);
    color: var(--ps-white);
    border: none;
    border-radius: 6px;
    padding: 0.3em 0.4em;
    font-size: 0.9em;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.highlight:hover .copy-btn {
    opacity: 0.7;
}

.copy-btn:hover {
    opacity: 1 !important;
    background: var(--ps-green-dark);
}

.copy-btn.copied {
    background: var(--ps-accent);
    opacity: 1 !important;
}

/* Hide decorative </> when copy button is present */
.highlight.has-copy-btn::before {
    display: none;
}

