/* ============================================================
   CSS custom properties — dark theme default
   ============================================================ */
:root {
  --bg:          #1e1e1e;
  --bg-alt:      #252526;
  --bg-hover:    #2a2d2e;
  --border:      #3c3c3c;
  --text:        #cccccc;
  --text-dim:    #6a6a6a;
  --text-bright: #e8e8e8;
  --accent:      #569cd6;
  --tab-active:  #2d2d2d;
  --tab-bg:      #2d2d2d;
  --tabbar-h:    36px;
  --statusbar-h: 24px;
  --sidebar-w:   260px;
  --linenum-w:   48px;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;
  --font-sans:   'Space Grotesk', system-ui, sans-serif;
  --ascii-color: #3a3a3a;
  --overlay-name-color: #e8e8e8;

  /* Syntax token colours */
  --tok-comment: #6a9955;
  --tok-kw:      #c586c0;
  --tok-var:     #9cdcfe;
  --tok-key:     #9cdcfe;
  --tok-str:     #ce9178;
  --tok-bool:    #569cd6;
  --tok-op:      #d4d4d4;
  --tok-punct:   #d4d4d4;
  --tok-link:    #ce9178;
}

[data-theme="light"] {
  --bg:          #ffffff;
  --bg-alt:      #f3f3f3;
  --bg-hover:    #e8e8e8;
  --border:      #d4d4d4;
  --text:        #333333;
  --text-dim:    #999999;
  --text-bright: #111111;
  --accent:      #0070f3;
  --tab-active:  #ffffff;
  --tab-bg:      #ececec;
  --ascii-color: #cccccc;
  --overlay-name-color: #111111;

  /* Syntax token colours — light theme */
  --tok-comment: #008000;
  --tok-kw:      #af00db;
  --tok-var:     #001080;
  --tok-key:     #001080;
  --tok-str:     #a31515;
  --tok-bool:    #0000ff;
  --tok-op:      #333333;
  --tok-punct:   #333333;
  --tok-link:    #a31515;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; background: none; border: none; color: inherit; font: inherit; }
ul { list-style: none; }
svg { display: block; }

/* ============================================================
   Editor shell
   ============================================================ */
.editor {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ---- Tab bar ---- */
.editor__tabbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: var(--tabbar-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.editor__tabs {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}
.editor__tabs::-webkit-scrollbar { display: none; }

.editor__tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--tab-bg);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.editor__tab:hover { color: var(--text); background: var(--bg-hover); }
.editor__tab.state-active {
  color: var(--text-bright);
  background: var(--tab-active);
  border-bottom: 1px solid var(--tab-active);
  margin-bottom: -1px;
}

.editor__tab__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5c07b;
  flex-shrink: 0;
}

.editor__tabbar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
}

.editor__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--text-dim);
  transition: color 0.15s, background 0.15s;
}
.editor__action:hover { color: var(--text-bright); background: var(--bg-hover); }

.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.icon--moon { fill: currentColor; stroke: none; }

[data-theme="dark"]  .icon--sun  { display: block; }
[data-theme="dark"]  .icon--moon { display: none; }
[data-theme="light"] .icon--sun  { display: none; }
[data-theme="light"] .icon--moon { display: block; }

/* ---- Breadcrumb bar ---- */
.editor__breadcrumb {
  height: 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 12px 0 calc(var(--linenum-w) + 12px);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

/* ---- Layout: sidebar + pane ---- */
.editor__layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.editor__sidebar {
  width: var(--sidebar-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.25s ease;
}
.editor__sidebar.state-hidden {
  width: 0;
  border-right: none;
}

.sidebar__panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar__panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__tabs {
  display: flex;
  flex: 1;
}
.sidebar__tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
  text-align: center;
}
.sidebar__tab:hover { color: var(--text); }
.sidebar__tab.state-active { color: var(--text-bright); border-bottom-color: var(--accent); }

.sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: color 0.15s;
}
.sidebar__close svg { width: 14px; height: 14px; fill: currentColor; }
.sidebar__close:hover { color: var(--text-bright); }

.sidebar__content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.sidebar__content.state-hidden { display: none; }

.sidebar__name {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.sidebar__role {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
}

.sidebar__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.sidebar__link {
  font-size: 12px;
  color: var(--text-dim);
  transition: color 0.15s;
}
.sidebar__link:hover { color: var(--text-bright); }

/* Resume link — slightly more prominent than standard sidebar links */
.sidebar__link--resume {
  color: var(--accent);
  font-weight: 700;
}
.sidebar__link--resume:hover { color: var(--text-bright); }

.sidebar__location {
  font-size: 11px;
  color: var(--text-dim);
}

/* ---- Editor main pane ---- */
.editor__pane {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Line numbers */
.editor__linenums {
  width: var(--linenum-w);
  padding: 4px 12px 0 0;
  overflow: hidden;
  text-align: right;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 20px;
  flex-shrink: 0;
  pointer-events: none;
  white-space: pre;
  background: var(--bg);
  border-right: 1px solid var(--border);
  user-select: none;
}

/* File sections — kept in DOM for SEO; inactive sections are visually hidden */
.editor__file {
  visibility: hidden;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.editor__file.state-active {
  visibility: visible;
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ASCII art fill */
.editor__ascii {
  position: absolute;
  inset: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20px;
  color: var(--ascii-color);
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  padding: 4px 0 0 0;
  word-break: break-all;
  letter-spacing: 0;
}

/* Overlay text (hero) */
.editor__overlay {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 40px;
  flex: 1;
  pointer-events: none;
}

.overlay__role {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}

.overlay__name {
  font-family: var(--font-sans);
  font-size: clamp(4rem, 12vw, 11rem);
  font-weight: 700;
  line-height: 0.9;
  color: var(--overlay-name-color);
  letter-spacing: -0.02em;
  pointer-events: none;
}

/* Text overlay (about, work, contact) */
.editor__overlay--text {
  overflow-y: auto;
  justify-content: flex-start;
  padding: 40px 60px;
  pointer-events: auto;
}

.overlay__code {
  max-width: 680px;
  font-size: 13px;
  line-height: 1.8;
}

/* Code token colours — driven by CSS variables for full theme support */
.tok-comment { color: var(--tok-comment); }
.tok-kw      { color: var(--tok-kw); }
.tok-var     { color: var(--tok-var); }
.tok-key     { color: var(--tok-key); }
.tok-str     { color: var(--tok-str); }
.tok-bool    { color: var(--tok-bool); }
.tok-op      { color: var(--tok-op); }
.tok-punct   { color: var(--tok-punct); }
.tok-link    { color: var(--tok-link); text-decoration: underline; text-underline-offset: 3px; pointer-events: auto; }
.tok-link:hover { color: var(--text-bright); }

.indent-1 { display: inline; margin-left: 1.5em; }
.indent-2 { display: inline; margin-left: 3em; }
.indent-block-1 { margin-left: 1.5em; }
.indent-block-2 { margin-left: 3em; }
.indent-block-3 { margin-left: 4.5em; }

/* ---- Work grid ---- */
.work__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.work__card {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, background 0.2s;
}
.work__card:hover { border-color: var(--accent); background: var(--bg-hover); }

.work__card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.work__title {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
}

.work__desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  flex: 1;
}

.work__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 2px;
}

/* ---- Experience list ---- */
.experience__list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.experience__item {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 20px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s, background 0.2s;
}
.experience__item:hover { border-color: var(--accent); background: var(--bg-hover); }

.experience__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.experience__company {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
  margin: 0;
}

.experience__period {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.experience__role {
  font-size: 12px;
  color: var(--accent);
  margin: 0;
  font-style: italic;
}

.experience__desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}

/* ---- Contact form ---- */
.contact__form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }

.form__row { display: flex; align-items: flex-start; gap: 8px; }
.form__label { flex-shrink: 0; padding-top: 6px; font-size: 12px; min-width: 90px; }

.form__input {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
.form__input:focus { border-color: var(--accent); }
.form__textarea { min-height: 80px; resize: vertical; }

.form__submit {
  align-self: flex-start;
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.form__submit:hover { border-color: var(--accent); background: var(--bg-hover); }
.form__submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Plain-language send label displayed alongside the code-style text */
.form__submit__label {
  font-size: 11px;
  color: var(--text-dim);
  border-left: 1px solid var(--border);
  padding-left: 10px;
  font-style: italic;
}
.form__submit:hover .form__submit__label { color: var(--text-bright); }

.form__status { font-size: 12px; color: var(--text-dim); }
.form__status.state-success { color: #4ec9b0; }
.form__status.state-error   { color: #f44747; }

/* ---- Status bar ---- */
.editor__statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--statusbar-h);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 0 12px;
  flex-shrink: 0;
  user-select: none;
}
.statusbar__left, .statusbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

/* ============================================================
   Responsive — tablet (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }

  .overlay__name { font-size: clamp(3.5rem, 10vw, 8rem); }

  .editor__overlay--text { padding: 32px 40px; }
}

/* ============================================================
   Responsive — large mobile (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; --linenum-w: 36px; }

  .editor__sidebar {
    position: absolute;
    top: var(--tabbar-h);
    left: 0;
    z-index: 10;
    height: calc(100% - var(--tabbar-h) - var(--statusbar-h));
  }
  .editor__sidebar.state-hidden { width: 0; }

  .editor__overlay--text { padding: 28px 24px; }

  .overlay__name { font-size: clamp(3rem, 16vw, 6rem); }

  .work__grid { grid-template-columns: 1fr; }

  .form__row { flex-direction: column; gap: 4px; }
  .form__label { padding-top: 0; }
}

/* ============================================================
   Responsive — small mobile (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; --linenum-w: 32px; }

  .editor__sidebar {
    position: absolute;
    top: var(--tabbar-h);
    left: 0;
    z-index: 10;
    height: calc(100% - var(--tabbar-h) - var(--statusbar-h));
  }
  .editor__sidebar.state-hidden { width: 0; }

  .editor__overlay--text { padding: 24px 16px; }

  .overlay__name { font-size: clamp(3rem, 20vw, 6rem); }

  .work__grid { grid-template-columns: 1fr; }

  .form__row { flex-direction: column; gap: 4px; }
  .form__label { padding-top: 0; }
}
