/* ================================================
   Log — Technical Research Journal
   Light editorial theme with warm amber accents
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f0eeea;
  --bg-raised: #f7f6f3;
  --bg-surface: #e8e6e0;
  --bg-hover: #e0ddd6;
  --text: #2c2824;
  --text-muted: #78726a;
  --text-faint: #a8a29a;
  --accent: #9a6c22;
  --accent-dim: #86601e;
  --accent-glow: rgba(154, 108, 34, 0.07);
  --border: #d6d2ca;
  --border-subtle: #e0ddd6;
  --mono: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
  --sans: 'IBM Plex Sans', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 3px;
}

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 max(2rem, env(safe-area-inset-left));
  padding-right: max(2rem, env(safe-area-inset-right));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
  text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.3;
  color: #1a1816;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.75rem;
  margin-top: 0;
  margin-bottom: 0.5em;
}

h2 {
  font-size: 1.15rem;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--text-muted);
}

h3 {
  font-size: 1.1rem;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

h4 {
  font-size: 1rem;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

p { margin-bottom: 1.2em; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ---- HEADER ---- */
.site-header {
  padding: 2.5rem 0 2rem;
  margin-bottom: 0;
  border-bottom: none;
  position: relative;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.nav-brand a {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  position: relative;
}

.nav-brand a::before {
  content: '>';
  margin-right: 0.4em;
  opacity: 0.5;
}


.nav-menu {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  align-items: center;
}

.nav-menu a {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.nav-menu a:hover {
  color: var(--text);
  background: var(--bg-surface);
}

/* ---- MAIN ---- */
.site-main {
  flex: 1;
  padding-top: 1rem;
}

/* ---- HOME ---- */
.home-hero {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.home-description {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0;
}

/* Section headers */
.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  padding: 2.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Entry list (posts & reviews) */
.entry-list {
  list-style: none;
}

.entry-item {
  display: block;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.entry-item:last-child {
  border-bottom: none;
}

.entry-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  text-decoration: none;
  position: relative;
}

.entry-link:hover .entry-title {
  color: var(--accent);
}

.entry-link:hover .entry-date {
  color: var(--text-muted);
}

.entry-title {
  font-family: var(--sans);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  transition: color 0.2s ease;
  flex: 1;
}

.entry-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.entry-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.entry-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.entry-tag::before {
  content: '#';
  opacity: 0.5;
}

/* Review cards (for reviews page) */
.review-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.review-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
}

.review-card:hover {
  border-color: var(--border);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.review-card-link {
  display: block;
  padding: 1.4rem 1.6rem;
  text-decoration: none;
}

.review-card-link:hover {
  text-decoration: none;
}

.review-card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.review-card-date {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

.review-card-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.review-card-tag {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--accent-dim);
  opacity: 0.7;
}

.review-card-tag::before {
  content: '#';
}

.review-card-title {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  transition: color 0.2s ease;
}

.review-card:hover .review-card-title {
  color: var(--accent);
}

/* ---- POST ---- */
.post {
  max-width: 100%;
  margin: 0;
}

.post-header {
  padding: 2rem 0 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.post-header::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 3rem;
  height: 1px;
  background: var(--accent);
}

.post-header h1 {
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.post-tags {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
}

.tag:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
  text-decoration: none;
}

.post-content {
  line-height: 1.9;
  font-size: 1.02rem;
  color: #302c28;
}

.post-content h2 {
  font-size: 1.2rem;
  color: #1a1816;
  text-transform: none;
  letter-spacing: -0.01em;
  font-weight: 600;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.post-content h3 {
  font-size: 1.05rem;
  margin-top: 2rem;
  color: #3a3632;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(176, 125, 46, 0.35);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}

.post-content a:hover {
  text-decoration-color: var(--accent);
}

.post-content strong {
  color: #1a1816;
  font-weight: 600;
}

.post-content em {
  color: #3a3632;
}

/* Code — inline */
code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  color: #6a3d00;
}

/* Code — block */
pre {
  background: #faf9f6 !important;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  position: relative;
  line-height: 1.7;
}

pre code {
  background: transparent !important;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 0.84rem;
  line-height: 1.7;
}

/* Override Shiki inline styles for consistency */
pre.astro-code {
  background: #faf9f6 !important;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.4rem 1.6rem;
}

pre.astro-code code {
  background: transparent !important;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

thead {
  border-bottom: 2px solid var(--border);
}

th {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.7rem 1rem;
  text-align: left;
}

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}

tr:hover td {
  background: var(--accent-glow);
}

/* Blockquote */
blockquote {
  border-left: 2px solid var(--accent-dim);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Lists in content */
.post-content ul,
.post-content ol {
  margin: 1rem 0 1.5rem 1.25rem;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-content li::marker {
  color: var(--text-faint);
}

/* ---- FOOTER ---- */
.site-footer {
  padding: 3rem 0 2rem;
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ---- KaTeX ---- */
.katex { font-size: 1.05em; }

.katex-display {
  margin: 1.5rem 0;
  padding: 1rem 0;
  overflow-x: auto;
}

/* ---- iOS / touch ---- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Prevent iOS zoom on input focus */
input, select, textarea {
  font-size: 16px;
}

/* Tap targets min 44px for iOS accessibility */
.nav-menu a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Safe area for iPhone home indicator */
.site-footer {
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

/* ---- RESPONSIVE: iPad landscape & small desktop (1024px) ---- */
@media (max-width: 1024px) {
  body {
    max-width: 720px;
  }
}

/* ---- RESPONSIVE: iPad portrait (768px) ---- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  body {
    max-width: 100%;
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
  }

  .home-hero {
    padding: 2.5rem 0 2rem;
  }

  .home-subtitle {
    font-size: 1.35rem;
  }

  .review-card-link {
    padding: 1.2rem 1.4rem;
  }

  th, td {
    padding: 0.6rem 0.75rem;
  }
}

/* ---- RESPONSIVE: iPhone (480px) ---- */
@media (max-width: 480px) {
  html {
    font-size: 15px;
    line-height: 1.7;
  }

  body {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .site-header {
    padding: 1.5rem 0 1rem;
  }

  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .nav-menu {
    gap: 0;
    flex-wrap: wrap;
  }

  .nav-menu a {
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
  }

  .home-hero {
    padding: 1.5rem 0 1.25rem;
  }

  .home-subtitle {
    font-size: 1.2rem;
  }

  .section-label {
    padding: 2rem 0 0.75rem;
  }

  .entry-item {
    padding: 0.9rem 0;
  }

  .entry-link {
    flex-direction: column;
    gap: 0.2rem;
  }

  .entry-title {
    font-size: 1rem;
  }

  .entry-date {
    order: -1;
    font-size: 0.7rem;
  }

  .review-card-link {
    padding: 1rem 1.1rem;
  }

  .review-card-title {
    font-size: 1rem;
  }

  h1 { font-size: 1.4rem; }

  .post-header {
    padding: 1.5rem 0;
  }

  .post-header h1 {
    font-size: 1.3rem;
  }

  .post-content {
    line-height: 1.8;
    font-size: 0.95rem;
  }

  .post-content h2 {
    font-size: 1.1rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
  }

  .post-content h3 {
    font-size: 1rem;
  }

  /* Full-bleed code blocks on mobile */
  pre {
    padding: 1rem;
    margin-left: calc(-1 * max(1rem, env(safe-area-inset-left)));
    margin-right: calc(-1 * max(1rem, env(safe-area-inset-right)));
    border-radius: 0;
    border-left: none;
    border-right: none;
    font-size: 0.78rem;
  }

  /* Scrollable tables on mobile */
  table {
    font-size: 0.78rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  th, td {
    padding: 0.45rem 0.55rem;
  }

  /* KaTeX scroll on mobile */
  .katex-display {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tag {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }

  img {
    margin: 1.5rem -1rem;
    max-width: calc(100% + 2rem);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* Selection */
::selection {
  background: var(--accent);
  color: #fff;
}

/* Smooth fade-in */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.site-main > * {
  animation: fadeUp 0.4s ease-out both;
}
