/* Theme variables */
:root {
    --bg: #f5f5f5;
    --text: #111111;
    --muted: #4d4d4d;          /* slightly stronger for readability on sage bg */
    --link: #0b57d0;
    --border: #b8c0b3;        /* softer border tuned to the bg */
    --hover-bg: #e7ece4;      /* subtle hover tone that fits the palette */
}

.dark {
    --bg: #0d0f10;        /* deep charcoal */
    --text: #f1f5f9;      /* near-white */
    --muted: #c8d1da;     /* softer light */
    --link: #8ab4ff;      /* readable blue on dark */
    --border: #222a30;    /* subtle border */
    --hover-bg: #161a1d;  /* slight lift */
}

/* Base reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Barlow Condensed', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* prevent any stray horizontal scroll */
}

/* Scrollbars */
*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

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

*::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 999px;
    border: 3px solid var(--bg);
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--muted);
}

*::-webkit-scrollbar-corner {
    background: var(--bg);
}

/* Firefox */
html {
    scrollbar-color: var(--border) var(--bg);
    scrollbar-width: thin;
}

/* Layout */
.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100svh; /* fill viewport height without extra margins */
    display: flex;
    flex-direction: column;
    justify-content: center; /* vertical center */
}

/* Fallback when svh isn't supported */
@supports not (height: 1svh) {
    .wrap { min-height: 100vh; }
}

/* Mobile: more side padding, keep vertical centering */
@media (max-width: 600px) {
    .wrap {
        justify-content: center;
        padding: 12px 28px 20px; /* top | sides | bottom */
    }
    .section { margin-top: 24px; }
}

.title {
    font-size: clamp(29px, 5vw, 45px);
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.lede {
    margin-top: 12px;
    color: var(--muted);
    font-size: clamp(18px, 2.5vw, 21px);
}

/* Extra-tight sizes on very small screens */
@media (max-width: 420px) {
    .title { font-size: clamp(25px, 7vw, 37px); }
    .lede { font-size: clamp(17px, 3.5vw, 19px); }
    .section h2 { font-size: 15px; }
}

/* Slightly larger link text on big screens, smaller on small */
.links { font-size: 18px; }
@media (max-width: 600px) { .links { font-size: 17px; } }
@media (min-width: 1200px) { .links { font-size: 19px; } }

.section { margin-top: 36px; }
.section.subtle { opacity: 0.9; }
.section h2 {
    font-size: 17px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 10px;
}

.not-found {
    text-align: center;
    gap: 10px;
}

/* All links site-wide get yellowish hover - MUST come before specific overrides */
a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 2px dotted var(--border);
    padding-bottom: 2px;
    background-image: linear-gradient(0deg, rgba(255, 213, 0, 1), rgba(255, 213, 0, 1));
    background-size: 100% 0%;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 260ms ease-in-out, color 160ms ease-in, border-color 160ms ease-in;
}

a:hover {
    color: var(--link);
    border-color: var(--link);
    background-size: 100% 100%;
}

.dark a:hover {
    color: #2b2b2b;
    border-color: #2b2b2b;;
    background-size: 100% 100%;
}

.links { list-style: none; }
.links li { margin: 6px 0; }

.copyright {
    margin-top: 32px;
    color: var(--muted);
    font-size: 16px;
}

/* Breadcrumb navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 0;
    font-size: 15px;
    color: var(--muted);
}

.breadcrumb-link {
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
    background-image: linear-gradient(0deg, rgba(255, 213, 0, 1), rgba(255, 213, 0, 1));
    background-size: 100% 0%;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 260ms ease-in-out, color 160ms ease-in, border-color 160ms ease-in;
}

.breadcrumb-link:hover { /* hover styling handled globally */ }

.breadcrumb-separator {
    color: var(--muted);
    user-select: none;
    font-weight: 600;
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

.post-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.post-list li {
    margin: 12px 0;
}

/* Blog and general content pages */
.container { 
    max-width: 720px; 
    margin: 0 auto; 
    padding: 48px 20px 56px; 
    font-size: 18px; 
    line-height: 1.6; 
}
@media (max-width: 600px) {
    .container { padding: 32px 20px 44px; }
}
.container h1 { font-size: clamp(29px, 5vw, 45px); margin-bottom: 14px; line-height: 1.1; }
.description { color: var(--muted); margin-bottom: 16px; font-size: 18px; }

.content { margin-top: 20px; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 14px;
}
.emoji-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.emoji-item:hover { transform: translateY(-2px); border-color: var(--link); }
.emoji-item .emoji { font-size: 2.2rem; }
.emoji-item .label { margin-top: 6px; font-size: 14px; color: var(--muted); }
.copy-feedback { display: none; }

@media (max-width: 520px) {
    .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}

/* Hash Map Playground */
.hashing-playground {
    margin-top: 20px;
    display: grid;
    gap: 18px;
}

.hashing-controls {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg) 92%, var(--hover-bg));
}

.hashing-control {
    display: grid;
    gap: 8px;
}

.hashing-control label {
    font-weight: 600;
}

.hashing-control small {
    color: var(--muted);
}

.hashing-controls input[type="range"] {
    width: 100%;
}

.hashing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.hashing-button {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--text);
    color: var(--bg);
    padding: 10px 18px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.hashing-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hashing-button:not(:disabled):hover {
    transform: translateY(-1px);
}

.hashing-output {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    gap: 10px;
    background: color-mix(in srgb, var(--bg) 96%, var(--hover-bg));
}

.hashing-output canvas {
    width: 100%;
    max-height: 360px;
}

.hashing-metric {
    font-size: 20px;
    font-weight: 700;
}

.hashing-status {
    color: var(--muted);
    font-size: 16px;
}

/* Password Generator */
.password-generator {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.password-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    background: color-mix(in srgb, var(--bg) 90%, white 10%);
}

.dark .password-card {
    background: color-mix(in srgb, var(--bg) 92%, var(--hover-bg));
}

.password-header {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.password-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.password-hint {
    color: var(--muted);
    font-size: 15px;
}

.password-display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--bg) 96%, var(--hover-bg));
}

.password-text {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: clamp(18px, 2.2vw, 24px);
    letter-spacing: 0.02em;
    flex: 1 1 220px;
    word-break: break-all;
    order: 1;
}

.password-button {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--hover-bg);
    color: var(--text);
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.password-display .password-button {
    margin-left: auto;
    order: 3;
}

.password-button.primary {
    background: var(--link);
    border-color: var(--link);
    color: #ffffff;
}

.password-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.password-button:not(:disabled):hover {
    transform: translateY(-1px);
}

.password-generator .copy-feedback {
    display: none;
    align-items: center;
    font-size: 14px;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.2s ease;
    order: 2;
}

.password-generator .copy-feedback.show {
    display: inline-flex;
    opacity: 1;
}

.password-error {
    margin-top: 10px;
    color: #b00020;
    font-size: 14px;
    min-height: 18px;
}

.control {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.control:last-child {
    margin-bottom: 0;
}

.control-label {
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.control-value {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

ul {
    padding-left: 1.5rem;
}

.toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #c5cdd8;
    position: relative;
    transition: background 0.2s ease;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
    background: #2d7ff9;
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(45, 127, 249, 0.35);
}

.toggle-label {
    font-weight: 500;
}

.strength-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.strength-weak {
    background: #fce8e6;
    color: #b00020;
}

.strength-medium {
    background: #fff4cf;
    color: #8a5b00;
}

.strength-strong,
.strength-very-strong {
    background: #d7f5d8;
    color: #256029;
}

@media (max-width: 540px) {
    .password-label {
        flex-direction: column;
        align-items: flex-start;
    }

    .password-display {
        align-items: stretch;
    }

    .password-button {
        width: 100%;
        text-align: center;
    }

    .password-generator .copy-feedback,
    .password-generator .copy-feedback.show {
        display: none;
        opacity: 0;
    }
}