/*
 * Modern CSS with Native Nesting
 *
 * This stylesheet uses CSS Nesting, a modern CSS feature standardized in 2023-2024.
 * Browser support: Chrome 120+, Firefox 117+, Safari 17.2+, Edge 120+ (92% global coverage)
 *
 * If you need to support older browsers, the SCSS version is available in the git history.
 */

/* Everforest Color Scheme - Dark and Light Modes */

:root {
  /* Light mode colors (Everforest Light) */
  --bg0: #fdf6e3;
  --bg1: #f4f0d9;
  --bg2: #efebd4;
  --bg3: #e6e2cc;
  --bg4: #e0dcc7;
  --bg5: #bdc3af;

  --fg: #5c6a72;
  --red: #f85552;
  --orange: #f57d26;
  --yellow: #dfa000;
  --green: #8da101;
  --aqua: #35a77c;
  --blue: #3a94c5;
  --purple: #df69ba;
  --grey0: #a6b0a0;
  --grey1: #939f91;
  --grey2: #829181;

  --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  /* Dark mode colors (Everforest Dark) */
  --bg0: #2d353b;
  --bg1: #343f44;
  --bg2: #3d484d;
  --bg3: #475258;
  --bg4: #4f585e;
  --bg5: #56635f;

  --fg: #d3c6aa;
  --red: #e67e80;
  --orange: #e69875;
  --yellow: #dbbc7f;
  --green: #a7c080;
  --aqua: #83c092;
  --blue: #7fbbb3;
  --purple: #d699b6;
  --grey0: #7a8478;
  --grey1: #859289;
  --grey2: #9da9a0;

  --shadow: rgba(0, 0, 0, 0.3);
}

/* Reset and base styles - Mobile First */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg0);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Skip to content link for accessibility */
.skip-to-content {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 1rem 1.5rem;
  background-color: var(--green);
  color: var(--bg0);
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;

  &:focus {
    left: 1rem;
    top: 1rem;
  }
}

/* Container and layout - Mobile First */
.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1rem 1rem;

  @media (min-width: 480px) {
    padding: 0 1.5rem 1.5rem;
  }
}

/* Header and navigation - Mobile First */
header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 1rem;

  @media (min-width: 768px) {
    padding-top: 0;
  }
}

/* Main content area - grows to push footer down */
main {
  flex: 1;
}

nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;

  @media (min-width: 768px) {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.site-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;

  &:hover {
    color: var(--green);
  }

  &:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 4px;
    border-radius: 2px;
  }

  @media (min-width: 480px) {
    font-size: 1.5rem;
  }
}

.nav-links {
  display: flex;
  gap: 1rem;
  list-style: none;
  align-items: center;
  flex-wrap: wrap;

  @media (min-width: 480px) {
    gap: 1.25rem;
  }

  @media (min-width: 768px) {
    gap: 1.5rem;
  }
}

.nav-links a {
  color: var(--grey1);
  text-decoration: none;
  font-size: 1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.25rem;

  &:hover {
    color: var(--green);
  }

  &:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 2px;
  }

  &.active {
    color: var(--green);
    font-weight: 500;
  }

  @media (min-width: 480px) {
    font-size: 0.95rem;
  }
}

/* Theme toggle switch - Mobile First with Accessibility */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 44px;
  /* Larger hit area for mobile */
  padding: 8px 2px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;

  /* Focus visible styles for keyboard navigation */
  &:focus-visible + .slider {
    outline: 2px solid var(--green);
    outline-offset: 2px;
  }
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 8px;
  left: 2px;
  right: 2px;
  bottom: 8px;
  background-color: var(--bg3);
  border: 2px solid var(--bg4);
  transition: all 0.3s ease;
  border-radius: 28px;

  &:before {
    position: absolute;
    content: "☀️";
    height: 22px;
    width: 22px;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--yellow);
    transition: all 0.3s ease;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
  }
}

input:checked + .slider {
  background-color: var(--bg4);
  border-color: var(--green);
}

input:checked + .slider:before {
  transform: translateX(22px) translateY(-50%);
  content: "🌙";
  background-color: var(--blue);
}

.slider:hover {
  border-color: var(--green);
}

/* Typography - Mobile First */
h1, h2, h3, h4, h5, h6 {
  color: var(--fg);
  margin: 1.5rem 0 1rem;
  line-height: 1.3;
  font-weight: 600;
}

h1 {
  font-size: 1.75rem;
  margin-top: 0;

  @media (min-width: 480px) {
    font-size: 1.9rem;
  }

  @media (min-width: 768px) {
    font-size: 2rem;
  }
}

h2 {
  font-size: 1.4rem;

  @media (min-width: 480px) {
    font-size: 1.45rem;
  }

  @media (min-width: 768px) {
    font-size: 1.5rem;
  }
}

h3 {
  font-size: 1.2rem;

  @media (min-width: 768px) {
    font-size: 1.25rem;
  }
}

p {
  margin: 1rem 0;
  line-height: 1.7;

  @media (min-width: 480px) {
    line-height: 1.6;
  }
}

/* Links with focus states */
a {
  color: var(--blue);
  text-decoration: none;

  &:hover {
    color: var(--aqua);
    text-decoration: underline;
  }

  &:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 2px;
  }
}

/* Homepage intro */
.intro {
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 2.5rem;

  @media (min-width: 480px) {
    font-size: 1.1rem;
    line-height: 1.7;
  }

  @media (min-width: 768px) {
    margin-bottom: 3rem;
  }
}

/* Blog list - Mobile First */
.blog-list {
  list-style: none;
}

.blog-item {
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--bg2);

  &:last-child {
    border-bottom: none;
  }

  @media (min-width: 480px) {
    margin-bottom: 2.25rem;
    padding-bottom: 2rem;
  }

  @media (min-width: 768px) {
    margin-bottom: 2.5rem;
  }
}

.blog-item h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.blog-item a {
  color: var(--fg);
  text-decoration: none;

  &:hover {
    color: var(--green);
  }

  &:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 2px;
  }
}

.blog-meta {
  color: var(--grey1);
  font-size: 1rem;
  margin-bottom: 0.5rem;

  @media (min-width: 480px) {
    font-size: 0.95rem;
  }

  @media (min-width: 768px) {
    font-size: 0.9rem;
  }
}

.blog-description {
  color: var(--grey2);
  margin-top: 0.5rem;
}

/* Tags - Mobile First with Touch Targets */
.tags {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;

  @media (min-width: 480px) {
    gap: 0.625rem;
  }

  @media (min-width: 768px) {
    gap: 0.5rem;
  }
}

.tag {
  background: var(--bg2);
  color: var(--grey1);
  padding: 0.5rem 0.85rem;
  min-height: 44px;
  border-radius: 4px;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--bg3);
  display: inline-flex;
  align-items: center;
  justify-content: center;

  &:hover {
    background: var(--bg3);
    color: var(--green);
    border-color: var(--green);
    text-decoration: none;
  }

  &:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
  }

  @media (min-width: 480px) {
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
  }

  @media (min-width: 768px) {
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    min-height: auto;
  }
}

/* Tag filter (for blog listing page) */
.tag-filter {
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg1);
  border-radius: 4px;
  border: 1px solid var(--bg3);
}

.tag-filter h3 {
  margin-top: 0;
  font-size: 1.05rem;

  @media (min-width: 768px) {
    font-size: 1rem;
  }
}

/* Code blocks - Mobile First */
pre {
  background: var(--bg1);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--bg3);
  /* Add shadow to indicate scrollability on mobile */
  box-shadow: inset -10px 0 10px -10px var(--shadow);

  @media (min-width: 768px) {
    padding: 1rem 1.25rem;
  }
}

code {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  /* Larger on mobile for readability */
  font-size: 0.95em;

  @media (min-width: 768px) {
    font-size: 0.9em;
  }
}

p code, li code {
  background: var(--bg2);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  color: var(--orange);

  @media (min-width: 768px) {
    padding: 0.15rem 0.4rem;
  }
}

/* Lists */
ul, ol {
  margin: 1rem 0;
  padding-left: 1.75rem;

  @media (min-width: 768px) {
    padding-left: 2rem;
  }
}

li {
  margin: 0.5rem 0;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--green);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--grey2);
  font-style: italic;
}

/* Footer */
footer {
  margin-top: 3rem;
  border-top: 1px solid var(--bg3);
  text-align: center;
  color: var(--grey1);
  font-size: 0.95rem;

  @media (min-width: 480px) {
    margin-top: 3.5rem;
  }

  @media (min-width: 768px) {
    margin-top: 4rem;
    font-size: 0.9rem;
  }
}

/* Experience/Timeline styles - Mobile First */
.experience-item {
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--bg2);

  &:last-child {
    border-bottom: none;
  }

  @media (min-width: 480px) {
    margin-bottom: 2.25rem;
    padding-bottom: 2rem;
  }

  @media (min-width: 768px) {
    margin-bottom: 2.5rem;
  }
}

.experience-header {
  margin-bottom: 0.5rem;
}

.experience-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  margin: 0;

  @media (min-width: 480px) {
    font-size: 1.25rem;
  }
}

.experience-company {
  color: var(--green);
  font-weight: 500;
}

.experience-date {
  color: var(--grey1);
  font-size: 0.95rem;

  @media (min-width: 768px) {
    font-size: 0.9rem;
  }
}

.experience-description {
  margin-top: 0.75rem;
  color: var(--grey2);
}

/* Style markdown-rendered experience content */
/* Reduce spacing between job title and company/date line */
article h2 {
  margin-bottom: 0.25rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--bg3);
}

/* Remove border from first job title */
article h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

/* Target the experience page specifically using article or content wrapper */
article h2 + p strong:first-of-type,
.content h2 + p strong:first-of-type {
  color: var(--green);
  font-weight: 600;
}

/* Make date line (paragraph right after h2) muted grey */
article h2 + p,
.content h2 + p {
  color: var(--grey1);
  font-size: 0.95rem;
  margin-top: 0;

  @media (min-width: 768px) {
    font-size: 0.9rem;
  }
}

/* Things I Like section */
.things-category {
  margin-bottom: 2.5rem;

  @media (min-width: 768px) {
    margin-bottom: 3rem;
  }
}

.things-category h2 {
  color: var(--green);
  border-bottom: 2px solid var(--bg3);
  padding-bottom: 0.5rem;
}

.things-list {
  list-style: none;
  padding-left: 0;
}

.things-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bg2);

  &:last-child {
    border-bottom: none;
  }
}

.thing-title {
  font-weight: 600;
  color: var(--fg);
}

.thing-author {
  color: var(--grey1);
  font-size: 1rem;

  @media (min-width: 768px) {
    font-size: 0.95rem;
  }
}

.thing-note {
  color: var(--grey2);
  font-size: 0.95rem;
  margin-top: 0.25rem;

  @media (min-width: 768px) {
    font-size: 0.9rem;
  }
}
