/* ------------------------------------------------------------------ *
 *  Personal portfolio – plain, monospace, terminal-ish.
 *  Light & dark themes are driven by [data-theme] on <html>.
 * ------------------------------------------------------------------ */

:root,
:root[data-theme="light"] {
  --bg: #f6f4ee;          /* warm paper off-white */
  --fg: #1c1b18;          /* soft near-black ink */
  --muted: #6d6a61;
  --muted-2: #57544c;
  --border: #2b2925;      /* softer than pure black */
  --border-soft: #d3cfc4;
  --link: #1f49c4;        /* classic-but-softer blue */
  --box-bg: #fffefb;      /* slightly brighter card */
  --accent-bg: #232019;
  --accent-fg: #f6f4ee;
  --ok-bg: #e3f2df;
  --err-bg: #f6dedb;
  --shadow: #26231d;      /* dark, for crisp retro offset shadows */
  --code-bg: #efece3;
}

:root[data-theme="dark"] {
  --bg: #14140f;          /* warm near-black */
  --fg: #e8e4d8;          /* warm off-white ink */
  --muted: #9d988a;
  --muted-2: #b6b1a2;
  --border: #4c4a40;
  --border-soft: #2c2b24;
  --link: #9db8ff;
  --box-bg: #1c1b15;
  --accent-bg: #e8e4d8;
  --accent-fg: #14140f;
  --ok-bg: #16301a;
  --err-bg: #3a1a17;
  --shadow: #000000;
  --code-bg: #201f18;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: "Courier New", Courier, monospace;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#page {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

img { max-width: 100%; }

a { color: var(--link); }

header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

header h1 { margin: 0; font-size: 24px; letter-spacing: 0.5px; }
header h1 .site-name { color: inherit; text-decoration: none; }
header h1 .site-name:hover { text-decoration: underline; }
header p { margin: 4px 0 0 0; font-size: 13px; }

nav { margin-top: 10px; font-size: 13px; }
nav a { margin-right: 10px; color: var(--link); text-decoration: underline; }

main { font-size: 14px; line-height: 1.6; }

section { margin-bottom: 24px; }
section h2 {
  font-size: 18px;
  margin: 0 0 4px 0;
  border-bottom: 1px solid var(--border);
  display: inline-block;
  padding-bottom: 2px;
}

.section-note { font-size: 12px; color: var(--muted-2); margin: 2px 0 8px 0; }

.mono-box {
  border: 1px solid var(--border);
  padding: 8px 12px;
  margin-top: 8px;
  background-color: var(--box-bg);
  box-shadow: 3px 3px 0 var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

ul { margin: 4px 0 4px 18px; padding: 0; }
li { margin-bottom: 3px; }

/* ---------- Error pages (404 / 500) ---------- */
.error-box {
  max-width: 560px;
  margin: 48px auto;
  text-align: center;
  padding: 24px 20px;
}
.error-code {
  font-size: 40px;
  font-weight: bold;
  letter-spacing: 6px;
  margin: 0 0 8px;
  color: var(--fg);
}
.error-box h1 { font-size: 18px; margin: 6px 0 12px; }
.error-box p { color: var(--muted-2); }
.error-ascii {
  font-size: 18px;
  margin: 16px 0;
  color: var(--muted);
  white-space: nowrap;
  overflow-x: auto;
}

.item {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-soft);
}
.item:last-child { border-bottom: none; }
.item-title { font-weight: bold; }
.item-meta { font-size: 12px; color: var(--muted); }
.item-description { margin-top: 4px; }

.tagline { font-size: 12px; color: var(--muted); margin-top: 4px; }

footer {
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: left;
}

/* ---------- Theme toggle button ---------- */
.theme-toggle {
  position: fixed;   /* default for standalone use (panel / login) */
  top: 12px;
  right: 12px;
  z-index: 10000;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  background-color: var(--box-bg);
  color: var(--fg);
  padding: 5px 8px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.theme-toggle:hover { background-color: var(--accent-bg); color: var(--accent-fg); }
.theme-toggle:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }

/* Public site: keep the toggle inside the page frame, sticky while scrolling. */
.theme-toggle-bar {
  position: sticky;
  top: 8px;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
  pointer-events: none;
}
.theme-toggle-bar .theme-toggle {
  position: static;
  pointer-events: auto;
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  min-width: 240px;
  max-width: 340px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 13px;
  background-color: var(--box-bg);
  color: var(--fg);
  box-shadow: 2px 2px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.success { background-color: var(--ok-bg); }
.toast.error { background-color: var(--err-bg); }
.toast-hide { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.toast-close {
  border: none; background: none; color: inherit;
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 12px; margin-bottom: 3px; }
.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  border: 1px solid var(--border);
  background-color: var(--bg);
  color: var(--fg);
}
.form-errors { font-size: 11px; color: #bb0000; margin-top: 2px; }
.contact-form { margin-top: 12px; border-top: 1px dashed var(--border-soft); padding-top: 12px; }

button.btn,
a.btn,
.contact-form button,
input[type="submit"] {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background-color: var(--accent-bg);
  color: var(--accent-fg);
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
}
button.btn:hover,
a.btn:hover,
.contact-form button:hover { opacity: 0.88; }
button.btn:active,
a.btn:active,
.contact-form button:active,
input[type="submit"]:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }

.btn-secondary {
  background-color: var(--box-bg);
  color: var(--fg);
}

/* ---------- Announcement / alert bar ---------- */
.alert-bar {
  display: flex;
  align-items: center;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.alert-inner { flex: 1 1 auto; overflow: hidden; min-width: 0; }
.alert-static { display: block; text-align: center; padding: 6px 12px; }
/* Single-copy marquee: padding-left:100% parks the text just off the right
   edge, then it scrolls fully off the left and re-enters from the right — one
   seamless loop at a constant speed, regardless of message length. */
.alert-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  will-change: transform;
}
.alert-track span { padding: 0 1rem; }
.alert-track.alert-left,
.alert-track.alert-right {
  animation-name: alertMarquee;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
/* Reverse makes it enter from the left and exit right instead. */
.alert-track.alert-right { animation-direction: reverse; }
@keyframes alertMarquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.alert-close {
  flex: 0 0 auto; border: none; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 12px; opacity: 0.8;
}
.alert-close:hover { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .alert-track { animation: none !important; }
}

/* ---------- Swipeable image gallery + lightbox ---------- */
.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  margin: 10px 0;
}
.gallery-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: block;
  border: 1px solid var(--border-soft);
  line-height: 0;
  cursor: zoom-in;
}
.gallery-item img { height: 220px; width: auto; display: block; object-fit: cover; }
.gallery-single { display: block; overflow: visible; }
.gallery-single .gallery-item { width: 100%; }
.gallery-single .gallery-item img { height: auto; width: 100%; max-height: 460px; object-fit: contain; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.lightbox[hidden] { display: none; }
.lightbox-fig { margin: 0; max-width: 92vw; max-height: 92vh; text-align: center; }
.lightbox-fig img { max-width: 92vw; max-height: 82vh; object-fit: contain; }
.lightbox-fig figcaption { color: #eee; font-size: 13px; margin-top: 8px; }
.lightbox-close, .lightbox-nav {
  position: absolute;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  line-height: 1;
}
.lightbox-close { top: 16px; right: 20px; font-size: 34px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); font-size: 52px; padding: 0 18px; }
.lightbox-prev { left: 6px; }
.lightbox-next { right: 6px; }

/* ---------- Résumé / projects list ---------- */
.resume-item {
  border: 1px solid var(--border);
  background: var(--box-bg);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 2px 2px 0 var(--shadow);
}
.resume-item.featured { box-shadow: 3px 3px 0 var(--shadow); border-color: var(--fg); }
.resume-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.resume-head h3 { margin: 0; font-size: 17px; }
.resume-head h3 a { text-decoration: none; color: var(--fg); }
.resume-period { font-size: 12px; color: var(--muted); white-space: nowrap; }
.resume-role { font-size: 13px; color: var(--muted); margin-top: 2px; }
.resume-summary { font-size: 14px; margin: 6px 0; }
.resume-tech { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.resume-links { font-size: 13px; margin-top: 6px; }

/* ---------- Feed thread / follow-ups ---------- */
.feed-followups { margin: 8px 0 0 16px; border-left: 2px solid var(--border-soft); padding-left: 12px; }
.feed-followup { margin-top: 8px; }
.feed-followup .feed-meta { margin-top: 4px; }
.feed-parent-note { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

/* ---------- News / feed ---------- */
.feed-item {
  border: 1px solid var(--border);
  background: var(--box-bg);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 2px 2px 0 var(--shadow);
}
.feed-single { box-shadow: 3px 3px 0 var(--shadow); }
.feed-pin { font-size: 11px; color: var(--muted); }
.feed-title { margin: 2px 0 6px 0; font-size: 17px; }
.feed-title a { text-decoration: none; color: var(--fg); }
.feed-body { font-size: 14px; line-height: 1.55; word-wrap: break-word; }
.feed-img { max-width: 100%; margin-top: 8px; border: 1px solid var(--border-soft); }
.feed-link { font-size: 13px; margin: 6px 0 0; }
.feed-meta { font-size: 11px; color: var(--muted); margin-top: 8px; }
.feed-author { font-weight: bold; }
.draft-banner {
  background: var(--accent-bg); border: 1px dashed var(--border);
  padding: 6px 10px; font-size: 13px; margin-bottom: 10px;
}

/* ---------- Blog ---------- */
/* Each post is a full card, and the whole card is the link (like the jokes cards). */
.post-card {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--box-bg);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 2px 2px 0 var(--shadow);
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.post-card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.post-card:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.post-card-cover {
  flex: 0 0 auto; width: 96px; height: 96px; object-fit: cover;
  border: 1px solid var(--border-soft);
}
.post-card-body { display: block; min-width: 0; }
.post-card h3 { margin: 0 0 2px 0; font-size: 16px; }
.post-meta { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.post-excerpt { display: block; font-size: 13px; margin-bottom: 4px; }
.post-card-tags { display: block; }

.tag, .category {
  display: inline-block;
  font-size: 11px;
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  margin: 2px 3px 2px 0;
  text-decoration: none;
  color: var(--muted-2);
}
.tag:hover, .category:hover { border-color: var(--border); }

.post-cover { max-width: 100%; height: auto; border: 1px solid var(--border); margin: 8px 0; }

/* Rich content coming from the editor */
.rich-content { font-size: 14px; line-height: 1.7; }
.rich-content img { max-width: 100%; height: auto; border: 1px solid var(--border-soft); margin: 8px 0; }
.rich-content pre {
  background: var(--code-bg);
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
}
.rich-content code { background: var(--code-bg); padding: 1px 4px; }
.rich-content blockquote {
  border-left: 3px solid var(--border-soft);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--muted-2);
}
.rich-content h2, .rich-content h3 { border: none; display: block; }

/* ---------- Jokes feed ---------- */
.joke-card {
  border: 1px solid var(--border);
  background: var(--box-bg);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: 2px 2px 0 var(--shadow);
}
.joke-card .joke-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.joke-card img { max-width: 100%; height: auto; margin-top: 6px; border: 1px solid var(--border-soft); }
.joke-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

#joke-sentinel { text-align: center; font-size: 12px; color: var(--muted); padding: 16px; }

/* ---------- Pagination ---------- */
.pagination { margin-top: 16px; font-size: 13px; }
.pagination a, .pagination span { margin-right: 8px; }

/* ---------- Filters / tables (shared with panel) ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  border: 1px solid var(--border);
  padding: 10px;
  margin-bottom: 14px;
  background-color: var(--box-bg);
  box-shadow: 3px 3px 0 var(--shadow);
}
.filter-bar .form-row { margin-bottom: 0; }
.filter-bar input, .filter-bar select { width: auto; min-width: 130px; max-width: 100%; }

/* Horizontal scroll container for wide tables on small screens. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th, table.data td {
  border: 1px solid var(--border-soft);
  padding: 5px 7px;
  text-align: left;
  vertical-align: top;
}
table.data th { background: var(--code-bg); }
table.data tr:hover td { background: var(--code-bg); }
.nowrap { white-space: nowrap; }

.joke-card video, .rich-content video { max-width: 100%; height: auto; display: block; margin: 8px 0; border: 1px solid var(--border-soft); }
.rich-content iframe { max-width: 100%; }

/* ------------------------------------------------------------------ *
 *  Responsiveness
 * ------------------------------------------------------------------ */
@media (max-width: 620px) {
  #page { padding: 12px; }
  header h1 { font-size: 20px; }
  nav a { display: inline-block; margin: 2px 8px 2px 0; }
  section h2 { font-size: 16px; }
  main { font-size: 13px; }
  .mono-box { padding: 8px; box-shadow: 2px 2px 0 var(--shadow); }
  .filter-bar { gap: 8px; }
  .filter-bar .form-row,
  .filter-bar input,
  .filter-bar select,
  .filter-bar button,
  .filter-bar .btn { width: 100%; min-width: 0; }
  .theme-toggle-bar { top: 6px; }
}

@media (max-width: 420px) {
  ul { margin-left: 16px; }
  .item ul ul { margin-left: 14px; }
}
