/* ============================================================
   Dervic.Dev — Portfolio (flat-file PHP)
   Fonts: JetBrains Mono (vsebina), Caveat (script brand)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;600&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --card: #fafafa;
  --border: #e5e5e5;
  --fg: #111111;
  --muted: #6b6b6b;
  --btn: #2a2a2a;
  --btn-fg: #ffffff;
  --highlight: #e8e8e8;
  --code-bg: #f0f0f0;
  --shadow: 0 10px 40px rgba(0,0,0,.08);
}
html[data-theme="dark"] {
  --bg: #0b0b0b;
  --bg-soft: #101010;
  --card: #131313;
  --border: #1f1f1f;
  --fg: #f2f2f2;
  --muted: #9c9c9c;
  --btn: #2c2c2c;
  --btn-fg: #f2f2f2;
  --highlight: #e6e6e6;
  --code-bg: #181818;
  --shadow: 0 10px 40px rgba(0,0,0,.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }
h1, h2, h3, h4, p, li { overflow-wrap: anywhere; }
body {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1640px; margin: 0 auto; padding: 0 40px; }
section { border-top: 1px solid var(--border); }
section:first-of-type { border-top: none; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; letter-spacing: 0; }
h1 { font-size: clamp(2rem, 4.4vw, 3.5rem); font-weight: 500; letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.script { font-family: 'Caveat', cursive; font-weight: 600; }
.label { font-size: .72rem; letter-spacing: .35em; color: var(--muted); text-transform: uppercase; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 80px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.brand .script { font-size: 1.4rem; }
.main-nav { display: flex; gap: 40px; align-items: center; margin-left: auto; }
.main-nav a { font-size: .85rem; color: var(--muted); transition: color .2s; }
.main-nav a:hover { color: var(--fg); }
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: 46px; }
@media (max-width: 940px) { .header-actions { margin-left: 0; } }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: var(--fg); cursor: pointer; padding: 6px; line-height: 1; }
.theme-toggle svg { display: block; }
.mobile-toggle { display: none; }
.hamburger { display: none; background: none; border: none; color: var(--fg); cursor: pointer; padding: 8px; z-index: 210; }
.hamburger svg { width: 26px; height: 26px; display: block; }
.mobile-menu {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: var(--bg); padding: 110px 34px 40px;
  flex-direction: column; gap: 6px;
}
.mobile-menu.open { display: flex; }
.mobile-menu a { font-size: 1.15rem; font-weight: 600; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mobile-menu .btn { margin-top: 22px; justify-content: center; }
@media (max-width: 940px) {
  .container { padding: 0 20px; }
  .main-nav, .header-actions .btn, .header-actions .theme-toggle:not(.mobile-toggle) { display: none; }
  .mobile-toggle { display: inline-flex; }
  .hamburger { display: block; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 8px;
  background: var(--btn); color: var(--btn-fg);
  font: inherit; font-size: .85rem; font-weight: 500;
  border: 1px solid var(--border); cursor: pointer; transition: opacity .2s, transform .15s;
}
.btn:hover { opacity: .85; transform: translateY(-1px); }
.btn.text { background: transparent; border-color: transparent; color: var(--fg); padding-left: 10px; padding-right: 10px; }

/* ---------- Hero ---------- */
.hero { padding: 120px 0 150px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 60px; align-items: center; }
.hero .script { font-size: 1.55rem; color: var(--fg); }
.hero h1 { margin: 16px 0 24px; }
.hero p { color: var(--muted); max-width: 52ch; }
.hero .actions { margin-top: 36px; display: flex; gap: 8px; align-items: center; }
.hero-img img { width: 100%; max-width: 560px; margin-left: auto; }
@media (max-width: 940px) {
  .hero { padding: 60px 0 80px; text-align: left; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-img img { margin: 0; max-width: 100%; }
  .hero .actions { flex-direction: column; align-items: stretch; }
  .hero .actions .btn { justify-content: center; }
  .hero .actions .btn.text { justify-content: center; }
}

/* ---------- Section head ---------- */
.sec { padding: 110px 0; }
.sec-head { text-align: center; max-width: 680px; margin: 0 auto 60px; }
.sec-head h2 { margin: 16px 0; }
.sec-head p { color: var(--muted); font-size: .9rem; }

/* ---------- Portfolio ---------- */
.portfolio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.portfolio-col { display: grid; gap: 22px; align-content: start; }
.p-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; transition: box-shadow .25s, transform .25s; display: block; }
.p-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.p-card .p-body { padding: 24px 26px; }
.p-card .p-body h3 { margin-bottom: 6px; }
.p-card .p-body p { color: var(--muted); font-size: .82rem; }
.p-card img { width: 100%; object-fit: cover; }
.p-card.tall img { height: 470px; }
.p-card.normal img { height: 250px; }
@media (max-width: 940px) {
  .portfolio-grid { grid-template-columns: 1fr; }
  .p-card.tall img { height: 300px; }
}

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; align-items: center; }
.about-grid img { width: 100%; }
.about-body h2 { margin: 16px 0 22px; }
.about-body p { color: var(--muted); font-size: .88rem; margin-bottom: 16px; }
.about-body .actions { margin-top: 28px; display: flex; gap: 8px; }
@media (max-width: 940px) {
  .about-grid { grid-template-columns: 1fr; gap: 44px; }
  .about-body .actions { flex-direction: column; align-items: stretch; }
  .about-body .actions .btn { justify-content: center; }
}

/* ---------- Testimonials ---------- */
.t-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.t-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 32px; }
.t-card blockquote { font-size: .88rem; color: var(--fg); line-height: 1.9; }
.t-card strong { background: var(--highlight); color: #111; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.t-author { display: flex; gap: 14px; align-items: center; margin-top: 26px; }
.t-author .avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--highlight); color: #111; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; overflow: hidden; flex-shrink: 0; }
.t-author .avatar img { width: 100%; height: 100%; object-fit: cover; }
.t-author .who { font-size: .85rem; font-weight: 600; }
.t-author .who .role { color: var(--muted); font-size: .78rem; font-weight: 400; }
@media (max-width: 940px) { .t-grid { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 80px; align-items: start; }
.contact-grid h2 { margin: 16px 0 20px; }
.contact-grid > div > p { color: var(--muted); font-size: .88rem; max-width: 46ch; }
.contact-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 44px; display: grid; gap: 32px; }
.contact-card .row { display: grid; gap: 4px; }
.contact-card .row .lbl { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }
.contact-card .row .lbl svg { width: 18px; height: 18px; stroke: var(--fg); }
.contact-card .row a { color: var(--muted); text-decoration: underline; font-size: .88rem; margin-left: 28px; }
.contact-card .row a:hover { color: var(--fg); }
.contact-form.contact-card { gap: 14px; padding: 30px; }
.contact-form { display: grid; gap: 14px; }
.contact-left h2 { margin: 16px 0 20px; }
.contact-left p { color: var(--muted); font-size: .88rem; max-width: 44ch; }
.contact-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 940px) {
  .contact-grid { grid-template-columns: 1fr; gap: 40px; }
}

input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font: inherit; font-size: .85rem;
}
input:focus, textarea:focus { outline: 2px solid var(--muted); outline-offset: 1px; }
label { display: block; font-size: .78rem; font-weight: 600; margin-bottom: 6px; }

/* ---------- FAQ ---------- */
.faq-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 60px; margin-bottom: 60px; }
.faq-head h2 { flex-shrink: 1; max-width: 460px; font-weight: 500; }
.faq-head .side { max-width: 520px; display: grid; gap: 24px; justify-items: end; text-align: left; }
.faq-head .side p { color: var(--muted); font-size: .84rem; max-width: 46ch; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px 70px; }
.faq-item h3 { font-size: .92rem; margin-bottom: 10px; }
.faq-item p { color: var(--muted); font-size: .82rem; }
@media (max-width: 940px) { .faq-grid { grid-template-columns: 1fr; gap: 36px; } .faq-head { flex-direction: column; align-items: flex-start; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 48px 0 30px; }
.footer-top { display: flex; justify-content: space-between; align-items: center; gap: 30px; flex-wrap: wrap; padding-bottom: 36px; border-bottom: 1px solid var(--border); }
.footer-top .brand .script { font-size: 1.2rem; }
.footer-nav { display: flex; gap: 30px; }
.footer-nav a { font-size: .75rem; color: var(--muted); }
.footer-nav a:hover { color: var(--fg); }
.socials { display: flex; gap: 14px; }
.socials a { color: var(--fg); opacity: .8; }
.socials a:hover { opacity: 1; }
.socials svg { width: 16px; height: 16px; fill: currentColor; }
.soc-letter { display: inline-flex; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 50%; align-items: center; justify-content: center; font-size: .66rem; font-weight: 700; }
.socials a { display: inline-flex; align-items: center; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: nowrap; padding-top: 24px; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.footer-bottom .legal { display: flex; gap: 24px; }
.footer-bottom .legal a:hover { color: var(--fg); }
@media (max-width: 940px) {
  .footer-top { flex-direction: column; align-items: center; text-align: center; gap: 22px; }
  .footer-nav { flex-direction: column; gap: 12px; align-items: center; }
  .footer-bottom { flex-direction: column; align-items: center; text-align: center; flex-wrap: wrap; white-space: normal; }
  .footer-bottom .legal { flex-direction: column; gap: 12px; align-items: center; }
}

/* ---------- Legal page ---------- */
.legal { padding-top: 90px; padding-bottom: 90px; max-width: calc(780px + 80px); margin: 0 auto; overflow-wrap: break-word; word-break: break-word; }
.legal h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 500; letter-spacing: -.02em; margin-bottom: 14px; }
.legal .updated { color: var(--muted); font-size: .85rem; margin-bottom: 34px; }
.legal .intro { color: var(--muted); font-size: .95rem; line-height: 1.8; margin-bottom: 50px; }
.legal h2 { font-size: 1.35rem; font-weight: 600; margin: 52px 0 18px; }
.legal p { color: var(--muted); font-size: .92rem; line-height: 1.8; margin-bottom: 16px; }
.legal ul { margin: 0 0 18px 24px; color: var(--muted); font-size: .92rem; line-height: 1.8; }
.legal li { margin-bottom: 12px; padding-left: 4px; }
.legal a { color: var(--fg); }
.legal .contact-block { margin-top: 60px; padding-top: 36px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .legal { padding-top: 60px; padding-bottom: 60px; }
  .legal h2 { font-size: 1.15rem; margin: 40px 0 14px; }
  .legal p, .legal ul { font-size: .88rem; }
}

/* ---------- Blog ---------- */
.blog-head { text-align: center; padding-top: 100px; padding-bottom: 64px; overflow-wrap: break-word; }
@media (max-width: 640px) { .blog-head { padding-top: 64px; padding-bottom: 44px; } }
.blog-head h1 { margin: 16px 0 18px; font-size: clamp(2rem, 4vw, 3rem); }
.blog-head p { color: var(--muted); max-width: 56ch; margin: 0 auto; font-size: .9rem; }
.blog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px; padding-bottom: 110px; }
.b-card { display: block; }
.b-card h3 { margin-bottom: 8px; font-size: .95rem; }
.b-card p { color: var(--muted); font-size: .8rem; margin-bottom: 16px; }
.b-card img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); transition: transform .25s, box-shadow .25s; }
.b-card:hover img { transform: translateY(-3px); box-shadow: var(--shadow); }
@media (max-width: 940px) { .blog-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .blog-grid { grid-template-columns: 1fr; gap: 44px; padding-bottom: 70px; } }

/* ---------- Single post ---------- */
.post-head { text-align: center; padding: 90px 24px 56px; max-width: 820px; margin: 0 auto; }
.post-head h1 { font-size: clamp(1.8rem, 3.6vw, 2.7rem); font-weight: 600; margin-bottom: 22px; }
.post-head .sub { color: var(--muted); font-size: .9rem; margin-bottom: 26px; max-width: 56ch; margin-left: auto; margin-right: auto; }
.post-head .meta { color: var(--muted); font-size: .82rem; }
.post-container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 64px; padding-bottom: 90px; }
.post-layout article { min-width: 0; }
.post-body { overflow-wrap: break-word; word-break: break-word; max-width: 100%; }
.post-body .code-block { max-width: 100%; box-sizing: border-box; }
.post-hero { border-radius: 12px; margin-bottom: 44px; width: 100%; }
.post-body h2 { font-size: 1.35rem; font-weight: 600; margin: 48px 0 18px; }
.post-body h3 { font-size: 1.12rem; font-weight: 600; margin: 36px 0 14px; }
.post-body h4 { margin: 28px 0 12px; }
.post-body p { color: var(--muted); font-size: .9rem; margin-bottom: 16px; line-height: 1.8; }
.post-body ul { margin: 0 0 18px 22px; color: var(--muted); font-size: .9rem; line-height: 1.8; }
.post-body li { margin-bottom: 8px; }
.post-body blockquote { border-left: 3px solid var(--border); padding: 6px 0 6px 20px; color: var(--fg); font-style: italic; margin: 24px 0; }
.post-body .code-block { background: #f6f8fa; border: 1px solid var(--border); border-radius: 10px; padding: 22px; overflow-x: auto; margin: 24px 0; }
html[data-theme="dark"] .post-body .code-block { background: #2d2d2d; }
.post-body .code-block code { font-size: .82rem; line-height: 1.7; background: transparent !important; padding: 0; white-space: pre; text-shadow: none; font-family: 'JetBrains Mono', monospace; }
.post-body .inline-code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: .82em; }
.toc { position: sticky; top: 120px; align-self: start; }
.toc h4 { font-size: .85rem; font-weight: 500; margin-bottom: 20px; color: var(--fg); }
.toc a { display: block; color: var(--muted); font-size: .84rem; padding: 9px 0; }
.toc a:hover { color: var(--fg); }
@media (max-width: 940px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .post-head { padding: 60px 24px 40px; }
  .post-container { padding: 0 20px; }
}

/* ---------- 404 ---------- */
.err-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.err-page h1 { font-size: 5rem; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-body { background: var(--bg); }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 34px; }
.login-box h1 { font-size: 1.3rem; text-align: center; margin-bottom: 6px; }
.alert { padding: 12px 14px; border-radius: 8px; font-size: .82rem; margin-bottom: 16px; border: 1px solid; }
.alert-error { border-color: #ef4444; color: #ef4444; }
.alert-ok { border-color: #22c55e; color: #22c55e; }
.field { margin-bottom: 16px; }

.admin-layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-sidebar { border-right: 1px solid var(--border); padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.admin-sidebar .brand { margin-bottom: 30px; padding: 0 8px; }
.admin-nav { list-style: none; display: grid; gap: 4px; }
.admin-nav a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--muted); font-size: .85rem; }
.admin-nav a:hover { color: var(--fg); background: var(--bg-soft); }
.admin-nav a.active { color: var(--fg); background: var(--bg-soft); font-weight: 600; }
.admin-main { padding: 30px 34px; }
.admin-main h1 { font-size: 1.4rem; margin: 0; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 14px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .75rem; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 22px; }
.panel h2 { font-size: 1rem; margin-bottom: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .75rem; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .72rem; border: 1px solid var(--border); }
.pill.pub { border-color: #22c55e; color: #22c55e; }
.pill.draft { color: var(--muted); }
.btn.sm { padding: 7px 14px; font-size: .78rem; }
.btn.danger { border-color: #ef4444; color: #ef4444; background: transparent; }
.btn.ghost { background: transparent; color: var(--fg); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.img-preview { width: 120px; height: 75px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; }
.hint { color: var(--muted); font-size: .74rem; margin-top: 5px; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.file-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.file-card img { width: 100%; height: 90px; object-fit: cover; }
.file-card .fn { font-size: .68rem; padding: 8px; word-break: break-all; color: var(--muted); }
.file-card .row-actions { padding: 0 8px 8px; }

details.acc { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: var(--card); }
details.acc summary { cursor: pointer; font-weight: 600; font-size: .88rem; }
details.acc .acc-inner { margin-top: 16px; }

.admin-side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; padding: 0 8px; }
.admin-sidebar .brand { margin-bottom: 0; }
.admin-sidebar .hamburger { display: none; }
@media (max-width: 1000px) {
  .admin-layout { display: block; min-height: 100vh; }
  .admin-sidebar { position: sticky; top: 0; height: auto; z-index: 150; background: var(--bg); border-right: none; border-bottom: 1px solid var(--border); padding: 16px 18px; }
  .admin-side-head { margin-bottom: 0; padding: 0; }
  .admin-sidebar .hamburger { display: block; }
  .admin-nav { display: none; }
  .admin-main { padding: 22px 16px; max-width: 100%; overflow-x: hidden; }
  .admin-topbar h1 { font-size: 1.25rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 1.3rem; }
  .panel { padding: 16px; }
  .panel, .stat { max-width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
  .table-wrap .table { min-width: 620px; }
  .grid2 { grid-template-columns: 1fr; }
  .contact-form .grid2 { grid-template-columns: 1fr; }
}
