/* ============================================================
   phidang.work — global styles
   Minimal editorial portfolio, light theme
   ============================================================ */

:root {
  --bg: #fdfdfc;
  --text: #1c1c1c;
  --text-secondary: #8f8f8f;
  --text-tertiary: #b5b5b5;
  --border: #ececea;
  --surface: #f4f4f2;
  --accent: #1c1c1c;
  --content-width: 40rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --bg: #121212;
  --text: #eceae6;
  --text-secondary: #8f8f8f;
  --text-tertiary: #5c5c5c;
  --border: #262626;
  --surface: #1c1c1c;
  --accent: #eceae6;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  transition: background 0.3s, color 0.3s;
}

[data-theme="dark"] ::selection {
  background: #eceae6;
  color: #121212;
}

[data-theme="dark"] .avatar {
  background: linear-gradient(135deg, #e8e8e4, #b8b8b4);
  color: #121212;
}

/* Dim screenshots slightly in dark mode so they don't glare */
[data-theme="dark"] .gallery-item img {
  filter: brightness(0.9);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: #1c1c1c;
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Typography ---------- */

h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Section headings share the nav-link look: same size, weight, muted color */
h2 {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
  max-width: 65ch;
}

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

.muted {
  color: var(--text-secondary);
}

/* ---------- Top nav ---------- */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-nav .nav-links {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  font-size: 0.875rem;
}

.site-nav .nav-links a {
  color: var(--text-secondary);
  transition: color 0.2s;
  position: relative;
}

.site-nav .nav-links a:hover {
  color: var(--text);
}

.site-nav .nav-home {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s var(--ease-out);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: #d0d0cd;
  transform: translateY(-1px);
}

[data-theme="dark"] .theme-toggle:hover {
  border-color: #3a3a3a;
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
}

/* Show the icon of the mode you can switch TO */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Layout: home ---------- */

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
}

section {
  margin-bottom: 4.5rem;
}

/* ---------- Header / hero ---------- */

.hero {
  margin-bottom: 4.5rem;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2b2b2b, #555);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero .subtitle {
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

/* Stacked role lines (ViruSs-style) */
.hero-roles {
  list-style: none;
  margin-top: 0.625rem;
}

.hero-roles li {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.1875rem 0;
}

.hero-roles li.muted-role {
  color: var(--text-tertiary);
}

.hero-line {
  margin-top: 1.25rem;
  color: var(--text);
}

.see-more {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.see-more a {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.see-more a:hover {
  color: var(--text);
}

/* ---------- Entry list (projects, experience, thoughts) ---------- */

.entry-list {
  list-style: none;
}

.entry {
  display: flex;
  gap: 1.5rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

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

.entry-date {
  flex: 0 0 7.5rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  padding-top: 0.0625rem;
}

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.entry-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.125rem;
  margin-bottom: 0;
}

.entry-meta {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

/* Linked entries: arrow slides on hover */
a.entry-link .entry-title::after {
  content: "↗";
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  transition: transform 0.25s var(--ease-out), color 0.25s;
  display: inline-block;
}

a.entry-link:hover .entry-title::after {
  transform: translate(2px, -2px);
  color: var(--text);
}

a.entry-link {
  display: flex;
  gap: 1.5rem;
  margin: 0 -0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  transition: background 0.2s;
}

a.entry-link:hover {
  background: var(--surface);
}

li.entry:has(a.entry-link) {
  display: block;
  padding: 0;
}

.tag-soon {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  vertical-align: middle;
}

/* ---------- Work rows (numbered list, thumb appears on hover) ---------- */

.work-list {
  list-style: none;
}

.work-title .tag-soon {
  margin-left: 0.375rem;
  vertical-align: 0.125rem;
}

.work-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.375rem 1rem 1.375rem 0;
  border-top: 1px solid var(--border);
  transition: background 0.3s;
}

.work-list li:last-child .work-row {
  border-bottom: 1px solid var(--border);
}

/* Left accent bar, grows in on hover */
.work-row::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--text);
  transform: scaleY(0);
  transition: transform 0.35s var(--ease-out);
}

a.work-row:hover {
  background: linear-gradient(90deg, var(--surface), transparent 70%);
}

a.work-row:hover::before {
  transform: scaleY(1);
}

.work-num {
  flex: 0 0 2.25rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  transition: color 0.3s;
}

a.work-row:hover .work-num {
  color: var(--text);
}

.work-main {
  flex: 1;
  min-width: 0;
}

.work-title {
  display: block;
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.work-sub {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-top: 0.1875rem;
}

/* Right side: metric by default, thumbnail on hover */
.work-right {
  position: relative;
  flex: 0 0 8.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 3.5rem;
}

.work-metric {
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  transition: opacity 0.25s, transform 0.25s var(--ease-out);
}

.work-metric small {
  display: block;
  font-family: "Inter", sans-serif;
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.work-thumb {
  position: absolute;
  right: 0;
  top: 50%;
  width: 8.5rem;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-radius: 0.375rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(-50%) translateX(8px) scale(0.96);
  transition: opacity 0.3s, transform 0.35s var(--ease-out);
  pointer-events: none;
}

a.work-row:hover .work-metric {
  opacity: 0;
  transform: translateX(-8px);
}

a.work-row:hover .work-thumb {
  opacity: 1;
  transform: translateY(-50%) translateX(0) scale(1);
}

@media (max-width: 48rem) {
  .work-thumb {
    display: none;
  }

  .work-right {
    flex-basis: auto;
    min-height: 0;
  }

  .work-row {
    gap: 1rem;
    padding-right: 0.5rem;
  }
}

/* ---------- Stack / toolbox ---------- */

.stack-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stack-item {
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  transition: transform 0.2s var(--ease-out), border-color 0.2s;
}

.stack-item:hover {
  transform: translateY(-2px);
  border-color: #d8d8d5;
}

/* ---------- Contact ---------- */

.contact-list {
  list-style: none;
}

.contact-list li {
  padding: 0.375rem 0;
}

.contact-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  transition: color 0.2s;
}

.contact-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  min-width: 6rem;
  display: inline-block;
}

.contact-value {
  position: relative;
}

.contact-value::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}

a:hover .contact-value::after {
  transform: scaleX(1);
}

/* ---------- Footer ---------- */

footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

/* ---------- Project detail layout ---------- */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--content-width)) 1fr;
  gap: 3rem;
  padding: 6rem 1.5rem 4rem;
  max-width: 72rem;
  margin: 0 auto;
}

.detail-sidebar {
  grid-column: 1;
  position: sticky;
  top: 6rem;
  align-self: start;
  font-size: 0.875rem;
}

.detail-content {
  grid-column: 2;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2.5rem;
  transition: opacity 0.2s;
}

.back-link:hover {
  opacity: 0.6;
}

.back-link .arrow {
  transition: transform 0.25s var(--ease-out);
}

.back-link:hover .arrow {
  transform: translateX(-3px);
}

.section-nav {
  list-style: none;
}

.section-nav li {
  margin-bottom: 0.5rem;
}

.section-nav a {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.section-nav a:hover,
.section-nav a.active {
  color: var(--text);
}

/* ---------- Project meta table ---------- */

.project-title {
  margin-bottom: 1.5rem;
}

.meta-table {
  display: grid;
  grid-template-columns: 7rem 1fr;
  row-gap: 0.375rem;
  margin-bottom: 3rem;
  font-size: 0.9375rem;
}

.meta-table dt {
  color: var(--text-secondary);
}

.meta-table dd {
  margin: 0;
}

.meta-table a {
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s;
}

.meta-table a:hover {
  border-color: var(--text);
}

/* ---------- Detail sections ---------- */

.detail-section {
  margin-bottom: 3.5rem;
  scroll-margin-top: 5rem;
}

.detail-section ul {
  list-style: none;
  margin-bottom: 1rem;
}

.detail-section ul li {
  position: relative;
  padding-left: 1.125rem;
  margin-bottom: 0.375rem;
  max-width: 65ch;
}

.detail-section ul li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--text-tertiary);
}

.detail-section h3 {
  margin-top: 1.75rem;
}

/* ---------- Gallery ---------- */

.gallery {
  margin: 2.5rem 0 0.75rem;
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery-item {
  flex: 0 0 min(100%, 32rem);
  scroll-snap-align: start;
  aspect-ratio: 4 / 3;
  border-radius: 0.625rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
}

.gallery-item.portrait {
  flex-basis: min(55%, 14rem);
  aspect-ratio: 9 / 19;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholder until real screenshots are dropped into assets/ */
.gallery-item .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  background:
    radial-gradient(ellipse at 30% 20%, #efefec 0%, transparent 55%),
    radial-gradient(ellipse at 75% 85%, #e9e9e5 0%, transparent 55%),
    var(--surface);
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.gallery-item .placeholder .ph-title {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Gallery scroll progress bar */
.gallery-progress {
  height: 2px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.gallery-progress .bar {
  height: 100%;
  width: 20%;
  background: var(--text);
  border-radius: 999px;
  transition: transform 0.1s linear;
  transform-origin: left;
}

/* ---------- Motion: reveal on load / scroll ---------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition:
      opacity 0.7s var(--ease-out),
      transform 0.7s var(--ease-out);
    transition-delay: var(--reveal-delay, 0s);
  }

  .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 60rem) {
  .detail-layout {
    display: block;
    padding-top: 4rem;
  }

  .detail-sidebar {
    position: static;
    margin-bottom: 2.5rem;
  }

  .section-nav {
    display: none;
  }

  .container {
    padding-top: 4rem;
  }

  .entry,
  a.entry-link {
    flex-direction: column;
    gap: 0.125rem;
  }

  .entry-date {
    flex-basis: auto;
  }

  .meta-table {
    grid-template-columns: 6rem 1fr;
  }
}
