:root {
    --ink: #2f3e2e;
    --primary: #5b7553;
    --primary-light: #a3b18a;
    --secondary: #a3b18a;
    --tertiary: #c17f59;
    --border: #dad7cd;
    --bg: #f6f5f1;
    --page-bg: #eeece3;
    --grey: #cccac2;

    --red: #8a4a4a;
    --aqua: #3d6b7d;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 1;
    }
}

/* Settings Modal */
.settings-modal-heading {
    display: flex;
    flex-direction: row;
    justify-content: space-between;     
}

.settings-modal-close-button {
    width: 32px;
    height: 32px;
    transition: all 0.1s ease-in;
}

.settings-modal-close-button:hover{
    scale: 1.05;
    fill: var(--primary);
}

dialog {
    border: none;
    border-radius: 12px;
    padding: 28px;
    max-width: 400px;
    width: 90%;
    background: var(--bg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

dialog h2 {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
}

dialog input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--page-bg);
    font-size: 13px;
    color: var(--ink);
    font-family: inherit;
    margin-bottom: 16px;
}

dialog input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

dialog input::placeholder {
    color: var(--grey);
}

dialog #save-settings {
    width: 100%;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    padding: 8px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:hover {
    color: var(--ink);
}

.pat-guide {
    margin-top: 12px;
    background: var(--page-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.pat-guide-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pat-guide-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink);
}

.pat-guide-step-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

.pat-guide-step a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pat-guide-step a:hover {
    color: var(--ink);
}

.pat-guide-step code {
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid var(--border);
}

/* Body */
body {
    display: grid;

    background-color: var(--page-bg);

    grid-template-rows: 1fr 8fr auto;
    height: 100vh;
    margin: 0;
    overflow: hidden;

    font-family: "Inter", sans-serif;
    font-optical-sizing: auto;
    font-weight: 800;
}

/*#region Header */
.header {
    display: flex;
    flex-direction: row;
    min-height: 0;
    justify-content: space-between;
    padding: 0.5rem;
    align-items: center;
    margin: 1rem 1rem 0 1rem;
}

/*#region Topbar */
.topbar {
    background: var(--ink);
    border-radius: 8px;
    padding: 0 18px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar .logo {
    color: var(--bg);
    font-weight: 500;
}

.topbar .nav-item {
    color: var(--primary-light);
    padding: 7px 12px;
    border-radius: 6px;
}

.topbar .nav-item-active {
    background: var(--primary);
    color: var(--bg);
}

.topbar .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--ink);
}

/* #endregion */

.repo-input {
    display: flex;
    flex-direction: row;
    gap: 2px;
    align-items: left;
}

.repo-input-button {
    border-radius: 6px 0 0 6px !important;
    box-shadow: 0 0 2px var(--primary-light) !important;
}

.repo-input-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: fit-content;
    text-align: left;
}

.repo-input-container label {
    font-size: 10px;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 2px;
}

.repo-input-container input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--bg);
    font-size: 14px;
    width: 220px;
}

.repo-input input::placeholder {
    color: var(--primary-light);
    opacity: 0.6;
}

#settings-button {
    color: var(--primary-light);
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

#settings-button:hover {
    color: var(--bg);
}

/*#endregion */

/*#region Main */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;

    min-height: 0;

    margin: 0 1rem 1rem 1rem;
}

.main .focused-commit, .commit-list {
    max-width: 1fr;
}

.main .focused-commit {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.main .commit-list-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    overflow: visible;
    overflow-y: scroll;
}

.main .commit-list {
    scrollbar-width: thin;
    /* NOTE: overflow-x: visible + overflow-y: scroll is impossible per CSS
       spec — the visible axis computes to auto and produces a horizontal
       scrollbar / clips overflowing children (tooltips, hover growth).
       Keep vertical scrolling here and portal overlays to <body> instead. */
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    /* Reserve breathing room so the hover scale fits inside the scroll
       container instead of overflowing it (which would either clip or, with
       overflow-x: auto, produce a horizontal scrollbar). */
    padding: 4px 10px 4px 4px;
}

.commit-list-section h4 {
    margin-left: -2px;
    margin-top: -0.25rem;
    margin-bottom: -0.1rem;
}

.commit-list-section .line-gap {
    width: 100%;
    border-bottom: 2px var(--primary-light) dashed;
    margin-bottom: 8px;
    opacity: 65%;
}

.commit-list .commit:nth-child(even) {
    background: var(--page-bg);
}

/*#region commit focus */
/*#region commit focus workflow */

.commit-focused-workflow-status:last-child {
    border-radius: 0 0 12px 12px;
}

.commit-focused-workflow-status:first-child {
    border-radius: 12px 12px 0 0;
}

.commit-focused-workflow-status {
    display: flex;
    flex-direction: row;
    justify-content: baseline;
    align-items: center;
    background-color: var(--secondary);
    border-bottom: var(--border) 2px solid;
    font-weight: 800;
    gap: 1rem;
    padding: 0.25rem;
    transition: all 0.1s ease-in;
    cursor: pointer;
    font-family: monospace;
}

.commit-focused-workflow-status:hover {
    scale: 1.01;
    background-color: var(--tertiary);
    font-weight: 1000;
}

.commit-focused-workflow-status__indicator {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}

/*#regionend */

.focused-commit-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.focused-commit-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.focused-commit-pi-chart {
    position: relative;
    flex-shrink: 0;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--page-bg);
}

.focused-commit-pi-chart-hitlayer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.focused-commit-pi-chart-center {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg);
    left: 10px;
    top: 10px;
    pointer-events: none;
}

.focused-commit-header-text {
    min-width: 0;
    flex: 1;
}

.focused-commit-text {
    font-weight: 400;
    font-size: 14px;
}

.focused-committer {
    display: flex;
    flex-direction: row;
}

.focused-committer-image {
    width: 44px;
    height: 44px;
    align-self: center;
    border-radius: 50%;
    margin: 2px;
}

.focused-commiter-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.focused-commit-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.focused-commiter-name-box {
    font-size: 12px;
}

.focused-commiter-name {
    font-size: 10px;
}

.focused-commit-meta {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    top: 0;
    margin-bottom: auto;
}

.focused-commit-meta-sha {
    font-size: 11px;
    color: var(--aqua);
    margin-top: 2px;
}

.focused-commit-meta-date {
    font-size: 11px;
    color: #8a887c;
    margin-top: 2px;
}

.focused-commit-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--primary);
}

.focused-commit-changes-added {
    color: var(--primary);
}

.focused-commit-changes-removed {
    color: var(--red);
}

.focused-commit-files {
    color: #8a887c;
}

/*#endregion */

/*#region commit template */
.commit {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    max-width: 100%;
    position: relative;
    transform-origin: center;
}

.commit:hover {
    background: var(--grey) !important;
    scale: 1.01;
    transform: translateX(1%);
    /* Paint the grown row above its siblings while it overlaps them. */
    z-index: 2;
}

.commit-pi-chart {
    position: relative;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--page-bg);
    align-self: center;
}

.commit-pi-chart-hitlayer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.commit-pi-chart .commit-pi-chart-center {
    position: relative;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg);
    left: 5px;
    top: 5px;
    pointer-events: none;
}

.commit-pi-chart,
.focused-commit-pi-chart {
    overflow: visible;
}

.commit-pi-chart-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--tooltip-bg, #1a1a1a);
    color: var(--tooltip-text, #fff);
    font-size: 12px;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    /* tooltip itself never intercepts hover */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 10;
    overflow: clip !important;
    z-index: 999;
}

.commit-pi-chart-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Portaled tooltip: appended to <body> with position: fixed so it renders
   on top of all scroll containers instead of being clipped / causing
   overflow-x scroll inside .commit-list. */
.commit-pi-chart-tooltip--global {
    position: fixed;
    /* left/top are set from JS (chart center, 8px above chart) */
    bottom: auto;
    transform: translate(-50%, -100%);
    z-index: 9999;
}

.commit-pi-chart-tooltip--global.is-visible {
    transform: translate(-50%, -100%);
}

.commit-pi-chart-center-actions-status {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    left: 5px;
    top: 5px;
    pointer-events: none;
    animation: pulse 1.5s infinite;
}

.commit-comitter-icon {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--ink);
    top:  -1px;
    left: -1px;
}

.commit-list .commit:nth-child(even) .commit-pi-chart {
    background: var(--bg);
}

.commit-list .commit:nth-child(even) .commit-pi-chart .commit-pi-chart-center {
    background: var(--page-bg);
}

.commit-content {
    flex: 1;
    min-width: 0;
}

.commit-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.commit-list-item-title {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commit-list-item-date {
    margin: 0;
    font-size: 11px;
    color: #8a887c;
    white-space: nowrap;
}

.commit-list-item-body {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 4px;
}

.commit-list-item-changes {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commit-list-item-line-changes-added {
    color: var(--primary);
}

.commit-list-item-line-changes-removed {
    color: var(--red);
}

.commit-list-item-sha {
    margin-top: 5px;
    font-size: 11px;
    color: var(--aqua);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/*#endregion */
/*#endregion */

/*#region Footer */
.footer {
    overflow-y: auto;
    min-height: 0;
}

/*#endregion */