/* ============================================================
   Pham Tran Tan Phat — Portfolio
   Theme: clean, modern, professional.  Accent = crimson red.
   ============================================================ */

:root {
  --bg:        #ffffff;
  --bg-alt:    #f7f7f8;
  --surface:   #ffffff;
  --surface-2: #fafafa;
  --border:    #e6e6ea;
  --fg:        #18181b;
  --fg-muted:  #5b5b65;
  --fg-soft:   #8a8a93;
  --accent:    #b91c1c;        /* crimson */
  --accent-2:  #ef4444;
  --accent-soft: #fee2e2;
  --shadow:    0 1px 2px rgba(16,16,20,.04), 0 8px 24px rgba(16,16,20,.04);
  --radius:    14px;
  --radius-sm: 10px;
  --maxw:      1100px;
  --font:      'Inter', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg:        #0b0b0f;
  --bg-alt:    #111118;
  --surface:   #14141c;
  --surface-2: #181820;
  --border:    #26262f;
  --fg:        #f4f4f5;
  --fg-muted:  #b4b4bb;
  --fg-soft:   #7f7f88;
  --accent:    #f87171;
  --accent-2:  #fca5a5;
  --accent-soft: rgba(248,113,113,.12);
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--fg); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { margin: 0 0 1em; }
.muted { color: var(--fg-muted); }
.small { font-size: .875rem; }
.mt { margin-top: 1.25rem; }
code {
  font-family: var(--mono);
  background: var(--bg-alt);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .875em;
}

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: 8px 12px; border-radius: 0 0 8px 0; z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.nav__links { margin-left: auto; display: flex; gap: 20px; }
.nav__links a { color: var(--fg-muted); font-weight: 500; }
.nav__links a:hover { color: var(--fg); text-decoration: none; }
.icon-btn {
  background: transparent; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg-soft); }

@media (max-width: 720px) {
  .nav__links { gap: 12px; font-size: .9rem; }
  .nav__links a:nth-child(2), .nav__links a:nth-child(3) { display: none; }
}

/* ---------- hero ---------- */
.hero { padding: 64px 0 32px; }
.hero__grid {
  display: grid; gap: 40px;
  grid-template-columns: 1.4fr .9fr; align-items: center;
}
@media (max-width: 880px) { .hero__grid { grid-template-columns: 1fr; } }
.eyebrow {
  display: inline-block; font-size: .8rem; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 999px; margin: 0 0 14px;
  letter-spacing: .04em; text-transform: uppercase;
}
.hero__title { font-size: 1.25rem; color: var(--fg-muted); margin: 4px 0 14px; }
.hero__tagline { font-size: 1.1rem; max-width: 60ch; }
.hero__summary { color: var(--fg-muted); max-width: 60ch; }
.hero__cta { display: flex; gap: 12px; margin: 22px 0 18px; flex-wrap: wrap; }
.hero__meta {
  list-style: none; padding: 0; margin: 20px 0 0;
  display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--fg-muted); font-size: .92rem;
}
.hero__meta li { display: inline-flex; align-items: center; gap: 8px; }
.hero__meta a { color: inherit; }
.hero__meta a:hover { color: var(--accent); }
.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 16px; }

.hero__avatar { position: relative; display: grid; place-items: center; }
.hero__avatar img {
  width: min(320px, 80%); aspect-ratio: 1; border-radius: 50%;
  object-fit: cover; box-shadow: var(--shadow);
  border: 4px solid var(--surface);
}
.hero__avatar__ring {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(80% 80% at 50% 50%, transparent 55%, var(--accent-soft) 56%, transparent 70%);
  border-radius: 50%;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: transform .04s ease, background .15s, color .15s, border-color .15s;
  font-family: inherit; font-size: 1rem;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); text-decoration: none; }
.btn--ghost {
  background: transparent; color: var(--fg);
  border-color: var(--border);
}
.btn--ghost:hover { border-color: var(--fg-soft); text-decoration: none; }

/* ---------- sections ---------- */
.section { padding: 72px 0; }
.section--alt { background: var(--bg-alt); }
.section__head { margin-bottom: 28px; }
.section__head h2 { margin-bottom: 6px; }
.section__sub { color: var(--fg-muted); margin: 0; }

/* ---------- about ---------- */
.about__grid { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; margin-top: 18px; }
@media (max-width: 720px) { .about__grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.li__top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.li strong { color: var(--fg); }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .88rem; color: var(--fg);
}
.chips--mono .chip { font-family: var(--mono); font-size: .8rem; }

/* ---------- skills ---------- */
.skills {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.skill-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.skill-group h3 { margin-bottom: 12px; color: var(--accent); }

/* ---------- timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border);
}
.t-item { display: grid; grid-template-columns: 24px 1fr; gap: 16px; padding: 8px 0 18px; }
.t-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); margin-top: 24px; box-shadow: 0 0 0 4px var(--accent-soft);
  position: relative; left: 6px;
}
.t-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.t-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.t-card__co { color: var(--fg-muted); margin: 4px 0 8px; }
.badge {
  font-size: .8rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 4px 10px;
  white-space: nowrap;
}

/* ---------- projects ---------- */
.projects {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.proj {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.proj__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proj__head h3 { color: var(--fg); }
.proj__hl { padding-left: 1.1em; margin: 10px 0 16px; color: var(--fg-muted); }
.proj__hl li { margin-bottom: 6px; }
.proj .chips { margin-top: auto; }

/* ---------- contact ---------- */
.contact { display: grid; gap: 24px; grid-template-columns: 1.4fr 1fr; }
@media (max-width: 820px) { .contact { grid-template-columns: 1fr; } }
.contact__form {
  display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.contact__form label { display: grid; gap: 6px; font-size: .9rem; font-weight: 500; }
.contact__form input,
.contact__form textarea {
  font: inherit; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.contact__form input:focus,
.contact__form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.contact__msg { grid-column: 1 / -1; }
.contact__card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.contact__card h3 { margin-bottom: 12px; }
.contact__card .list { gap: 14px; }
.socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.social {
  display: inline-flex; padding: 8px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg); font-weight: 500;
}
.social:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.form-status { min-height: 1.2em; margin: 4px 0 0; font-size: .9rem; }
.form-status.ok  { color: #15803d; }
.form-status.err { color: var(--accent); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0; color: var(--fg-muted);
  font-size: .9rem;
}
.site-footer p { margin: 0 0 4px; }

/* ============================================================
   Auth (header sign-in button + user menu dropdown)
   ============================================================ */
.btn--sm { padding: 8px 14px; font-size: .9rem; border-radius: 10px; }

.auth { position: relative; display: flex; align-items: center; }
.auth-menu { position: relative; }
.auth-userbtn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer;
  color: var(--fg); font: inherit; font-size: .9rem;
  max-width: 220px;
}
.auth-userbtn:hover { border-color: var(--fg-soft); }
.auth-userbtn img {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  flex: 0 0 28px; background: var(--surface-2);
}
.auth-userbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 240px; padding: 6px; z-index: 60;
  display: flex; flex-direction: column; gap: 2px;
}
.auth-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  background: transparent; border: 0; color: var(--fg); cursor: pointer;
  font: inherit; font-size: .9rem; text-align: left; width: 100%;
}
.auth-row:hover { background: var(--bg-alt); }
.auth-row.muted { color: var(--fg-muted); cursor: default; }
.auth-row.muted:hover { background: transparent; }
.auth-row .badge { margin-left: auto; }
.badge--soft { background: var(--bg-alt); color: var(--fg-muted); }
.badge--on   { background: var(--accent); color: #fff; }

/* ============================================================
   Save bar (sticky strip below header in edit mode)
   ============================================================ */
.save-bar {
  background: var(--bg-alt); border-bottom: 1px solid var(--border);
  padding: 6px 24px; font-size: .85rem; color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.save-bar.ok  { color: #15803d; background: #f0fdf4; }
.save-bar.err { color: var(--accent); background: #fef2f2; }

/* ============================================================
   Edit mode visual cues + controls
   ============================================================ */
body.editing [contenteditable="true"] {
  outline: 1px dashed transparent;
  outline-offset: 2px; transition: outline-color .15s, background .15s;
  border-radius: 4px;
  cursor: text;
}
body.editing [contenteditable="true"]:hover { outline-color: var(--fg-soft); }
body.editing [contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  background: var(--accent-soft);
}

/* + Add button (appended to each list container) */
.edit-add {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 8px 0 0; padding: 8px 14px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px dashed var(--accent); border-radius: 10px;
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
}
.edit-add:hover { background: var(--accent); color: #fff; }
.edit-add__icon { font-size: 1.1em; line-height: 1; }
/* When the host is a flex chips row, button flows inline */
.chips .edit-add { margin: 0; padding: 4px 10px; font-size: .75rem; }
.skills .edit-add { width: 100%; justify-content: center; padding: 16px; }
.projects .edit-add { width: 100%; justify-content: center; padding: 18px; }

/* × Delete button (overlayed on each list item) */
.edit-del {
  position: absolute; top: -8px; right: -8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 2px solid var(--bg);
  font-size: 1rem; line-height: 1; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; z-index: 5;
}
body.editing .edit-del { display: inline-flex; }
body.editing .chip .edit-del { width: 18px; height: 18px; font-size: .75rem; top: -6px; right: -6px; }

/* ============================================================
   Avatar dropzone (edit mode)
   ============================================================ */
.hero__avatar.avatar-editable { cursor: pointer; }
.hero__avatar .dropzone {
  position: absolute; inset: 0; border-radius: 50%;
  display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 30%, transparent);
  border: 2px dashed var(--accent);
  opacity: 0; transition: opacity .15s;
}
.hero__avatar.avatar-editable .dropzone { opacity: 1; pointer-events: auto; }
.hero__avatar.is-dragover .dropzone {
  background: var(--accent-soft); opacity: 1;
}
.dropzone__inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--accent); font-weight: 600; font-size: .85rem;
  text-align: center; padding: 8px;
}

/* ============================================================
   Modal (setup dialog)
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}
.modal__panel {
  position: relative; z-index: 1;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); color: var(--fg);
  border-radius: 16px; border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 28px;
}
.modal__x {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 0; color: var(--fg-muted);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.modal__x:hover { background: var(--bg-alt); color: var(--fg); }
.modal__panel h2 { margin: 0 0 8px; font-size: 1.4rem; }
.modal__steps {
  margin: 16px 0 18px; padding-left: 1.3em;
  color: var(--fg-muted); font-size: .92rem;
}
.modal__steps li { margin-bottom: 8px; }
.modal__steps code {
  background: var(--bg-alt); padding: 1px 6px; border-radius: 6px;
  font-family: var(--mono); font-size: .85em; word-break: break-all;
}
.modal__form { display: grid; gap: 12px; margin: 8px 0 16px; }
.modal__form label { display: grid; gap: 6px; font-size: .9rem; font-weight: 500; }
.modal__form input {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg);
}
.modal__form input:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: var(--accent); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal__note { margin-top: 12px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 300;
  max-width: calc(100vw - 32px);
}
.toast.ok  { background: #16a34a; color: #fff; }
.toast.err { background: var(--accent); color: #fff; }
.toast.warn{ background: #b45309; color: #fff; }

/* ============================================================
   Collapsible project cards
   ============================================================ */
.proj { padding: 0; overflow: hidden; }
.proj__head {
  width: 100%; display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 22px; background: transparent; border: 0;
  text-align: left; cursor: pointer; color: inherit; font: inherit;
}
.proj__head:hover { background: var(--surface-2); }
.proj__head__main { flex: 1; min-width: 0; }
.proj__head h3 { margin: 0 0 6px; color: var(--fg); }
.proj__preview {
  color: var(--fg-muted); margin: 0 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: .95rem;
}
.proj__meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: .85rem; color: var(--fg-muted); align-items: center;
}
.proj__co {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fg);
}
.proj__co .i { color: var(--accent); }
.proj__role { font-size: .85rem; }
.proj__chev {
  flex-shrink: 0; padding: 4px; color: var(--fg-muted);
  transition: transform .2s;
}
.proj.proj--open .proj__chev { transform: rotate(180deg); }
.proj__body {
  padding: 4px 22px 22px;
  animation: fadeIn .2s ease-out;
}
.proj.proj--open .proj__body { display: block; }
.proj__hl { padding-left: 1.1em; margin: 6px 0 14px; color: var(--fg-muted); }
.proj__hl li { margin-bottom: 6px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Mobile auth tweaks
   ============================================================ */
@media (max-width: 540px) {
  .auth-userbtn span { display: none; }
  .auth-userbtn { padding: 4px; }
  .modal__panel { padding: 20px; }
}
