/* ============================================
   KSK — Automation Engineer Portfolio
   Token system
   ============================================ */
:root {
  --bg: #09090B;
  --card: #111216;
  --card-2: #15161B;
  --border: rgba(245, 245, 247, 0.08);
  --border-strong: rgba(245, 245, 247, 0.14);
  --accent: #00D4FF;
  --accent-dim: rgba(0, 212, 255, 0.14);
  --success: #00FF88;
  --text: #F5F5F7;
  --text-dim: rgba(245, 245, 247, 0.62);
  --text-faint: rgba(245, 245, 247, 0.38);

  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --container: 1160px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img, video { max-width: 100%; display: block; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
}

/* subtle grain overlay for premium texture */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.025; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cursor-glow {
  position: fixed; top: 0; left: 0; width: 480px; height: 480px;
  border-radius: 50%; pointer-events: none; z-index: 1;
  background: radial-gradient(circle, rgba(0,212,255,0.06) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease;
  opacity: 0;
}

/* ============================================
   Nav
   ============================================ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 20px 0;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), padding 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
}
.nav-dot { color: var(--accent); }
.nav-links { display: flex; gap: 30px; }
.nav-links a {
  font-size: 14px; color: var(--text-dim);
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--text); }
.nav-cta {
  font-size: 13px; font-weight: 600;
  padding: 9px 18px; border-radius: 100px;
  border: 1px solid var(--border-strong);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.nav-cta:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ============================================
   Hero
   ============================================ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 140px 0 60px;
  overflow: hidden;
}

.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(245,245,247,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,245,247,0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black 20%, transparent 75%);
  animation: gridDrift 40s linear infinite;
}
@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 96px, 48px 96px; }
}

.hero-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 60px;
  align-items: center;
  position: relative; z-index: 2;
  width: 100%;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px; letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 24px;
}
.eyebrow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(40px, 5.4vw, 68px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 22px;
}
.hero-title-accent {
  background: linear-gradient(90deg, var(--accent), #7CE8FF);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 40px;
  letter-spacing: 0.01em;
}

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 24px;
  border-radius: 100px;
  font-size: 14.5px; font-weight: 600;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.btn-primary {
  background: var(--text);
  color: #000;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(245,245,247,0.15); }
.btn-ghost {
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px); }

/* Glass card */
.glass-card {
  background: rgba(17, 18, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), inset 0 1px 0 rgba(245,245,247,0.04);
}

.status-card {
  padding: 28px 28px 20px;
}
.status-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.status-card-title {
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.1em;
  color: var(--text-dim);
}
.status-card-live {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  color: var(--success);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.status-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong) 20%, var(--border-strong) 80%, transparent);
  margin: 12px 0;
}
.status-list { display: flex; flex-direction: column; gap: 11px; margin-bottom: 4px; }
.status-list li {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}
.status-list li span { color: var(--text-dim); }
.status-list li b {
  font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 100px;
}
.status-list li b.ok {
  color: var(--success);
  background: rgba(0,255,136,0.1);
}

.terminal { margin-top: 4px; }
.terminal-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
}
.term-dot { width: 8px; height: 8px; border-radius: 50%; opacity: 0.6; }
.term-red { background: #FF5F56; }
.term-yellow { background: #FFBD2E; }
.term-green { background: #27C93F; }
.terminal-label {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  margin-left: 6px;
}
.terminal-body {
  font-family: var(--font-mono);
  font-size: 12px;
  height: 118px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, transparent, black 12%, black 100%);
}
.terminal-line {
  display: flex; gap: 10px;
  padding: 3px 0;
  color: var(--text-dim);
  white-space: nowrap;
  animation: lineIn 0.4s var(--ease);
}
.terminal-line .t-time { color: var(--text-faint); flex-shrink: 0; }
.terminal-line .t-ok { color: var(--success); }
.terminal-line .t-arrow { color: var(--text-faint); }
@keyframes lineIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.scroll-cue {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  color: var(--text-faint);
  z-index: 2;
}
.scroll-cue span {
  width: 1px; height: 26px;
  background: linear-gradient(var(--accent), transparent);
  animation: scrollLine 1.8s ease-in-out infinite;
}
@keyframes scrollLine {
  0% { transform: scaleY(0); transform-origin: top; opacity: 1; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; opacity: 0.4; }
}

/* ============================================
   Sections generic
   ============================================ */
.section { padding: 130px 0; position: relative; }
.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 12.5px; letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 42px);
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in-view { opacity: 1; transform: translateY(0); }
.reveal-delay-1.in-view { transition-delay: 0.12s; }
.reveal-delay-2.in-view { transition-delay: 0.24s; }

/* ============================================
   About
   ============================================ */
.about-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 70px;
  align-items: center;
}
.photo-frame {
  aspect-ratio: 4/5;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--card), var(--card-2));
  display: flex; align-items: center; justify-content: center;
}
.photo-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-faint);
  font-size: 13px;
  font-family: var(--font-mono);
}
.about-text {
  font-size: 18px; line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 28px;
  max-width: 52ch;
}
.about-text b { color: var(--text); font-weight: 600; }
.tag-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  color: var(--text-dim);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================
   Featured project
   ============================================ */
.section-feature { background: linear-gradient(180deg, transparent, rgba(0,212,255,0.02), transparent); }
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  margin-top: 44px;
}
.feature-desc {
  font-size: 17px; line-height: 1.75;
  color: var(--text-dim);
  margin-bottom: 30px;
  max-width: 54ch;
}
.mini-flow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 34px;
}
.mini-flow span {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.mini-flow i { color: var(--accent); font-style: normal; }

.media-card {
  aspect-ratio: 16/10;
  overflow: hidden;
  position: relative;
  padding: 0;
}
.media-card video { width: 100%; height: 100%; object-fit: cover; }
.media-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-faint);
  font-family: var(--font-mono); font-size: 12.5px;
  background: linear-gradient(160deg, var(--card), var(--card-2));
}

/* ============================================
   Architecture
   ============================================ */
.arch-wrap {
  margin-top: 50px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  overflow-x: auto;
}
.arch-svg { width: 100%; min-width: 900px; height: auto; display: block; }
.arch-node rect {
  fill: var(--card-2);
  stroke: var(--border-strong);
  stroke-width: 1.5;
  transition: stroke 0.3s ease, filter 0.3s ease;
}
.arch-node.lit rect {
  stroke: var(--accent);
  filter: drop-shadow(0 0 12px rgba(0,212,255,0.45));
}
.arch-node-title {
  fill: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
}
.arch-node-sub {
  fill: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}
.arch-dot {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent));
}

/* ============================================
   Tech stack
   ============================================ */
.stack-grid {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.stack-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.25s ease, transform 0.25s var(--ease), box-shadow 0.25s ease;
}
.stack-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,212,255,0.08);
}
.stack-name { font-weight: 600; font-size: 15px; }
.stack-role { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }

/* ============================================
   Workflow
   ============================================ */
.workflow-line {
  margin-top: 54px;
  display: flex;
  align-items: flex-start;
  position: relative;
}
.workflow-line::before {
  content: '';
  position: absolute;
  top: 6px; left: 0; right: 0;
  height: 1px;
  background: var(--border-strong);
}
.wf-step {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px;
  position: relative;
  text-align: center;
}
.wf-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
  transition: box-shadow 0.3s ease;
}
.wf-step:hover .wf-dot { box-shadow: 0 0 14px rgba(0,212,255,0.6); }
.wf-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ============================================
   Gallery
   ============================================ */
.gallery-grid {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.gallery-card {
  aspect-ratio: 9/16;
  overflow: hidden;
  position: relative;
  padding: 0;
}
.gallery-card video { width: 100%; height: 100%; object-fit: cover; }
.gallery-caption {
  position: absolute; bottom: 14px; left: 14px;
  font-family: var(--font-mono); font-size: 12px;
  padding: 6px 12px;
  background: rgba(9,9,11,0.6);
  backdrop-filter: blur(8px);
  border-radius: 100px;
  border: 1px solid var(--border);
}

/* ============================================
   Contact
   ============================================ */
.section-contact { text-align: center; padding-bottom: 100px; }
.contact-inner { display: flex; flex-direction: column; align-items: center; }
.contact-sub { color: var(--text-dim); font-size: 16px; margin-bottom: 40px; }
.contact-links { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.contact-link {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 24px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-size: 14.5px; font-weight: 500;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s var(--ease);
}
.contact-link:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px); }

/* ============================================
   Footer
   ============================================ */
.footer { border-top: 1px solid var(--border); padding: 28px 0; }
.footer-inner {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-faint);
}

/* Back to top */
.to-top {
  position: fixed; right: 26px; bottom: 26px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s ease;
}
.to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.to-top:hover { border-color: var(--accent); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .hero-inner { grid-template-columns: 1fr; gap: 50px; }
  .hero { padding-top: 120px; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .photo-frame { max-width: 280px; margin: 0 auto; }
  .feature-grid { grid-template-columns: 1fr; gap: 40px; }
  .stack-grid { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .workflow-line { flex-wrap: wrap; gap: 30px 0; }
  .workflow-line::before { display: none; }
  .wf-step { flex: 1 1 25%; min-width: 90px; }
}

@media (max-width: 640px) {
  .container { padding: 0 22px; }
  .hero-inner { padding: 0 22px; }
  .section { padding: 90px 0; }
  .stack-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: 1fr; }
  .gallery-card { aspect-ratio: 16/10; }
  .hero-actions .btn { flex: 1; justify-content: center; }
  .contact-links { flex-direction: column; width: 100%; }
  .contact-link { justify-content: center; }
  .wf-step { flex: 1 1 40%; }
  .footer-inner { flex-direction: column; gap: 6px; text-align: center; }
}
/* Mobile trade execution video */
.gallery-card {
  aspect-ratio: 16/10;
  overflow: hidden;
  position: relative;
  padding: 0;
  background: #000;
}

.gallery-card video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.project-preview {
  height: 320px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080808;
}

.project-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* ============================================
   Other Projects Layout Fix
   ============================================ */
   .projects-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: 100%;
  }
  
  .project-card {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr; /* 텍스트와 이미지 영역 비율 */
    width: 100%;
    overflow: hidden; /* 내부 요소가 카드를 탈출하는 것 차단 */
  }
  
  .project-live-body {
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  
  /* 태블릿 및 모바일 반응형 (화면 좁아질 때 세로 배치) */
  @media (max-width: 980px) {
    .project-card {
      grid-template-columns: 1fr;
    }
    .project-live-body {
      padding: 30px 24px;
    }
  }