/* === Taigo Sakai Portfolio - Unified Design System === */

:root {
  /* Core Colors */
  --bg: #020408;
  --surface: #0d1117;
  --surface-2: #161b22;
  --surface-3: #21262d;
  --text-main: #f0f6fc;
  --text-sub: #8b949e;
  --muted: #6e7681;
  --accent: #2f81f7;
  --accent-2: #58a6ff;
  --accent-warm: #f78166;
  --stroke: #30363d;
  --stroke-subtle: #161b22;
  --glow: rgba(47, 129, 247, 0.25);
  
  /* Glass & Effects */
  --bg-glass: rgba(2, 4, 8, 0.75);
  --bg-glass-strong: rgba(2, 4, 8, 0.95);
  
  /* Non-Uniform Border Radius (Premium Anti-AI) */
  --radius-sm: 4px;
  --radius-md: 12px 2px 12px 2px;
  --radius-lg: 24px 4px;
  
  /* Motion & Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: -4px 6px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: -8px 12px 32px rgba(0, 0, 0, 0.4);
  --ease-organic: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);

  --header-gradient: var(--surface);
}

[data-theme="light"] {
  --bg: #fdfbf7;
  --surface: #f4f2ed;
  --surface-2: #e9e7e3;
  --surface-3: #e9e7e3;
  --text-main: #1f2328;
  --text-sub: #57606a;
  --muted: #656d76;
  --accent: #1a7f37;
  --accent-2: #0969da;
  --accent-warm: #cf222e;
  --stroke: #d8d4cd;
  --stroke-subtle: #e1ddd7;
  --bg-glass: rgba(253, 251, 247, 0.75);
  --bg-glass-strong: rgba(253, 251, 247, 0.95);
  --header-gradient: linear-gradient(to bottom, rgba(245, 222, 179, 0.15), transparent 80%),
                     var(--surface);
}

/* === Reset & Base === */
* { box-sizing: border-box; }
body {
  font-family: "Space Grotesk", "Inter", "Noto Sans JP", system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 30% 20%, rgba(31, 111, 235, 0.05), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(47, 129, 247, 0.03), transparent 25%);
  color: var(--text-main);
  line-height: 1.6;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a { text-decoration: none; color: var(--accent-2); transition: 0.2s; }
a:hover { text-decoration: underline; color: var(--accent); }

/* === Layout === */
.page { max-width: 1280px; margin: 0 auto; padding: 24px; }
.container-lg { display: grid; grid-template-columns: 296px 1fr; gap: 32px; margin-top: 32px; }

@media (max-width: 768px) {
  .container-lg { grid-template-columns: 1fr; margin-top: 16px; }
  .page { padding: 16px; }
  .profile-sidebar { position: static !important; order: 1; }
  .header-bar { margin: -16px -16px 24px -16px !important; padding: 16px !important; }
}

/* === Header === */
.header-bar {
  background: var(--header-gradient);
  border-bottom: 1px solid var(--stroke);
  padding: 20px 24px;
  margin: -24px -24px 24px -24px;
  position: sticky;
  top: 0;
  z-index: 1100;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  transition: all 0.4s var(--ease-organic);
}

.header-bar.scrolled {
  padding-top: 10px; padding-bottom: 10px;
  background: var(--bg-glass-strong);
  box-shadow: var(--shadow-lg);
}

.header-inner {
  display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1;
}

.header-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

.header-profile { display: flex; gap: 20px; align-items: center; }

.header-identity { display: flex; flex-direction: column; gap: 4px; }

.header-name {
  font-size: 28px; font-weight: 700; margin: 0;
  background: linear-gradient(to bottom right, #fff, var(--text-sub));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .header-name { background: linear-gradient(to bottom right, #1f2328, #57606a); -webkit-background-clip: text; }

.header-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.header-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.header-badge {
  font-size: 10px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--stroke); color: var(--text-sub);
  background: var(--bg-glass); letter-spacing: 0.3px;
}

.header-stats {
  display: flex; gap: 0; align-items: center; margin: 0 auto;
  padding: 6px 16px; background: var(--surface-2);
  border: 1px solid var(--stroke); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.stat-item { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text-main); font-family: "Space Grotesk", sans-serif; }
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.header-btn {
  background: var(--surface-2); border: 1px solid var(--stroke);
  color: var(--text-sub); padding: 6px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.header-btn:hover { border-color: var(--accent-2); color: var(--text-main); background: var(--surface-3); }
.header-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-2); }

.header-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.header-nav { display: flex; gap: 12px; }
.nav-btn {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 4px 0; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: 0.2s;
}
.nav-btn:hover { color: var(--text-main); border-bottom-color: var(--accent-warm); }
.header-hint { font-size: 11px; color: var(--muted); }

/* === Sidebar === */
.profile-sidebar { position: sticky; top: calc(var(--header-height, 80px) + 24px); height: fit-content; }
.profile-card {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-md);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden; cursor: grab;
}
.profile-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(to right, var(--accent), var(--accent-2));
}
.profile-name { font-size: 22px; font-weight: 700; color: var(--text-main); margin-top: 8px; }
.profile-username { font-size: 18px; color: var(--muted); margin-bottom: 12px; }
.profile-bio { font-size: 14px; color: var(--text-sub); line-height: 1.5; margin-bottom: 16px; }
.profile-links { display: flex; flex-direction: column; gap: 8px; }
.profile-links a { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-sub); }
.profile-links a:hover { color: var(--accent-2); }
.profile-link-row { display: flex; align-items: center; gap: 8px; }
.profile-link-row a { flex: 1; }

.copy-btn {
  border: 1px solid var(--stroke); background: var(--surface-3);
  color: var(--text-sub); font-size: 11px; padding: 4px 8px;
  border-radius: 6px; cursor: pointer; white-space: nowrap; transition: 0.2s;
}
.copy-btn:hover { border-color: var(--accent-2); color: var(--text-main); }
.copy-btn.success { border-color: var(--accent); color: var(--text-main); }

/* === Sections & Cards === */
.section-card {
  background: var(--section-bg, var(--surface));
  border: 1px solid var(--section-border, var(--stroke));
  border-radius: var(--radius-md);
  padding: 24px; margin-bottom: 24px;
  transition: all 0.4s var(--ease-organic);
  box-shadow: var(--shadow-sm);
}
.section-card:hover { transform: rotate(-0.5deg) scale(1.005); box-shadow: var(--shadow-md); }

/* Color Mix Variations */
.tab-content .section-card:nth-of-type(3n+1) {
  --section-accent: var(--accent);
  --section-border: color-mix(in srgb, var(--accent), var(--stroke) 80%);
  --section-bg: color-mix(in srgb, var(--accent), var(--bg) 97%);
}
.tab-content .section-card:nth-of-type(3n+2) {
  --section-accent: var(--accent-2);
  --section-border: color-mix(in srgb, var(--accent-2), var(--stroke) 80%);
  --section-bg: color-mix(in srgb, var(--accent-2), var(--bg) 97%);
}
.tab-content .section-card:nth-of-type(3n+3) {
  --section-accent: var(--accent-warm);
  --section-border: color-mix(in srgb, var(--accent-warm), var(--stroke) 80%);
  --section-bg: color-mix(in srgb, var(--accent-warm), var(--bg) 97%);
}

.section-title {
  font-size: 18px; font-weight: 700; color: var(--text-main); margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--section-border, var(--stroke)); padding-bottom: 8px;
}
.section-title::before {
  content: ""; display: block; width: 4px; height: 1.2em;
  background-color: var(--section-accent, var(--accent)); border-radius: 2px;
}
.subsection-title { font-size: 15px; font-weight: 600; color: var(--accent-2); margin: 20px 0 10px; }

/* === Lists & Chips === */
.repo-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.repo-list li {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-sm);
  padding: 12px 16px; transition: 0.3s var(--ease-organic);
}
.repo-list li:hover { border-color: var(--section-accent, var(--accent)); transform: translateX(8px); background: var(--surface-2); }

.badge-year {
  display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 700;
  border-radius: 12px; background: #238636; color: #fff; margin-right: 8px;
}

/* === Tab Navigation === */
.tab-nav {
  display: flex; gap: 8px; border-bottom: 1px solid var(--stroke-subtle);
  margin-bottom: 24px; position: sticky; top: var(--header-height, 80px);
  background: var(--bg-glass-strong); backdrop-filter: blur(12px); z-index: 1000; padding: 12px 0;
}
.tab-item { padding: 10px 16px; color: var(--muted); font-weight: 600; cursor: pointer; border-radius: 6px; transition: 0.2s; }
.tab-item:hover { color: var(--text-main); background: var(--surface-2); }
.tab-item.active { color: var(--text-main); background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--accent-warm); }

/* === App Grid === */
.grid-dense { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.app-card {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-md);
  padding: 16px; display: flex; gap: 16px; transition: all 0.3s var(--ease-organic);
  position: relative; overflow: hidden; cursor: pointer;
}
.app-card:hover { border-color: var(--accent-2); transform: translateY(-4px); box-shadow: var(--shadow-md); background: var(--surface-2); }
.app-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--stroke); flex-shrink: 0; }
.app-info { flex: 1; min-width: 0; }
.app-title { font-weight: 700; color: var(--accent-2); font-size: 15px; margin-bottom: 4px; display: block; }
.app-desc { font-size: 12px; color: var(--text-sub); line-height: 1.5; margin-bottom: 8px; }
.app-links { display: flex; gap: 8px; flex-wrap: wrap; }
.app-links a { font-size: 11px; border: 1px solid var(--stroke); padding: 2px 8px; border-radius: 4px; color: var(--muted); }
.app-links a:hover { color: var(--text-main); border-color: var(--text-sub); text-decoration: none; }

/* === Utility Bar === */
.utility-bar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.search-input { background: transparent; border: none; border-bottom: 1px solid var(--stroke); color: var(--text-main); padding: 8px 0; flex: 1; outline: none; font-size: 14px; }
.search-input:focus { border-bottom-color: var(--accent); }
.chip { background: var(--surface-3); border: 1px solid var(--stroke); color: var(--text-sub); padding: 4px 12px; border-radius: 999px; font-size: 12px; cursor: pointer; transition: 0.2s; }
.chip:hover { border-color: var(--accent-2); color: var(--text-main); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent-2); }

/* === Multi-language Visibility === */
[lang="en"] { display: none !important; }
html[data-lang="en"] [lang="en"] { display: block !important; }
html[data-lang="en"] [lang="ja"] { display: none !important; }

/* === Modal, TOC, FAB, etc. === */
#toc-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; z-index: 1500; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); transition: 0.3s; cursor: pointer; }
#toc-menu { position: fixed; bottom: 90px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 1400; opacity: 0; visibility: hidden; transition: 0.3s; }
#toc-menu.show { opacity: 1; visibility: visible; }
.toc-link { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: 1px solid var(--stroke); display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 20px; box-shadow: var(--shadow-sm); cursor: pointer; position: relative; }
.toc-link::after { content: attr(data-title); position: absolute; right: 140%; top: 50%; transform: translateY(-50%) scale(0.9); background: var(--surface-3); color: var(--text-main); padding: 6px 12px; border-radius: 6px; font-size: 12px; white-space: nowrap; opacity: 0; visibility: hidden; transition: 0.2s; border: 1px solid var(--stroke); }
.toc-link:hover::after { opacity: 1; visibility: visible; transform: translateY(-50%) scale(1); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 3000; opacity: 0; visibility: hidden; transition: 0.3s; }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-container { background: var(--bg); border: 1px solid var(--stroke); border-radius: 12px; width: 90%; max-width: 600px; padding: 24px; transform: scale(0.9); transition: 0.4s var(--ease-out-expo); box-shadow: var(--shadow-lg); position: relative; }
.modal-overlay.open .modal-container { transform: scale(1); }
.modal-close { position: absolute; top: 16px; right: 16px; background: var(--surface-3); border: none; color: var(--text-main); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 20px; }

/* === Animations === */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.reveal-item { opacity: 0; transform: translateY(20px); transition: all 0.6s var(--ease-organic); }
.reveal-active { opacity: 1; transform: translateY(0); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Hide loading screen */
#loading-screen { position: fixed; inset: 0; background: var(--bg); z-index: 9999; display: flex; align-items: center; justify-content: center; transition: 0.5s; }
#loading-screen.hidden { opacity: 0; visibility: hidden; }
.spinner { font-size: 24px; font-weight: 700; color: var(--accent); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.95); } }

.typing-container { font-size: 24px; font-weight: 600; color: var(--text-main); display: inline-flex; align-items: center; min-height: 1.5em; }
.cursor { width: 2px; height: 1.2em; background: var(--accent); margin-left: 4px; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* === Drag Tooltip === */
.drag-tooltip {
  position: fixed;
  background: var(--surface-3);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  pointer-events: none;
  z-index: 9999;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  transform: translate(-50%, -100%) scale(0.9);
}
.drag-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}
.drag-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent);
}
