/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&family=Lora&family=Poppins&display=swap');

/* ========================================
  CSS Variables
========================================
*/

/* 1. Color Themes */
:root,
body.theme-light {
    --color-bg: #F8F9FA;
    --color-text: #343A40;
    --color-accent: #B07D62;
    --color-ui-border: #030304;
    --color-ui-bg: #F8F9FA;
}

body.theme-sepia {
    --color-bg: #FBF3E6;
    --color-text: #5D4037;
    --color-accent: #B07D62;
    --color-ui-border: #000000;
    --color-ui-bg: #FBF3E6;
}

body.theme-dark {
    --color-bg: #25292D;
    --color-text: #CED4DA;
    --color-accent: #B07D62;
    --color-ui-border: #495057;
    --color-ui-bg: #343A40;
}

/* 2. Font Styles */
:root,
body.font-sans {
    --font-body: 'Poppins', sans-serif;
    --font-heading: 'Poppins', sans-serif;
}

body.font-serif {
    --font-body: 'Lora', serif;
    --font-heading: 'Lora', serif;
}

body.font-accessible {
    --font-body: 'Atkinson Hyperlegible', sans-serif;
    --font-heading: 'Atkinson Hyperlegible', sans-serif;
}

/* ========================================
  Global Styles & Reset
========================================
*/
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: 1.7;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
  Typography
========================================
*/
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.1rem; }

p {
    margin-top: 0;
    margin-bottom: 1.2em;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

blockquote {
    margin-left: 1em;
    padding-left: 1em;
    border-left: 4px solid var(--color-accent);
    font-style: italic;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ========================================
  Layout & Header
========================================
*/
.navbar,
.content-wrapper {
    max-width: 750px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.blog-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 2.25rem;
    line-height: 1.1;
}

.title-link {
    color: var(--color-text);
    text-decoration: none;
}
.title-link:hover {
    color: var(--color-accent);
    text-decoration: none;
}

.content-wrapper {
    padding-top: 1rem;
    padding-bottom: 3rem;
}

/* ========================================
  Appearance Button & Modal
========================================
*/

.appearance-toggle {
    background: none;
    border: 1px solid var(--color-ui-border);
    color: var(--color-text);
    border-radius: 5px;
    padding: 0.25rem 0.75rem;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.2s ease;
}

.appearance-toggle:hover {
    background: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
}

.appearance-wrapper {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end; /* align dropdown under button */
    /* Uncomment for debugging */
    /* background: red; padding: 20px; */
}

.appearance-modal {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--color-ui-bg);
    border: 1px solid var(--color-ui-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: 8px;
    z-index: 1000;
}

.appearance-modal[hidden] {
    display: none;
}

.appearance-modal h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
}

.setting-group {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.setting-group button {
    flex: 1;
    background: none;
    border: 1px solid var(--color-ui-border);
    color: var(--color-text);
    padding: 0.5rem 0.25rem;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.setting-group button:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.setting-group button.active {
    background: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
}

/* ========================================
  Post Styles
========================================
*/

.post-preview {
    border-bottom: 1px solid var(--color-ui-border);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.post-preview h2 {
    margin-top: 0;
}

.post-preview h2 a {
    color: var(--color-text);
    text-decoration: none;
}

.post-preview h2 a:hover {
    color: var(--color-accent);
}

.post-meta {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.read-more {
    font-family: var(--font-heading);
    font-weight: 600;
}

.post-full h1 {
    margin-top: 0;
}

.post-full .post-meta {
    margin-bottom: 2rem;
}

/* ========================================
  Navbar Links
========================================
*/
.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: var(--color-accent);
    opacity: 1;
    text-decoration: none;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}
/* ========================================
  Responsiveness
========================================
*/
@media (max-width: 600px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    .appearance-modal {
    /* This aligns the modal's right edge with its parent (the 'Aa' button) */
    right: 0; 
    left: auto; /* We no longer want it to stretch from the left */

    /* This is the key: it sets a max width to prevent overflow */
    /* It can be 220px, but no wider than the screen (minus padding) */
    max-width: calc(100vw - 2rem); 

    /* We can let it try to be 220px, but max-width will stop it */
    width: 220px; 
}
    .navbar {
    /* Stack the left (title/links) and right ('Aa' button) sections */
    flex-direction: column;
    align-items: flex-start; /* Align everything to the left */
    gap: 1rem; /* Add space between the stacked sections */
    position: relative; /* Needed for positioning the 'Aa' button */
}

.nav-left {
    /* Stack the title and the nav links */
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem; /* Tighter space between title and links */
}

.blog-title {
    font-size: 2rem; /* Slightly smaller title on mobile */
}

.nav-links {
    /* Ensure links are stacked and not side-by-side */
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.appearance-wrapper {
    /* Move the 'Aa' button to the top right corner */
    /* This takes it out of the normal flow */
    position: absolute;
    top: 1.5rem;
    right: 1rem;
}
}
.post-full img {
    max-width: 100%;
    height: auto;
    border-radius: 8px; /* This just adds nice rounded corners */
}
