/* Variables. */
/* Variables (Light Mode Default) */
:root {
    --background-color: #FAFAFA;
    --text-color: #191919;
    --link-color: gray;
    --link-hover-color: #212A37;
    --body-font: sans-serif;
    --code-bg: #eee; /* Added this */
}

/* Automatic Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #222428;
        --text-color: #c0c0c0;
        --link-color: #60a5fa;
        --link-hover-color: #4ade80;
        --code-bg: #333333; /* Darker background for code blocks */
    }
}
/* General */

body{
  background-color:var(--background-color);
  color:var(--text-color);
  font-family:var(--body-font);
  margin:0;
  padding:0;
}
body {
  background-color: var(--background-color);
  color: var(--text-color);
}
    /* For all paragraph tags */
p {
  line-height: 1.5; /* Unitless value, scales with font-size */
}
img{
  max-width:100%;
  max-height:100%;
  width:auto;
  height:auto;
}
a{
  color:var(--link-color);
  text-decoration:none;
}
a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
  text-underline-offset: 4px; /* A small gap makes it easier to read */
}
#container{
  max-width:700px;
  margin:0 auto;
  padding:1em;
}
pre{
  white-space:pre-wrap;
  word-break: break-all;
}
code{
  background-color:#eee;
  word-break: break-all;
  white-space:pre-wrap;
}
  
/* Header */

#title{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-weight:normal;
  color:var(--text-color);
}
/* Header Links - Base State */
#title a, .title-text a, .title-nav a {
  color: var(--text-color); /* Removed !important so hover can work */
  text-decoration: none;
  transition: color 0.2s ease; /* Smooth transition for color */
}

/* Header Links - Hover State */
#title a:hover, .title-text a:hover, .title-nav a:hover {
  color: var(--link-hover-color); /* Now the Green will show! */
  text-decoration: underline;
  text-underline-offset: 4px;
}
.title-arrow{
  transition:0.2s;
}
#description-toggle, .description{
  display:none;
}
#description-toggle:checked ~ .description {
  display:block;
}
#description-toggle:checked ~ * .title-arrow{
  transform:rotate(-180deg);
}
hr{
  border-top:1px solid var(--text-color);
  border-bottom:none;
  margin:1em 0;
}

/* Gallery Layout */
 
#gallery{
  display:grid;
  width:100%;
  gap:1em;
  grid-template-columns:repeat(3, 1fr);
}
/* Update the container to clip the zooming image */
#gallery a {
  color: var(--text-color);
  opacity: 1;
  transition: 0.3s ease; /* Faster transition feels snappier */
  display: grid;
  gap: 1em;
  align-items: flex-start;
  
  /* NEW: This keeps the border sharp and content contained */
  border-radius: 8px; /* Optional: adds slightly rounded corners */
  overflow: hidden;   /* Crucial: keeps the zoomed image inside the box */
  border: 3px solid transparent; /* Reserve space for border so layout doesn't jump */
}

/* The Hover State */
#gallery a:hover {
  opacity: 1; /* Keep full opacity so the border pops */
  border-color: var(--link-hover-color); /* The fun colored border! */
}

/* The Image Animation */
.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.5s ease; /* Smooth zoom movement */
}

/* Target the image specifically when the LINK is hovered */
#gallery a:hover .item-image img {
  transform: scale(1.05); /* Zooms in by 5% */
}
.item-title{
  text-align:center;
  font-size:0.9rem;
}

/* Page Layout */

#page, #page-flipped, #two-column, #three-column, #page-about, #page-project{
  display:grid;
  gap:1em;
}
#page-about .img-container{
  display:grid;
  justify-content:center;
  align-items:center;
}
#page-about .caption{
  text-align:left;
}
#page{
  grid-template-columns:2fr 1fr;
}
#page-flipped{
  grid-template-columns:1fr 2fr;
}
#two-column{
  grid-template-columns:repeat(2, 1fr);
}
#three-column{
  grid-template-columns:repeat(3, 1fr);
}
#two-column, #three-column{
  justify-content:center;
  align-items:center;
}
#page-about, #page-project{
  grid-template-columns:1fr 1.5fr;
}
.img-container{
  text-align:center;
}
.page-divider{
  display:none;
  margin-top:0;
}
.caption-always-centered{
  text-align:center;
}
.caption-always-left{
  text-align:left;
}
.caption-always-right{
  text-align:right;
}
#page-flipped .caption{
  text-align:right;
}
/* --- Footer Navigation --- */

.footer-nav {
  display: grid;
  /* This creates 3 columns: 
     1. Take up available space
     2. Only as wide as the content needs
     3. Take up available space */
  grid-template-columns: 1fr auto 1fr; 
  align-items: center;
  
  /* Spacing and visual lines */
  padding-top: 2rem;
  margin-top: 3rem; /* Pushes footer away from content */
  margin-bottom: 2rem;
  border-top: 1px solid rgba(128, 128, 128, 0.3); /* Matches your other dividers */
}

/* Align text within the grid cells */
.nav-item.left {
  text-align: left;
}

.nav-item.center {
  text-align: center;
}

.nav-item.right {
  text-align: right;
}

.footer-nav a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
}

.footer-nav a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
}
/* --- Footer Info Section --- */

.footer-info {
  text-align: center;
  margin-top: 2rem;      /* Space between Nav and Info */
  padding-bottom: 2rem;  /* Space at the very bottom of the page */
  font-size: 0.9rem;     /* Slightly smaller text */
  line-height: 1.6;
}

.footer-info p {
  margin: 0.5rem 0;      /* precise spacing between the two lines */
  opacity: 0.8;          /* Slightly fade the text so it's not distracting */
}

/* Ensure the link stands out but matches the theme */

.footer-info a {
  color: var(--text-color);
  text-decoration: none; /* Changed from 'underline' to 'none' */
}

/* Add the underline AND color only on hover */
.footer-info a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Mobile Tweak */
@media (max-width: 400px) {
  .footer-nav {
    font-size: 0.9rem; /* Shrink text slightly on very small screens */
  }
  .footer-info p {
    font-size: 0.9rem; /* Shrink text slightly on very small screens */
  }
}

/* Mobile */

@media (max-width:700px){
  #gallery{
  grid-template-columns:repeat(2, 1fr);
  }
  .page-divider{
  display:block;
  }
  #page .caption, #page-flipped .caption{
    text-align:center;
  }
  #page, #page-flipped, #page-about, #page-project, #three-column, #two-column{
    grid-template-columns:1fr;
  }
  .footer-info p {
    font-size: 0.9rem; /* Shrink text slightly on very small screens */
  }
}
/* --- Homepage Cover Image Styles --- */

/* 1. Set up the container (the .img div) */
.img {
  overflow: hidden;               /* Clips the image when it zooms */
  border-radius: 12px;             /* Optional: Rounded corners */
  border: 3px solid transparent;  /* Invisible border to reserve space */
  transition: border-color 0.3s ease;
  line-height: 0;                 /* Removes weird gap at bottom of images */
  display: inline-block;          /* Keeps it tight to the image size */
}

/* 2. Set up the image itself for animation */
.img img {
  transition: transform 0.5s ease;
  width: 100%;                    /* Ensures it fits the container */
  display: block;
}

/* 3. The Interaction: When you hover the LINK (a), effect the div and img */

/* Turn the border colored */
a:hover .img {
  border-color: var(--link-hover-color);
}

/* Zoom the image */
a:hover .img img {
  transform: scale(1.05);
}

/* --- Table of Contents (Split Layout) --- */

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.chapter-list li {
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

/* 1. Turn the link into a Flexbox container */
.chapter-list a {
  display: flex;              /* Activates the layout mode */
  justify-content: space-between; /* Pushes items to opposite edges */
  align-items: baseline;      /* Aligns text by the bottom of the letters */
  gap: 1rem;                  /* Ensures space between title and date */
  
  padding: 1rem 0.5rem;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.2s ease-out;
}

/* 2. Style the Title (Make it pop) */
.chapter-title {
  font-weight: bold;
  font-size: 1.1rem;
}

/* 3. Style the Date (Make it subtle) */
.chapter-date {
  font-size: 0.9rem;          /* Slightly smaller */
  opacity: 0.7;               /* Makes it slightly see-through (greyish) */
  text-align: right;
  font-style: italic;         /* Optional: looks nice for dates */
}

/* 4. Hover Effects */
.chapter-list a:hover {
  background-color: rgba(125, 125, 125, 0.05);
  padding-left: 1rem;         /* Slide effect */
  border-left: 4px solid var(--link-hover-color); /* Adds a colored bar on left */
}

.chapter-list a:hover .chapter-title {
  color: var(--link-hover-color); /* Only the title turns green */
}

.chapter-list a:hover .chapter-date {
  opacity: 1; /* Date becomes fully visible on hover */
}

/* 5. Mobile Friendly Adjustment */
@media (max-width: 600px) {
  .chapter-list a {
    flex-direction: column; /* Stack them vertically on phones */
    gap: 0.2rem;
  }
  .chapter-date {
    text-align: left; /* Align date left on phones */
    font-size: 0.8rem;
  }
}


/* --- Classic Book Header --- */

.book-header {
  text-align: center;
  margin-top: 3rem;    /* Lots of whitespace at the top feels expensive */
  margin-bottom: 3rem; /* Space before the story starts */
}

.chapter-label {
  font-family: "Georgia", serif; /* Force a serif font for that book feel */
  text-transform: uppercase;     /* Makes it all caps */
  letter-spacing: 4px;           /* Stretches the letters wide (classic look) */
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;                  /* Slightly faded */
  margin-bottom: 0.5rem;
}

.book-title {
  font-family: "Georgia", serif; 
  font-size: 2.5rem;             /* Nice and big */
  font-weight: normal;           /* Not too bold, keeps it elegant */
  margin: 0;
  line-height: 1.2;
  color: var(--text-color);
}

/* The Decorative Line */
.chapter-divider {
  width: 60px;                   /* Keep it short */
  height: 2px;
  background-color: var(--text-color);
  margin: 1.5rem auto 0;         /* Centers it horizontally */
  opacity: 0.3;                  /* Make it subtle */
}

/* Mobile Adjustment */
@media (max-width: 600px) {
  .book-title {
    font-size: 2rem; /* Slightly smaller on phones */
  }
}


/* --- Story Text Styling --- */

/* Target paragraphs only inside the content container */
#container p {
  margin-bottom: 1.6em;   /* Classic blog spacing */
  line-height: 1.8;       /* Taller lines = easier deep reading */
  font-size: 1.1rem;      /* Slightly larger than standard web text */
  max-width: 65ch;        /* "ch" means characters. 65 is the perfect reading width. */
  margin-left: auto;      /* Centers the text block if the screen is wide */
  margin-right: auto;
}


/* --- Salutation Styling --- */
.salutation {
  font-style: italic;       /* Makes "Dear Richard," look handwritten/personal */
  margin-bottom: 0.5rem !important; /* Pulls it closer to the text below */
  color: var(--text-light); /* Optional: Makes it slightly softer than black */
}

/* --- The Drop Cap (Targeting the paragraph AFTER the salutation) --- */
.salutation + p::first-letter {
  float: left;
  font-family: "Georgia", serif;
  font-size: 3.8rem;
  line-height: 0.8;
  padding-right: 0.5rem;
  padding-top: 0.1rem;
  color: var(--text-color);
  font-weight: bold;
}