/* Import subtle handwritten font for headings */
@import url('https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Caveat:wght@400;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400..700;1,400..700&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400..700;1,400..700&family=Grandstander:ital,wght@0,100..900;1,100..900&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');
:root {
    /* Shadows & Effects */
    --shadow-subtle: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.16);

    /* Spacing */
    --default-margin: 10px;
    --card-padding: 1.5rem;
    --section-spacing: 3rem;

    /* Typography */
    --font-sansserif: 'Inter', 'Arial';
    --font-semi-handwriting: 'Grandstander', 'Inter', 'Arial';
    --font-handwriting: 'Architects Daughter', 'Inter', 'Arial';

    /* Layout */
    --max-width: 1280px;
    --content-width: 80%;

    scroll-behavior: smooth;
}

/* ============================================
   BASE STYLES
   ============================================ */

body {
    counter-reset: sidenote-counter;
    max-width: var(--max-width);
    width: 90%;
    margin: auto;
    padding: 2.5%;
    background-color: var(--color-bg);
    color: var(--color-text-body);
    font-family: var(--font-sansserif), sans-serif;
    font-size: 1.4rem;
    line-height: 1.6;
    position: relative;
}
/* ============================================
   THEME COLORS
   Theme is set on <html> element to prevent flash
   ============================================ */

:root[data-theme="light"] {
    --color-bg: #af9b75;
    --color-off-white: #cac4a6;
    --color-text-body: #2A2A2A;
    --color-text-secondary: #6B6B6B;
    --color-accent: #993399;
    --color-deco-A: #D4A574;
    --color-deco-B: #FFB4A2;
    --color-deco-C: #8B7355;
}

:root[data-theme="dark"] {
    --color-bg: #1A1612;
    --color-off-white: #2D2620;
    --color-text-body: #E8E6E3;
    --color-text-secondary: #A8A8A8;
    --color-accent: #C97AB8;
    --color-deco-A: #8B6F47;
    --color-deco-B: #B8755E;
    --color-deco-C: #A68B6A;
}

/* Tint black icons to match --color-text-body */
:root[data-theme="light"] .external-link-icon {
    filter: invert(0.25);
}

:root[data-theme="dark"] .external-link-icon {
    filter: invert(0.7);
}

/* ============================================
   DARK MODE TOGGLE
   ============================================ */

.theme-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 2rem;
    z-index: 1000;
    transition: transform 200ms ease;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    transform: scale(1.2) rotate(20deg);
}
/* ============================================
   TYPOGRAPHY
   ============================================ */

/* H1 is site title only */
h1 {
    font-size: 4em;
    margin-bottom: 0.2em;
    line-height: 1.1;
    font-weight: 400;
    font-family: var(--font-handwriting), sans-serif;
}

/* H1 is used for the site title; underline is not wanted there */
h1 a {
    text-decoration: none;
}

/* Site title should be black by default and accented when hovered */
h1 a:hover {
    color: var(--color-accent);
}

/* Subtitle shown next to site title on section pages */
.site-subtitle {
    font-size: 0.6em;
    font-weight: 400;
}

/* H2 is used for page titles */
h2 {
    font-size: 2.5em;
    margin-top: 1.5em;
}

/* H3 is used within pages */
h3 {
    font-size: 1.8em;
}

/* Links have an underline and get accented with a line shift effect when hovered over */
a {
    text-decoration: underline 0.15em var(--color-text-body);
    text-underline-offset: 0.2em;
    transition: text-decoration-color 300ms, text-underline-offset 300ms, color 300ms;
    color: var(--color-text-body);
}

a:hover {
    text-decoration-color: var(--color-accent);
    text-underline-offset: 0.4em;
    color: var(--color-accent);
}

/* The highlight class can be used to make any text accented even if it's not the link */
.highlight {
    color: var(--color-accent);
}

/* Highlighted links are accented by default and become black when hovered over */
.highlight a {
    color: var(--color-accent);
    text-decoration-color: var(--color-accent);
}

.highlight a:hover {
    color: var(--color-text-body);
    text-decoration-color: var(--color-text-body);
}

/* Make any text small caps */
.smallcaps {
    font-variant: small-caps;
}

/* Add a left vertical line next to block quotes */
blockquote {
    border-left: 3px solid var(--color-deco-A);
    padding-left: 20px;
    color: var(--color-text-secondary);
}
/* ============================================
   CARD COMPONENTS
   ============================================ */

.landing-intro {
    position: relative;
    background: transparent;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}

.landing-intro-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.landing-intro p {
    margin: 0 0 1rem 0;
}

.landing-intro p:last-child {
    margin-bottom: 0;
}

.card {
    background: var(--color-off-white);
    border: 8px solid var(--color-off-white);
    border-bottom-width: 40px; /* Polaroid bottom margin */
    box-shadow: var(--shadow-card);
    padding: var(--card-padding);
    margin-bottom: 2rem;
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* Link cards for landing page.
 * Link cards are wide and short; a .link-card div contains
 */

.link-card {
    position: relative;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: transform 300ms ease;
    background: transparent;
    border: none;
}

/* Canvas for rough.js sketch background */
.link-card-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.link-card:hover {
    transform: translateY(-4px) rotate(0deg);
}

.link-card-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.link-card-title {
    font-family: var(--font-handwriting), sans-serif;
    font-size: 1.6em;
    margin: 0;
    color: var(--color-accent);
    line-height: 1.2;
    display: block;
}

.link-card-description {
    color: var(--color-text-secondary);
    margin: 0.3em 0 0 0;
    font-size: 1rem;
    display: block;
}

.external-links-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.external-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    width: 93px;
    background: var(--color-off-white);
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.1));
    text-decoration: none;
    color: var(--color-text-body);
    transition: transform 200ms ease, filter 200ms ease, color 200ms ease;
    text-align: center;
    font-family: var(--font-semi-handwriting), sans-serif;
}

.external-link:hover {
    transform: translateY(-2px) rotate(-0.5deg);
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.15));
    color: var(--color-accent);
}

.external-link-icon {
    width: 2em;
    height: 2em;
    display: block;
}
/* ============================================
   BLOG
   ============================================ */

/* Blog List Container */
.blog-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Blog Card */
.blog-card {
    display: block;
    background: var(--color-off-white);
    padding: 1.5rem;
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.12));
    transition: transform 200ms ease, filter 200ms ease;
    text-decoration: none;
}

.blog-card:hover {
    transform: translateY(-2px) rotate(-0.3deg);
    filter: drop-shadow(3px 5px 8px rgba(0, 0, 0, 0.18));
    text-decoration: none;
}

.blog-card-content {
    display: flex;
    flex-direction: row-reverse;
    gap: 1.5rem;
    align-items: flex-start;
}

/* Blog Thumbnail (right side) */
.blog-thumbnail {
    width: 180px;
    min-width: 180px;
    aspect-ratio: 4/3;
    object-fit: cover;
    flex-shrink: 0;
}

/* Blog Card Text Content */
.blog-card-text {
    flex: 1;
    min-width: 0;
}

/* Blog Title */
.blog-title {
    font-size: 1.6em;
    font-weight: 600;
    margin: 0 0 0.4rem 0;
    line-height: 1.3;
    font-family: var(--font-semi-handwriting), sans-serif;
    color: var(--color-text-body);
}

.blog-card:hover .blog-title {
    color: var(--color-accent);
}

/* Blog Date */
.blog-date {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    display: block;
    margin-bottom: 0.6rem;
}

/* Blog Blurb */
.blog-blurb {
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
    color: var(--color-text-body);
}

/* Blog Meta */
.blog-meta {
    color: var(--color-text-secondary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* Tags */
.blog-tags {
    display: inline-flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: var(--color-deco-B);
    padding: 0.3em 0.8em;
    border-radius: 3px;
    font-size: 0.9rem;
    color: var(--color-text-body);
    text-decoration: none;
    box-shadow: var(--shadow-subtle);
}

.tag:hover {
    background: var(--color-deco-A);
}

/* Responsive: Stack vertically on smaller screens */
@media (max-width: 640px) {
    .blog-card-content {
        flex-direction: column;
    }

    .blog-thumbnail {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
    }

    .blog-title {
        font-size: 1.4em;
    }
}

/* ============================================
   ARTICLE CARDS (Research & Writings)
   ============================================ */

/* Article List Container */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Article Card - toned down version of blog card */
.article-card {
    display: block;
    background: var(--color-off-white);
    padding: 1.25rem;
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.10));
    transition: transform 200ms ease, filter 200ms ease;
    text-decoration: none;
}

.article-card:hover {
    transform: translateY(-1px) rotate(-0.15deg);
    filter: drop-shadow(2px 3px 5px rgba(0, 0, 0, 0.14));
    text-decoration: none;
}

.article-card-content {
    display: flex;
    flex-direction: row-reverse;
    gap: 1.25rem;
    align-items: flex-start;
}

/* Article Thumbnail (right side) */
.article-thumbnail {
    width: 160px;
    min-width: 160px;
    aspect-ratio: 4/3;
    object-fit: cover;
    flex-shrink: 0;
}

/* Article Card Text Content */
.article-card-text {
    flex: 1;
    min-width: 0;
}

/* Article Title - uses sans-serif font */
.article-title {
    font-size: 1.4em;
    font-weight: 600;
    margin: 0 0 0.3rem 0;
    line-height: 1.3;
    font-family: var(--font-sansserif), sans-serif;
    color: var(--color-text-body);
}

.article-card:hover .article-title {
    color: var(--color-accent);
}

/* Article Date */
.article-date {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.4rem;
}

/* Article Collaborators */
.article-collaborators {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.4rem;
}

/* Article Blurb */
.article-blurb {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
    color: var(--color-text-body);
}

/* Responsive: Stack vertically on smaller screens */
@media (max-width: 640px) {
    .article-card-content {
        flex-direction: column;
    }

    .article-thumbnail {
        width: 100%;
        min-width: 100%;
        max-height: 180px;
    }

    .article-title {
        font-size: 1.25em;
    }
}

/* ============================================
   MICROBLOG
   ============================================ */

.microblog-card {
    background: var(--color-off-white);
    padding: 0.75rem;
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.12));
    transition: transform 200ms ease, filter 200ms ease;
}

.microblog-card:hover {
    transform: translateY(-2px) rotate(-0.5deg);
    filter: drop-shadow(3px 5px 8px rgba(0, 0, 0, 0.18));
}

.microblog-card img {
    width: 100%;
    display: block;
    margin: 0;
    max-width: 100%;
}

.microblog-card-content {
    padding: 1rem;
}

.microblog-title {
    font-size: 1.3em;
    font-weight: 600;
    margin: 0 0 0.3rem 0;
    line-height: 1.3;
    font-family: var(--font-semi-handwriting), sans-serif;
}

.microblog-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.microblog-date {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.microblog-permalink {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
}

.microblog-permalink:hover {
    color: var(--color-accent);
}

.microblog-body {
    font-size: 1rem;
    line-height: 1.5;
}

.microblog-body p {
    margin: 0 0 0.5rem 0;
}

.microblog-body p:last-child {
    margin-bottom: 0;
}

/* Single microblog post view (permalink page) */
.microblog-single {
    display: flex;
    justify-content: center;
}

.microblog-single .microblog-card {
    width: 95%;
    max-width: 800px;
}

.microblog-single .microblog-card:hover {
    transform: none;
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.12));
}

/* Masonry grid (for microblog) */
.microblog-grid {
    /* Masonry handles layout via JS */
}

.microblog-grid .microblog-card {
    width: 31.5%;
    margin-bottom: 2rem;
}

/* Sizer element for Masonry columnWidth */
.microblog-grid-sizer {
    width: 31.5%;
}

/* Gutter sizer for Masonry */
.microblog-gutter-sizer {
    width: 2.5%;
}

@media (max-width: 1024px) {
    .microblog-grid .microblog-card,
    .microblog-grid-sizer {
        width: 48%;
    }

    .microblog-gutter-sizer {
        width: 4%;
    }
}

@media (max-width: 640px) {
    .microblog-grid .microblog-card,
    .microblog-grid-sizer {
        width: 95%;
    }

    .microblog-gutter-sizer {
        width: 0;
    }
}
/* ============================================
   IMAGES
   ============================================ */

/* By default, images are centered and slightly less than 100% wide */
img {
    max-width: 80%;
    display: block;
    margin: auto;
}

/* Full-width images */
.full-image {
    max-width: 100%;
}

/* Slightly wider images; used for post thumbnails */
.wide-image {
    max-width: 90%;
    margin: auto;
}

.small-image {
    float: right;
    aspect-ratio: 4/3;
    object-fit: cover;
    width: 200px;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card);
    border: 4px solid var(--color-off-white);
}

.textsize-image {
    height: 1em;
    width: auto;
    display: inline;
}
/* ============================================
   LAYOUT UTILITIES
   ============================================ */

.title {
    margin-bottom: 0;
}

footer {
    width: 100%;
    text-align: center;
    margin: 2.5%;
    padding-top: 3rem;
    border-top: 1px solid var(--color-deco-A);
    color: var(--color-text-secondary);
}

/* Portfolio Grid */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}
/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    body {
        font-size: 1.2rem;
        width: 95%;
        padding: 2%;
    }

    h1 {
        font-size: 3em;
    }

    h2 {
        font-size: 2em;
    }

    .card,
    .link-card,
    .blog-item {
        border-width: 4px;
        border-bottom-width: 20px;
        padding: 1rem;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    article > p,
    article > footer,
    article > table {
        width: 100%;
    }
}
/* ============================================
   UTILITY CLASSES
   ============================================ */

.font-sans {
    font-family: var(--font-sansserif), sans-serif;
}

.font-hand {
    font-family: var(--font-handwriting), sans-serif;
}