/* Import preferred code font */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Code:wght@400;500;600&display=swap');
/* --------------------------------------------------
  Base Theme Variables
-------------------------------------------------- */
:root {
  --color-bg: #232a36;
  --color-bg-alt: #2c3544;
  --color-border: #313a48;
  --color-text: #7c8590;
  --color-title: #d3dae2; /* slightly lighter for main headings */
  --color-subtle: #9aa5b1; /* subtle / subheading */
  --color-accent: #f472b6; /* pink accent */
  --color-accent-alt: #a6f472; /* green accent */
  --radius-sm: 4px;
  --transition: 0.2s ease; 
  font-family: 'Fira Code', 'Code Sans Pro', monospace;
  --font-code: 'Google Sans Code', 'Fira Code', monospace;
  --header-h: 56px;
  --footer-h: 52px;
  --header-offset: var(--header-h);
}

/* --------------------------------------------------
  Global Layout & Typography
-------------------------------------------------- */
* { box-sizing: border-box; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  font-family: 'Fira Code', monospace;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--header-offset, var(--header-h)); /* offset for fixed header */
}
/* Home specific background */
.home-bg {
  background:
    linear-gradient(rgba(20,24,32,0.78), rgba(20,24,32,0.82)),
  /* Path fix: CSS file already in assets/, so image is sibling */
  url('background3.png') center/cover no-repeat fixed;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: none; }

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 2rem;
  width: 100%;
  flex: 1; /* allow main pages to push footer to bottom */
}

main.main-content { padding: 2.5rem 0 3rem; }
main.main-content { flex: 1; }

/* --------------------------------------------------
  Header
-------------------------------------------------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 1.25rem;
  height: 56px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.12)),
    radial-gradient(circle at 20% -10%, rgba(96,165,250,0.08), transparent 72%),
    radial-gradient(circle at 85% -5%, rgba(244,114,182,0.035), transparent 60%),
    var(--color-bg);
  border-bottom: 1px solid rgba(49,58,72,0.85);
  box-shadow: 0 3px 6px -4px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04) inset;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 40;
  backdrop-filter: blur(3px);
}
header .header-left { color: var(--color-title); font-size: 1rem; font-weight: 500; white-space: nowrap; }
header .header-square { color: var(--color-accent); margin-left: .25rem; }
header .header-right { display: flex; align-items: center; gap: 1.5rem; }
/* Ensure right-side group stays to the right on wide screens */
@media (min-width: 761px) {
  header .header-right { margin-left: auto; }
}
header .header-menu { display: flex; gap: 1.5rem; font-size: .95rem; }
header .header-menu a { color: var(--color-text); transition: color var(--transition); }
header .header-menu a:hover { color: var(--color-accent); }
header .header-pipe { color: var(--color-border); }
/* Three dots (inline on desktop, repositioned on mobile) */
.header-actions { display:flex; align-items:center; position:static; margin-left:.5rem; z-index:50; }
.header-actions .admin-menu { top:calc(100% + 6px); right:0; }

/* Admin dropdown */
.admin-menu .admin-item:hover { background: var(--color-bg-alt); color: var(--color-title); }
.admin-menu .admin-item + .admin-item { border-top: 1px solid var(--color-border); }
.admin-menu { animation: fadeScale .12s ease; transform-origin: top right; }
@keyframes fadeScale { from { opacity:0; transform: scale(.96); } to { opacity:1; transform: scale(1); } }

.header-icon { background: transparent; border: none; color: var(--color-text); cursor: pointer; padding: .35rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.header-icon:hover { background: var(--color-bg-alt); }
.header-icon svg { width: 22px; height: 22px; stroke: var(--color-text); transition: stroke var(--transition); }
.header-icon:hover svg { stroke: var(--color-accent); }

/* --------------------------------------------------
  Hero / Index
-------------------------------------------------- */
.main-title {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--color-title);
  margin: 0 0 2rem;
  text-align: center;
}
.main-subtitle { text-align: left; margin-top: -1rem; margin-bottom: 2rem; color: var(--color-subtle); font-size: 1rem; }

.social-row { display: flex; justify-content: center; gap: 1.75rem; margin: 0 0 1.5rem; }
.social-row a { color: var(--color-title); font-size: 1.4rem; transition: color var(--transition); }
.social-row a:hover { color: var(--color-accent); }

/* --------------------------------------------------
  Pages Listing
-------------------------------------------------- */
.pages-search-row { display: flex; justify-content: flex-end; margin: 0 0 1.75rem; }
#search-pages { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-title); padding: .55rem .9rem; font-size: .95rem; width: 260px; border-radius: var(--radius-sm); transition: border-color var(--transition), background var(--transition); }
#search-pages:focus { outline: none; border-color: var(--color-accent); background: var(--color-bg-alt); }

.content-list { width: 100%; }
.page-row { padding: 0 0 1.15rem; margin: 0 0 0; border-top: 1px solid var(--color-border); transition: background var(--transition); }
.page-row:hover { background: var(--color-bg-alt); cursor: pointer; }
.page-row:focus { outline: 2px solid var(--color-accent); }
.page-row-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-row-header + .page-subheading { margin-top: .45rem; }

.page-title { font-size: 1.55rem; font-weight: 600; color: var(--color-title); margin: 0; }
.page-subheading { font-size: 1.05rem; margin-top: .35rem; color: var(--color-subtle); font-weight: 400; }
.page-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; font-size: .8rem; min-width: 120px; }
.page-date { color: var(--color-text); font-size: .85rem; }
.page-category { color: var(--color-accent-alt); font-weight: 600; font-size: .75rem; letter-spacing: .5px; text-transform: uppercase; }

/* --------------------------------------------------
  Page Detail
-------------------------------------------------- */
.page-content { max-width: 100%; }
.page-body { margin-top: 1.75rem; font-size: 1rem; color: var(--color-text); }
.page-body img {
  max-width: 100%;
  height: auto;
  max-height: 520px;
  display: block;
  margin: 1.5rem auto;
  object-fit: contain;
}
.page-header-block { padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--color-border); }
.page-body h1, .page-body h2, .page-body h3, .page-body h4 { color: var(--color-title); margin-top: 2.2rem; margin-bottom: .9rem; line-height: 1.25; }
.page-body pre { background: var(--color-bg-alt); padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: auto; }
.page-body code { font-family: var(--font-code); font-size: .9rem; }
.page-body a { color: var(--color-accent); }
.page-body a:hover { text-decoration: underline; }

/* Back button (page detail) */
.back-btn { background:rgba(255,255,255,0.02); border:1px solid var(--color-border); color:var(--color-text); padding:.4rem .7rem; font-size:.65rem; letter-spacing:.6px; text-transform:uppercase; border-radius:4px; cursor:pointer; line-height:1; display:inline-flex; align-items:center; gap:.4rem; font-weight:600; position:relative; }
.back-btn:hover { background:var(--color-bg-alt); color:var(--color-title); border-color:var(--color-accent); }
.back-btn:active { transform:translateY(1px); }

/* Enhanced code styling */
pre, code { font-family: var(--font-code); }
pre { background:#1d232d; border:1px solid #2d3643; border-radius:6px; padding:1rem 1.1rem; font-size:.85rem; line-height:1.5; position:relative; overflow:auto; }
pre:before { content:""; position:absolute; top:0; left:0; height:2px; width:100%; background:linear-gradient(90deg,var(--color-accent),var(--color-accent-alt)); opacity:.35; }
code { background:#2c3544; padding:0 .4em; border-radius:4px; border:1px solid #313a48; font-size:.85em; color:#d7dee6; }
pre code { background:transparent; padding:0; border:none; font-size:inherit; color:#cfd6de; }
/* Editor markdown preview consistency */
#markdown-preview pre { background:#1d232d; }
#markdown-preview code { font-family: var(--font-code); }
/* Subtle selection contrast inside code blocks */
pre ::selection, code::selection { background:rgba(244,114,182,0.25); }

/* --------------------------------------------------
  Gallery
-------------------------------------------------- */
.gallery-tags { display:flex; flex-wrap:wrap; gap:.5rem; margin:-.5rem 0 1.5rem; }
.tag-chip { display:inline-flex; align-items:center; gap:.35rem; padding:.45rem .75rem; border-radius:20px; border:1px solid var(--color-border); color:var(--color-text); font-size:.8rem; letter-spacing:.3px; transition:background var(--transition), border var(--transition), color var(--transition); }
.tag-chip:hover { background:rgba(244,114,182,0.08); border-color:var(--color-accent); color:var(--color-title); }
.tag-chip.active { background:rgba(166,244,114,0.12); border-color:var(--color-accent-alt); color:var(--color-title); }

.gallery-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:1.75rem; width:100%; max-width:960px; margin:0 auto 2.5rem; }
.gallery-item { position:relative; cursor:pointer; }
.gallery-item:focus { outline:2px solid var(--color-accent); outline-offset:4px; }
.gallery-item:focus-visible { outline:2px solid var(--color-accent); outline-offset:4px; }
.gallery-image-wrapper { position:relative; overflow:hidden; border-radius:16px; border:1px solid rgba(49,58,72,0.9); box-shadow:0 18px 32px -18px rgba(0,0,0,0.65); background:var(--color-bg-alt); aspect-ratio: 4 / 3; }
.gallery-image-wrapper img { width:100%; height:100%; object-fit:cover; display:block; transition:transform 0.4s ease; }
.gallery-image-wrapper:hover img { transform:scale(1.06); }

.gallery-overlay { position:absolute; inset:0; display:flex; flex-direction:column; align-items:flex-start; justify-content:flex-start; gap:.45rem; padding:.75rem .85rem; color:var(--color-title); pointer-events:none; border-radius:inherit; background:linear-gradient(160deg, rgba(18,23,31,0.68) 0%, rgba(18,23,31,0.28) 42%, rgba(18,23,31,0) 78%); }
.overlay-top { display:flex; align-items:flex-start; gap:.65rem; align-self:flex-start; background:rgba(18,23,31,0.46); padding:.5rem .7rem; border-radius:14px; backdrop-filter:blur(7px); box-shadow:0 6px 14px -12px rgba(0,0,0,0.55); min-width:200px; max-width:min(360px, 90%); }
.overlay-description { flex:1 1 auto; margin:0; font-size:.94rem; font-weight:500; color:var(--color-title); text-shadow:0 1px 3px rgba(0,0,0,0.28); line-height:1.1; }
.overlay-date { font-size:.73rem; color:var(--color-subtle); text-transform:uppercase; letter-spacing:.55px; white-space:nowrap; }
.overlay-tags { display:flex; flex-wrap:wrap; gap:.3rem; margin-top:.2rem; padding:.28rem .42rem; background:rgba(18,23,31,0.34); border-radius:999px; backdrop-filter:blur(6px); align-self:flex-start; max-width:min(360px, 90%); pointer-events:auto; }
.gallery-tag-link { display:inline-flex; align-items:center; justify-content:center; background:rgba(18,23,31,0.55); color:var(--color-title); padding:.28rem .55rem; border-radius:999px; font-size:.68rem; letter-spacing:.35px; text-transform:uppercase; }
.gallery-tag-link:hover { background:rgba(244,114,182,0.24); color:var(--color-title); }

.gallery-modal { position:fixed; inset:0; display:none; align-items:center; justify-content:center; padding:2rem 1.5rem; background:rgba(10,14,22,0.78); backdrop-filter:blur(14px); z-index:200; }
.gallery-modal.open { display:flex; }
.gallery-modal-dialog { position:relative; width:auto; max-width:min(1040px, calc(100vw - 3rem)); background:rgba(28,34,46,0.72); border:1px solid rgba(255,255,255,0.08); border-radius:20px; box-shadow:0 28px 60px -32px rgba(0,0,0,0.75); overflow:hidden; display:flex; align-items:center; justify-content:center; box-sizing:border-box; }
.gallery-modal-frame { position:relative; }
.gallery-modal-frame img { width:auto; height:auto; max-width:100%; max-height:80vh; object-fit:contain; display:block; background:#0f141c; }
.gallery-modal-layer { position:absolute; inset:0; display:flex; flex-direction:column; justify-content:flex-start; gap:.6rem; padding:1.3rem 1.4rem; pointer-events:none; box-sizing:border-box; }
.gallery-modal-layer .overlay-top { background:rgba(18,23,31,0.52); padding:.65rem .85rem; max-width:420px; min-width:0; }
.gallery-modal-layer .overlay-date { font-size:.78rem; }
.gallery-modal-layer .overlay-description { font-size:1.05rem; }
.gallery-modal-layer .overlay-tags { background:rgba(18,23,31,0.3); padding:.32rem .5rem; max-width:420px; min-width:0; }
.gallery-modal-layer .gallery-tag-link { font-size:.72rem; }
.gallery-modal-tags { display:flex; flex-wrap:wrap; gap:.45rem; }
.gallery-modal-tags span { background:rgba(0,0,0,0.35); color:var(--color-title); padding:.35rem .65rem; border-radius:999px; font-size:.7rem; letter-spacing:.4px; text-transform:uppercase; }
.gallery-modal-close { position:absolute; top:1.1rem; right:1.1rem; background:rgba(12,16,24,0.72); border:1px solid rgba(255,255,255,0.16); color:var(--color-title); border-radius:999px; padding:.45rem .8rem; cursor:pointer; font-size:.85rem; line-height:1; display:inline-flex; align-items:center; justify-content:center; gap:.45rem; transition:background var(--transition), color var(--transition), border var(--transition), transform var(--transition); pointer-events:auto; font-weight:600; text-transform:uppercase; letter-spacing:.5px; z-index:5; }
.gallery-modal-close:hover { background:rgba(244,114,182,0.32); border-color:var(--color-accent); color:var(--color-title); transform:translateY(-1px); }
.gallery-modal-close-icon { font-size:1.35rem; line-height:1; }
.gallery-modal-close-label { font-size:.75rem; letter-spacing:.4px; }

body.gallery-modal-open { overflow:hidden; }

.gallery-sentinel { width:100%; height:8px; margin-top:1rem; }

@media (max-width: 1024px) {
  .gallery-grid { grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); max-width:760px; }
}

@media (max-width: 640px) {
  .gallery-modal { padding:1.5rem .75rem; }
  .gallery-modal-dialog { flex-direction:column; max-width:min(640px, calc(100vw - 1.5rem)); }
  .gallery-modal-frame { width:100%; }
  .gallery-modal-frame img { width:100%; height:auto; max-height:60vh; }
  .gallery-modal-layer { position:static; padding:1rem 1.15rem 1.25rem; gap:.5rem; background:rgba(18,23,31,0.72); border-top:1px solid rgba(255,255,255,0.08); pointer-events:auto; }
  .gallery-modal-layer .overlay-top { width:100%; }
  .gallery-modal-layer .overlay-tags { align-self:stretch; justify-content:flex-start; }
}

@media (max-width: 640px) {
  .gallery-grid { grid-template-columns:minmax(0, 1fr); max-width:420px; }
  .overlay-top { flex-direction:column; align-items:flex-start; gap:.4rem; }
  .overlay-description { max-width:100%; font-size:.9rem; }
  .overlay-date { font-size:.7rem; }
}

/* --------------------------------------------------
  Footer
-------------------------------------------------- */
.footer {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.55)),
    radial-gradient(circle at 50% -40%, rgba(96,165,250,0.10), transparent 70%),
    var(--color-bg);
  border-top: 1px solid rgba(49,58,72,0.85);
  color: var(--color-text);
  text-align: center;
  font-size: .8rem;
  padding: .85rem 0 1.15rem;
  margin-top: auto;
  box-shadow: 0 -3px 6px -4px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04) inset;
  backdrop-filter: blur(2px);
}

.footer .footer-link {
  color: var(--color-accent);
  text-decoration: none;
  margin-left: .35rem;
  letter-spacing: .4px;
}

.footer .footer-link:hover,
.footer .footer-link:focus {
  color: #f8f9fc;
  text-decoration: underline;
}

/* --------------------------------------------------
  Utilities
-------------------------------------------------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
/* Centering utility: middle center within viewport or parent with min-height */
.center-viewport { flex: 1; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.center-parent { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; }
/* Hero variant: centered but visually lowered a bit (golden-ratio feel) */
.hero-viewport { flex:1; min-height:calc(100vh - var(--header-h) - var(--footer-h)); display:flex; flex-direction:column; position:relative; }
/* spacer technique: pushes hero to visual center-lower position without translate jumps */
.hero-viewport:before { content:""; flex:1 0 0; }
/* Reduced after-spacer ratio (was 2) to bring hero block slightly lower while shrinking excess bottom gap */
.hero-viewport:after { content:""; flex:1.25 0 0; } /* ratio controls vertical bias */
.hero-inner { text-align:center; display:flex; flex-direction:column; align-items:center; justify-content:center; margin:0; padding:0; }
/* Optional modifier to tweak ratio */
.hero-offset.heavier:before { flex:1.2 0 0; }
.hero-offset.heavier:after { flex:2 0 0; }

/* --------------------------------------------------
  Responsive
-------------------------------------------------- */
@media (max-width: 760px) {
  header { flex-wrap: wrap; height: auto; padding-top: .55rem; padding-bottom: .55rem; }
  /* Title spans full width; add right padding so dots don't overlap */
  header .header-left { width: 100%; padding-right: 0; }
  /* Center nav on its own line */
  header .header-right { width: 100%; flex-wrap: wrap; justify-content: center; }
  header .header-menu { flex-wrap: wrap; row-gap: .35rem; justify-content: center; width: 100%; }
  /* Hide pipe separator */
  header .header-pipe { display: none; }
  /* Mobile: pin dots top-right inside header */
  header .header-actions { position:absolute; top:6px; right:8px; margin-left:0; }
  header .header-icon { position: static; }
  .page-row-header { flex-direction: column; }
  .page-meta { flex-direction: row; align-items: center; justify-content: flex-start; gap: 1rem; text-align: left; }
  .page-meta { margin-top: .75rem; }
  .pages-search-row { justify-content: flex-start; }
  #search-pages { width: 100%; }
}

@media (max-width: 520px) {
  .container { padding: 0 1rem; }
  .main-title { font-size: 2.2rem; }
  .page-title { font-size: 1.35rem; }
  .page-subheading { font-size: .95rem; }
}
