/* ==========================================================================
   Main CSS File - ilias.pm
   ========================================================================== */

/* Variables
   ========================================================================== */
:root {
  /* Colors - Base */
  --color-bg: #d4e8e4;
  --color-bg-inverted: #1a1a1a;
  --color-text: #16302b;
  --color-text-inverted: #e0e0e0;
  --color-text-transparent: hsla(168, 37%, 14%, 0.4);
  --color-link-primary: #4C5CE5;
  --color-link-secondary: #BA2D0B;
  --color-card-bg: #ffffff30;
  --color-card-border: #00000018;

  /* Typography */
  --font-primary: 'Geist Mono', monospace;
  --font-secondary: 'EB Garamond', serif;
  --font-size-xs: 14px;
  --font-size-sm: 16px;
  --font-size-md: 18px;
  --font-size-lg: 20px;
  --font-size-xl: 26px;
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 600;

  /* Layout */
  --container-width: 640px;
  --container-width-wide: 1100px;
  --section-spacing: 5%;
}

/* Dark Mode
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a1a;
    --color-bg-inverted: #d4e8e4;
    --color-text: #e0e0e0;
    --color-text-inverted: #16302b;
    --color-text-transparent: hsla(0, 0%, 88%, 0.4);
    --color-link-primary: #8ab4f8;
    --color-link-secondary: #ff8e71;
    --color-card-bg: #00000030;
    --color-card-border: #ffffff18;
  }
}

/* Base Styles
   ========================================================================== */
body {
  margin: 0 auto;
  padding: var(--section-spacing);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
  position: relative;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Special handling for wide pages */
body.work-page,
body.about-page {
  max-width: var(--container-width-wide);
}

::selection {
  background: var(--color-bg-inverted);
  color: var(--color-text-inverted);
}

/* Typography
   ========================================================================== */
h1, h2, h3, h4, p, small {
  margin: 0 0 1rem;
  font-weight: var(--font-weight-regular);
}

h1 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  cursor: grab;
}

h2 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin-top: var(--section-spacing);
}

section.contact {
  margin-top: 3rem;
}

section.contact > h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
}

h4 {
  font-family: var(--font-secondary);
  font-style: italic;
  font-size: var(--font-size-md);
}

p {
  font-size: var(--font-size-sm);
}

small {
  font-size: var(--font-size-xs);
}

.medium {
  font-weight: var(--font-weight-bold);
}

/* Links
   ========================================================================== */
a {
  color: var(--color-link-primary);
  text-decoration: none;
  font-weight: var(--font-weight-regular);
}

a:hover {
  text-decoration: underline;
}

.company-link:hover {
  font-style: italic;
  transition: 50ms;
  cursor: crosshair;
}

.book-link {
  color: var(--color-link-secondary);
}

.reading-status {
  font-weight: var(--font-weight-medium);
}

.reading-status a.book-link {
  font-weight: var(--font-weight-medium);
}

/* Navigation
   ========================================================================== */
.top-nav {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2rem;
  transition: all 0.3s ease;
}

.nav-link {
  color: var(--color-text-transparent);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-light);
  transition: color 0.2s ease;
}

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

/* Corner Elements
   ========================================================================== */
.corner-element {
  position: fixed;
  padding: 1rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-transparent);
  font-weight: var(--font-weight-light);
  z-index: 100;
}

.top-left { top: 0; left: 0; }
.top-right { top: 0; right: 0; }
.bottom-left { bottom: 0; left: 0; }
.bottom-right { bottom: 0; right: 0; }

.corner-name {
  font-size: var(--font-size-xs);
  margin: 0;
}

.home-link {
  color: var(--color-text-transparent);
  transition: color 0.2s ease;
}

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

#current-time {
  font-family: var(--font-primary);
  letter-spacing: -0.02em;
}

/* Layout Components
   ========================================================================== */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding-top: var(--section-spacing);
  padding-bottom: var(--section-spacing);
}

.container-wide {
  max-width: var(--container-width-wide);
}

/* Hero Section */
.hero-section {
  text-align: center;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  margin: 0 auto;
  padding: 0;
}

.hero-section h1 {
  font-size: calc(var(--font-size-xl) * 3);
  line-height: 1.2;
  margin: 0;
  width: 100%;
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.hero-description {
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--color-text);
  width: 85%;
  max-width: var(--container-width);
  margin: 0 auto;
  position: absolute;
  bottom: calc(var(--section-spacing) * 4);
  left: 50%;
  transform: translateX(-50%);
  font-weight: var(--font-weight-regular);
}

/* Special handling for wide pages */
.work-page .container,
.about-page .container {
  max-width: var(--container-width-wide);
}

/* Content Components
   ========================================================================== */
.card-base {
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: 4px;
  transition: border-color 0.4s ease;
}

.card-base:hover {
  border-color: var(--color-text-transparent);
}

/* Flex Layouts */
.flex-container {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* About Page */
.about-content {
  display: flex;
  gap: 6rem;
  align-items: flex-start;
}

.about-text {
  flex: 0 1 var(--container-width);
}

.about-text h1 {
  margin-top: 0;
}

.about-image {
  flex: 0 1 20%;
  margin-top: 4rem;
  max-width: 20%;
}

.about-image img {
  width: 100%;
  height: auto;
  border-radius: 7px;
  mix-blend-mode: multiply;
}

.site-metadata pre {
  font-family: var(--font-primary);
  font-size: var(--font-size-xs);
  line-height: 1.6;
  background: var(--color-card-bg);
  padding: 1.5rem;
  border-radius: 4px;
  border: 1px solid var(--color-card-border);
  overflow-x: auto;
}

/* Syntax Highlighting for Site Metadata */
.site-metadata .key {
  color: #5f8787;
  font-weight: var(--font-weight-medium);
}

.site-metadata .value {
  color: #99bbaa;
}

.site-metadata .bracket {
  color: #888888;
  font-weight: var(--font-weight-regular);
}

.site-metadata .comment {
  color: #999999;
  font-style: italic;
}

/* Work Experience */
.work-experience {
  margin-bottom: 4rem;
}

.work-experience-content {
  display: flex;
  gap: 4rem;
  align-items: flex-start;
  margin: 0 auto;
}

.work-experience:nth-child(even) .work-experience-content {
  flex-direction: row-reverse;
}

.work-experience-description {
  flex: 0 1 var(--container-width);
}

.work-experience-description h2 {
  color: var(--color-text);
  font-size: var(--font-size-lg);
  margin-top: 0;
}

.work-experience-image {
  flex: 0 1 512px;
}

.work-experience-image img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  transition: transform 0.3s ease;
  margin-bottom: 0.5rem;
}

.work-experience-image .image-copyright {
  font-size: var(--font-size-xs);
  color: var(--color-text-transparent);
  text-align: right;
  margin-top: 0.25rem;
}

.work-experience-image:hover img {
  transform: scale(1.02);
}

/* Mobile Responsive
   ========================================================================== */
.mobile-header,
.mobile-footer {
  display: none;
}

@media screen and (max-width: 1200px) {
  /* Layout */
  body.work-page,
  body.about-page {
    max-width: 100%;
    padding: var(--section-spacing);
  }

  .work-experience-content,
  .about-content {
    gap: 2rem;
  }

  .work-experience-description,
  .work-experience-image,
  .about-text,
  .about-image {
    flex: 1;
  }
}

@media screen and (max-width: 768px) {
  /* Typography */
  body {
    font-size: var(--font-size-xs);
    padding-top: calc(var(--section-spacing) * 2);
    padding-bottom: var(--section-spacing);
  }

  p, footer {
    font-size: var(--font-size-xs);
  }

  /* Layout */
  .container {
    padding-bottom: calc(var(--section-spacing) * 2);
    margin-bottom: var(--section-spacing);
  }

  /* Hero adjustments */
  .hero-section {
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
  }

  .hero-section h1 {
    position: relative;
    top: auto;
    left: auto;
    transform: translateY(-25%);
    font-size: calc(var(--font-size-xl) * 1.5);
    margin: 0;
    padding: 0 1rem;
    width: 100%;
  }

  .hero-description {
    position: relative;
    bottom: auto;
    left: auto;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
    animation-delay: 0.8s;
    width: 90%;
    font-size: calc(var(--font-size-xs) - 1px);
    line-height: 1.6;
    margin: 0;
    padding: 0 1rem;
    transform: translateY(50%);
  }

  /* Page headers */
  main > section > h1,
  main > article header h1,
  main > .intro h1 {
    margin-top: 3rem;
  }

  /* Hide desktop elements */
  .corner-element,
  .corner-element.top-nav {
    display: none;
  }

  /* Work page */
  .work-experience-content {
    flex-direction: column !important;
    gap: 1.5rem;
    margin: 0;
  }

  .work-experience-description,
  .work-experience-image {
    max-width: 100%;
  }

  /* About page */
  .about-content {
    flex-direction: column;
    margin-top: 3rem;
  }

  .about-text {
    order: 2;
  }

  .about-image {
    order: 1;
    position: relative;
    top: 0;
    max-width: 120px;
    margin: 0;
    margin-right: auto;
  }

  /* Site metadata and contact */
  .site-metadata pre {
    font-size: calc(var(--font-size-xs) - 1px);
    padding: 1rem;
  }
  
  .site-metadata,
  .contact-info {
    margin: 3rem 0;
  }

  /* Contact section */
  .contact-description {
    font-size: calc(var(--font-size-xs) - 1px);
  }

  /* Mobile header */
  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: var(--color-bg);
    z-index: 1;
  }

  .mobile-header .top-nav {
    position: static;
    transform: none;
    display: flex;
    padding: 0;
  }

  /* Mobile footer */
  .mobile-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--color-text-transparent);
  }

  /* Reading table adjustments */
  .reading-table {
    font-size: calc(var(--font-size-xs) - 1px);
  }
  
  .reading-table th,
  .reading-table td {
    padding: 0.5rem 0.25rem;
  }

  .reading-table th:nth-child(3),
  .reading-table td:nth-child(3),
  .reading-table th:nth-child(4),
  .reading-table td:nth-child(4) {
    display: none;
  }

  /* Layout */
  header {
    margin-top: 2rem;
  }
}

/* Dark mode overrides for specific components
   ========================================================================== */
@media (prefers-color-scheme: dark) {

  .about-image img {
    mix-blend-mode: lighten;
  }

  .site-metadata .key {
    color: #ddeecc;
  }

  .site-metadata .value {
    color: #99bbaa;
  }

  .site-metadata .bracket {
    color: #aaaaaa;
  }

  .site-metadata .comment {
    color: #999999;
  }
}

/* Contact Section */
.contact-section {
  text-align: center;
  max-width: var(--container-width);
  margin: 6rem auto 0rem;
  padding: 0 1rem;
}

.contact-description {
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  line-height: 1.;
  color: var(--color-text);
  margin-bottom: 2rem;
  font-weight: var(--font-weight-regular);
}

@media screen and (max-width: 768px) {
  .contact-section {
    margin: 4rem auto 2rem;
  }
  
  .contact-description {
    font-size: calc(var(--font-size-xs) - 1px);
  }
}

/* Articles and Work Experience */
article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 4px;
}


/* Blockquotes and Notes */
article blockquote {
  margin: 1rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 2px solid var(--color-text-transparent);
  background: transparent;
}

article blockquote p {
  margin: 0;
}

article blockquote strong {
  font-weight: var(--font-weight-medium);
}


/* Reading Table
   ========================================================================== */
.reading-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-xs);
  margin-top: 2rem;
}

.reading-table th {
  text-align: left;
  padding: 0.5rem;
  color: var(--color-text-transparent);
  font-weight: var(--font-weight-regular);
}

.reading-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-card-border);
}

.reading-table tbody tr.current-book td {
  font-weight: var(--font-weight-medium);
}

.reading-table th:last-child,
.reading-table td:last-child {
  text-align: center;
}

.reading-table th.reading-group {
  padding-top: 3rem;
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  text-align: left;
  border-bottom: 1px solid var(--color-text-transparent);
}

.reading-table tbody:first-of-type th.reading-group {
  padding-top: 1.5rem;
}

.reading-table .clickable {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.reading-table .clickable:hover {
  background: var(--color-card-bg);
}

.reading-table .clickable:active {
  background: var(--color-card-border);
}

/* Animations
   ========================================================================== */
.animate-on-load {
  transition: opacity 0.2s ease-in-out;
  opacity: 0;
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(70%);
  }
  100% {
    opacity: 1;
    transform: translateY(50%);
  }
}

/* Reading Status Indicator */
.reading-indicator {
  display: inline-block;
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  line-height: 1;
}

/* Creative — Cohesive Article Cards */
.recent-writings {
  display: grid;
  gap: 1.25rem;
}

.article-card {
  padding: 1rem 1rem 0.7rem;
  transition: border-color 400ms, transform 150ms ease;
  margin-bottom: 0;
}

.article-card:hover,
.article-card:focus-within {
  transform: translateY(-1px);
}

.article-card a {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem 0.75rem;
  align-items: start;
  color: var(--color-text);
  text-decoration: none;
}

/* Unify heading typography with site */
.article-card h3,
.recent-writings h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  margin-bottom: 2px;
  font-style: normal;
  font-family: var(--font-primary);
}

/* Keep descriptions in serif for tone */
.recent-writings .article-card p {
  font-size: var(--font-size-md);
  font-family: var(--font-secondary);
  margin-bottom: 6px;
  color: var(--color-text);
}

/* Meta line — align with nav style */
.recent-writings small {
  display: block;
  text-align: left;
  color: var(--color-text-transparent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Grid placement for contents */
.article-card h3,
.article-card p,
.article-card small {
  grid-column: 1 / 2;
}

/* Enhanced interactions */
.email-button a {
  transition: letter-spacing 0.2s ease;
}

.email-button a:hover {
  letter-spacing: 0.05em;
  text-decoration: none;
}
