@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,700;1,6..72,400&family=Space+Grotesk:wght@400;700&display=swap");

:root {
  /* Colors */
  --surface: #fffcf7;
  --surface-container-low: #fcf9f3;
  --surface-container-lowest: #ffffff;
  --surface-container-highest: #e0ddd7; /* Calculated approximation based on progression */
  --surface-bright: #ffffff;

  --on-surface: #383831;
  --on-background: #383831; /* Use this for text, no pure black */

  --primary: #5f5e5e;
  --primary-dim: #535252;
  --on-primary: #fffcf7;

  --secondary: #845c32;
  --tertiary: #3d6d5d;

  --outline: rgba(186, 186, 176, 0.15); /* Ghost Border */
  --outline-variant: #babab0;

  /* Syntax Highlighting */
  --secondary-fixed-dim: #c48c53;
  --tertiary-fixed-dim: #659a86;

  /* Typography */
  --font-display: "Newsreader", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "Space Grotesk", monospace;

  /* Spacing Scale */
  --spacing-10: 3.5rem;
  --spacing-16: 5.5rem;
  --spacing-24: 8.5rem;
  --spacing-20: 7rem;
}

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--on-background);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* Typography Scale */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--on-background);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1.display-lg,
.hero-title {
  font-size: 3.5rem;
  margin-left: 15%; /* Asymmetrical alignment */
  line-height: 1.1;
  margin-bottom: var(--spacing-16);
}

h2.headline-md,
.section-title {
  font-size: 1.75rem;
  margin-bottom: 2rem;
}

.label-sm {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--tertiary);
}

/* Base Layout Elements */
main {
  max-width: 800px;
  margin: auto;
  padding: 0 1.5rem;
  padding-bottom: var(--spacing-24);
}

header {
  margin-top: var(--spacing-16);
  margin-bottom: var(--spacing-10);
}

/* Floating Navigation */
nav {
  position: sticky;
  top: 1rem;
  max-width: 800px;
  margin: 1rem auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;

  /* Glassmorphism */
  background: rgba(255, 252, 247, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  /* Ambient Shadow */
  box-shadow: 0 16px 32px rgba(56, 56, 49, 0.05);
  z-index: 100;
}

nav .site-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--on-background);
}

nav a:not(.site-title) {
  margin-left: 2rem;
  text-decoration: none;
  color: var(--on-background);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.3s ease;
}

nav a:hover {
  color: var(--secondary);
}

/* Projects / Articles List */
ul.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

ul.article-list > li {
  background: var(--surface-container-low);
  padding: 2rem;
  margin-bottom: var(--spacing-10);
  border-radius: 0px;
  position: relative;
  /* Ghost Border */
  border: 1px solid var(--outline);
}

ul.article-list > li a {
  text-decoration: none;
  color: var(--on-background);
  font-family: var(--font-display);
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

ul.article-list > li a:hover {
  color: var(--secondary);
}

ul.article-list time {
  display: block;
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  text-decoration: none;
  border-radius: 0px;
  cursor: pointer;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

.btn-primary {
  background: linear-gradient(145deg, var(--primary), var(--primary-dim));
  color: var(--on-primary);
  border: none;
}

.btn-primary:hover {
  background: var(--secondary);
  color: var(--on-primary);
}

.btn-secondary {
  background: transparent;
  color: var(--on-background);
  border: 1px solid var(--outline);
}

.btn-secondary:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

/* Code Fragments */
pre,
code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  border-radius: 0px;
}

pre {
  background: var(--surface-container-highest);
  padding: 1.5rem;
  overflow-x: auto;
  border-left: 4px solid var(--tertiary);
  margin: 2rem 0;
}

code {
  color: var(--tertiary-fixed-dim);
}

/* Input Fields */
input,
textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  border-radius: 0px;
  padding: 0.5rem 0;
  font-family: var(--font-body);
  color: var(--on-background);
  font-size: 1rem;
  width: 100%;
  margin-bottom: 2rem;
  transition: border-bottom-color 0.3s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-bottom: 2px solid var(--secondary);
}

label {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--on-background);
  display: block;
  margin-bottom: 0.5rem;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 0px; /* Force sharp corners */
}

/* Forms / Input specific layout */
.form-group {
  margin-bottom: 2rem;
}

/* Footer / Meta Links */
footer.editorial-footer {
  margin-top: var(--spacing-24);
  padding: var(--spacing-16) 0;
  background: var(--surface-container-low);
  /* Boundary defined solely by background color shift */
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 2.5fr; /* Intentional Asymmetry */
  gap: var(--spacing-10);
}

@media (max-width: 600px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

/* For TAGLIST.HTML */
.taglist {
  text-align: left;
}

.taglist ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column; /* Act as an index/appendix */
  gap: 1rem;
}

.taglist a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  color: var(--tertiary);
  letter-spacing: 0.15em;
  transition: color 0.3s ease;
}

.taglist a::before {
  content: "→";
  margin-right: 0.5rem;
  color: var(--outline-variant);
}

.taglist a:hover {
  color: var(--secondary);
}

/* For NEXTPREV.HTML */
.footer-nav {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-10);
}

.footer-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.footer-nav .nav-item a.display-md {
  font-family: var(--font-display);
  font-size: 2.5rem;
  line-height: 1.1;
  color: var(--on-background);
  text-decoration: none;
  margin-top: 0.5rem;
  transition: color 0.3s ease;
}

.footer-nav .nav-item a.display-md:hover {
  color: var(--secondary);
}

/* Selection Highlighting */
::selection {
  background: var(--secondary);
  color: var(--on-primary);
}
::-moz-selection {
  background: var(--secondary);
  color: var(--on-primary);
}

/* Article Links */
article a {
  color: var(--on-background);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition:
    color 0.3s ease,
    text-decoration-color 0.3s ease;
}

article a:hover {
  color: var(--secondary);
  text-decoration-color: var(--secondary);
}

/* Content Elements */
article p {
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
}

article ul,
article ol {
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

article li {
  margin-bottom: 0.5rem;
}

blockquote {
  margin: var(--spacing-10) 0;
  padding-left: 2rem;
  border-left: 4px solid var(--primary);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--primary);
}

/* Inline Code & Mark */
mark {
  background: var(--surface-container-highest);
  color: var(--secondary);
  padding: 0 0.25rem;
}

article code {
  background: var(--surface-container-highest);
  padding: 0.15rem 0.35rem;
  font-size: 0.875rem;
  color: var(--tertiary-fixed-dim);
}

/* Dark Mode Variables */
:root[data-theme="dark"] {
  --surface: #1c1b1a;
  --surface-container-low: #242321;
  --surface-container-lowest: #141312;
  --surface-container-highest: #302f2d;
  --surface-bright: #383734;

  --on-surface: #e3e1db;
  --on-background: #e3e1db;

  --primary: #a8a6a6;
  --primary-dim: #969494;
  --on-primary: #1c1b1a;

  --secondary: #e09f53;
  --tertiary: #6b9e89;

  --outline: rgba(227, 225, 219, 0.15);
  --outline-variant: #666562;

  --secondary-fixed-dim: #e09f53;
  --tertiary-fixed-dim: #6b9e89;
}

:root[data-theme="dark"] nav {
  background: rgba(28, 27, 26, 0.8);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
}

/* Theme Toggle Button */
#theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  background: var(--surface-container-highest);
  color: var(--on-background);
  border: 1px solid var(--outline);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  z-index: 1000;
  transition:
    background 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease;
  border-radius: 0px; /* Explicitly forced sharp corners per DESIGN.md */
}

#theme-toggle:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background: var(--surface-container-low);
}

/* Transition for body to make theme switching smooth */
body {
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* PORTFOLIO LAYOUT OVERRIDES */

.portfolio-wrapper {
  margin-top: 2rem;
}

/* Hero Section */
.portfolio-hero {
  margin-bottom: var(--spacing-20);
  border-bottom: 1px solid var(--outline);
  padding-bottom: var(--spacing-10);
}

.portfolio-hero .display-lg {
  margin-left: 0; /* Resetting the global asymmetric margin for this specific page */
  margin-bottom: 2rem;
}

.hero-subtext {
  color: var(--secondary);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.hero-content {
  font-size: 1.25rem;
  line-height: 1.8;
  color: var(--on-background);
  max-width: 650px;
}

.hero-content p {
  margin-bottom: 1.5rem;
}

.hero-content strong {
  color: var(--secondary);
}

/* Style the links in the hero specifically (Resume, Dotfiles, etc.) */
.hero-content a {
  display: inline-block;
  margin-right: 1.5rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--on-background);
  text-decoration: none;
  border-bottom: 1px solid var(--outline-variant);
  transition:
    color 0.3s ease,
    border-color 0.3s ease;
}

.hero-content a:hover {
  color: var(--secondary);
  border-bottom-color: var(--secondary);
}

/* Projects Section - Editorial List */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--on-background);
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
}

.section-header .headline-md {
  margin: 0;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 2rem;
  align-items: start;
  padding: 2rem;
  background: var(--surface-container-low);
  border: 1px solid var(--outline);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
}

.project-row:hover {
  border-color: var(--secondary);
  transform: translateX(4px);
}

.project-meta {
  padding-top: 0.25rem;
}

.project-info h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.project-title {
  text-decoration: none;
  color: var(--on-background);
  transition: color 0.2s ease;
}

.project-row:hover .project-title {
  color: var(--secondary);
}

.project-summary {
  margin: 0;
  font-size: 1rem;
  color: var(--primary);
  line-height: 1.5;
}

/* Small Button Variant for List */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 700px) {
  .project-row {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.5rem;
  }

  .project-meta {
    display: none; /* Hide year on very small screens to save space */
  }

  .project-action {
    margin-top: 1rem;
  }
}
