:root {
  --accent-main: #1f6f78;
  --accent-soft: #2e8a99;
  /* deep teal accent for hover/emphasis (replaces warm orange #e07a5f) */
  --accent-warm: #15575e;
  --paper-bg: #f4f7f8;
  --card-bg: rgba(255, 255, 255, 0.84);
  --card-border: rgba(31, 111, 120, 0.16);
  /* Soft-Flat 3D elevation — light source top-left; each level = near hard + far soft */
  --elev-1: 0 1px 2px rgba(15, 35, 45, .06), 0 1px 3px rgba(15, 35, 45, .04);
  --elev-2: 0 2px 4px rgba(15, 35, 45, .07), 0 4px 12px rgba(15, 35, 45, .05);
  --elev-3: 0 4px 8px rgba(15, 35, 45, .10), 0 12px 28px rgba(15, 35, 45, .09);
  --elev-4: 0 8px 16px rgba(15, 35, 45, .12), 0 20px 44px rgba(15, 35, 45, .12);
  --elev-5: 0 12px 24px rgba(15, 35, 45, .16), 0 28px 60px rgba(15, 35, 45, .16);
  /* inset top highlight: light catching the card's top edge */
  --highlight-top: inset 0 1px 0 rgba(255, 255, 255, .6);
  /* transitions */
  --dur-fast: 150ms; --dur-base: 250ms; --dur-slow: 350ms;
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  /* focus ring */
  --focus-ring: 0 0 0 3px rgba(46, 138, 153, .4);
  /* code block inset (recessed feel) */
  --code-inset: inset 0 1px 3px rgba(0, 0, 0, .06);
  /* press state: collapsed near-hard shadow for active feedback */
  --elev-press: 0 1px 2px rgba(15, 35, 45, .06);
  /* redefine theme card shadows so all .cardHover consumers auto-upgrade */
  --card-box-shadow: var(--elev-2);
  --card-hover-box-shadow: var(--elev-3);
}

[data-theme='dark'] {
  /* dark reversal: black shadow + faint white glow (black-on-black is invisible) */
  --elev-1: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(255, 255, 255, .04);
  --elev-2: 0 2px 4px rgba(0, 0, 0, .45), 0 4px 12px rgba(255, 255, 255, .03);
  --elev-3: 0 4px 8px rgba(0, 0, 0, .5), 0 12px 28px rgba(255, 255, 255, .05);
  --elev-4: 0 8px 16px rgba(0, 0, 0, .55), 0 20px 44px rgba(255, 255, 255, .06);
  --elev-5: 0 12px 24px rgba(0, 0, 0, .6), 0 28px 60px rgba(255, 255, 255, .08);
  --highlight-top: inset 0 1px 0 rgba(255, 255, 255, .08);
  --focus-ring: 0 0 0 3px rgba(122, 194, 205, .5);
  --code-inset: inset 0 1px 3px rgba(0, 0, 0, .3);
  --elev-press: 0 1px 2px rgba(0, 0, 0, .3);
  --card-box-shadow: var(--elev-2);
  --card-hover-box-shadow: var(--elev-3);
  /* fix dark-mode bug: override light card bg so cards aren't white on dark */
  --card-bg: rgba(28, 30, 34, 0.86);
  --card-border: rgba(122, 194, 205, 0.14);
  --paper-bg: #121212;
}

/* T10: dark-mode body + component background overrides (fix white-card bug) */
[data-theme='dark'] body {
  background: radial-gradient(circle at 12% 18%, rgba(46, 138, 153, 0.10), transparent 34%),
              radial-gradient(circle at 88% 10%, rgba(31, 111, 120, 0.10), transparent 30%),
              #121212;
}

[data-theme='dark'] #post blockquote,
[data-theme='dark'] #page blockquote {
  background: rgba(40, 44, 50, 0.7);
}

[data-theme='dark'] #post .wl-editor {
  background: rgba(40, 44, 50, 0.6);
}

[data-theme='dark'] #page-header.nav-fixed #nav,
[data-theme='dark'] #page-header.not-top-img #nav {
  background: rgba(18, 18, 18, 0.85);
}

[data-theme='dark'] #footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* a11y: kill all motion for reduced-motion users (only !important exemption) */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* a11y: visible focus ring on keyboard focus */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

body {
  background: radial-gradient(circle at 12% 18%, rgba(224, 122, 95, 0.14), transparent 34%),
              radial-gradient(circle at 88% 10%, rgba(46, 138, 153, 0.14), transparent 30%),
              linear-gradient(180deg, #fbfcfc 0%, var(--paper-bg) 100%);
}

#page-header {
  background-image: linear-gradient(135deg, rgba(31, 111, 120, 0.92), rgba(46, 138, 153, 0.82));
}

#page-header::before {
  background: linear-gradient(180deg, rgba(7, 18, 24, 0.08) 0%, rgba(7, 18, 24, 0.26) 100%);
}

#site-info .site-title {
  letter-spacing: 0.06em;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

#site-info .site-subtitle {
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  opacity: 0.96;
}

#nav #blog-info .nav-site-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(4px);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#nav #blog-info .nav-site-title:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-1);
}

#nav #blog-info .site-icon {
  width: 28px;
  height: 28px;
  margin-right: 0;
  padding: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--elev-1);
}

#nav #blog-info .site-name {
  letter-spacing: 0.04em;
  line-height: 1;
}

#page-header.not-top-img #nav #blog-info .nav-site-title,
#page-header.nav-fixed #nav #blog-info .nav-site-title {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(31, 111, 120, 0.2);
}

#page-header.not-top-img #nav #blog-info .site-icon,
#page-header.nav-fixed #nav #blog-info .site-icon {
  background: rgba(31, 111, 120, 0.08);
  box-shadow: none;
}

/* T4: nav pill micro-lift + highlight */
#nav #blog-info .nav-site-title {
  box-shadow: var(--elev-1), var(--highlight-top);
}

/* T4: floating glass nav when fixed/scrolled — deepen blur + bottom shadow */
#page-header.nav-fixed #nav,
#page-header.not-top-img #nav {
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--elev-4);
}

/* T4: hero site-title readability + scroll-down breathing */
#site-info .site-title {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.25);
}

#scroll-down .scroll-down-effects {
  animation: sf3d-breathe 2.4s ease-in-out infinite;
}

@keyframes sf3d-breathe {
  0%, 100% { opacity: 0.6; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(4px); }
}

@media (prefers-reduced-motion: no-preference) {
  #scroll-down .scroll-down-effects { animation: sf3d-breathe 2.4s ease-in-out infinite; }
}

.layout > div:first-child:not(.recent-posts) {
  border-radius: 16px;
}

.card-widget,
.layout > div:first-child:not(.recent-posts),
#recent-posts > .recent-post-item,
#post,
#page,
#archive {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--elev-2), var(--highlight-top);
  backdrop-filter: blur(6px);
}

#recent-posts > .recent-post-item {
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

#recent-posts > .recent-post-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--elev-3), var(--highlight-top);
}

/* T6: sidebar cards — hover lift + author avatar disc + card-info-btn press */
.card-widget {
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.card-widget:hover {
  box-shadow: var(--elev-3), var(--highlight-top);
}

#aside-content .card-info .avatar-img {
  box-shadow: var(--elev-2), var(--highlight-top);
  border-radius: 50%;
}

#card-info-btn {
  box-shadow: var(--elev-1), var(--highlight-top);
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

#card-info-btn:hover {
  box-shadow: var(--elev-2);
}

#card-info-btn:active {
  transform: translateY(1px);
  box-shadow: var(--elev-press);
}

/* tag cloud / archive list items hover micro-lift */
#aside-content .card-tag-cloud a:hover,
#aside-content .card-archives a:hover,
#aside-content .card-categories a:hover {
  transform: translateY(-1px);
  transition: transform var(--dur-fast) var(--ease-out);
}

/* T7: post page typography — blockquote raise, code inset, tag pill, copyright, toc */
#post blockquote,
#page blockquote {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--elev-1);
  border-radius: 8px;
}

#post figure.highlight,
#post pre,
#page figure.highlight,
#page pre {
  box-shadow: var(--code-inset);
}

#post .post-meta__tags,
#page .post-meta__tags {
  box-shadow: var(--elev-1);
}

#post .post-copyright,
#page .post-copyright {
  transition: box-shadow var(--dur-base) var(--ease-out);
}

#post .post-copyright:hover,
#page .post-copyright:hover {
  box-shadow: var(--elev-2);
}

#card-toc {
  box-shadow: var(--elev-2), var(--highlight-top);
}

#aside-content .card-widget .card-content a:hover,
#post a:hover,
#page a:hover {
  color: var(--accent-warm);
}

#footer {
  background: linear-gradient(120deg, rgba(31, 111, 120, 0.95), rgba(46, 138, 153, 0.9));
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

#footer-wrap,
#footer-wrap a {
  color: #f5fbfd;
}

/* T8: pagination hover micro-lift (page items inherit elev-2 via .cardHover token) */
.layout .pagination > *:not(.space):hover {
  transform: translateY(-2px);
  transition: transform var(--dur-fast) var(--ease-out);
}

/* T8: rightside buttons + go-up — elevate + press feedback */
#rightside > div > button,
#rightside > div > a,
#go-up {
  box-shadow: var(--elev-2), var(--highlight-top);
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

#rightside > div > button:hover,
#rightside > div > a:hover,
#go-up:hover {
  box-shadow: var(--elev-3);
}

#rightside > div > button:active,
#rightside > div > a:active,
#go-up:active {
  transform: translateY(1px);
  box-shadow: var(--elev-press);
}

/* T9: standalone pages — tag cloud pills, category list, flink cards, 404 */
.tag-cloud-list a {
  box-shadow: var(--elev-1), var(--highlight-top);
}

.category-list a {
  box-shadow: var(--elev-1), var(--highlight-top);
}

.flink-item-card {
  box-shadow: var(--elev-2), var(--highlight-top);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.flink-item-card:hover {
  box-shadow: var(--elev-3);
  transform: translateY(-2px);
}

.error-img {
  box-shadow: var(--elev-2), var(--highlight-top);
}

.page .aplayer,
.post .aplayer {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--elev-2);
}

@media (max-width: 768px) {
  #nav #blog-info .nav-site-title {
    gap: 8px;
    padding: 5px 10px;
  }

  #nav #blog-info .site-icon {
    width: 24px;
    height: 24px;
    padding: 2px;
  }

  #site-info .site-title {
    font-size: 1.9rem;
  }

  #site-info .site-subtitle {
    font-size: 0.92rem;
  }

  /* T11: mobile safeguards — touch has no hover, lifts degrade naturally;
     keep cards within viewport (no horizontal overflow from shadows) */
  #recent-posts > .recent-post-item,
  .card-widget,
  #post,
  #page,
  #archive {
    box-shadow: var(--elev-1);
  }

  #rightside > div > button,
  #rightside > div > a,
  #go-up {
    box-shadow: var(--elev-1);
  }
}

/* ============================================
   Waline comment section — var-first theming
   Redefine Waline v3.7.1 --waline-* CSS variables so the runtime
   picks up the teal palette everywhere (cleaner than per-class overrides).
   Structure classes below cover only what the variables cannot reach.
   ============================================ */

#waline-wrap {
  --waline-theme-color: #1f6f78;
  --waline-active-color: #2e8a99;
  --waline-bg-color: var(--card-bg);
  --waline-bg-color-light: rgba(255, 255, 255, 0.5);
  --waline-border-color: rgba(31, 111, 120, 0.16);
  --waline-color: var(--font-color);
  --waline-box-shadow: var(--elev-2);
  --waline-radius: 10px;
}

[data-theme='dark'] #waline-wrap {
  --waline-bg-color: rgba(28, 30, 34, 0.86);
  --waline-bg-color-light: rgba(28, 30, 34, 0.6);
  --waline-border-color: rgba(46, 138, 153, 0.25);
}

.wl-panel {
  border-radius: 12px;
  overflow: hidden;
}

.wl-editor:focus,
.wl-input:focus {
  box-shadow: 0 0 0 3px rgba(46, 138, 153, 0.12);
}

.wl-btn.primary {
  background: linear-gradient(135deg, #1f6f78, #2e8a99);
  color: #fff;
  border: none;
}

.wl-empty {
  color: #858585;
}

/* ============================================
   Body font-weight — light 450 / dark 380
   No font-synthesis set (keep default; none would break bold synthesis).
   Headings keep their own bold; only body text affected.
   ============================================ */
body {
  font-weight: 450;
}

[data-theme='dark'] body {
  font-weight: 380;
}

/* ============================================
   Dark-mode Waline editor/button + aside link colors
   Variables already set in T1; these cover class-layer + link color.
   ============================================ */
[data-theme='dark'] #waline-wrap .wl-editor {
  background: rgba(28, 30, 34, 0.6);
  border-color: rgba(46, 138, 153, 0.25);
  color: rgba(255, 255, 255, 0.85);
}

[data-theme='dark'] #waline-wrap .wl-btn.primary {
  background: linear-gradient(135deg, #2e8a99, #3fa5b3);
}

[data-theme='dark'] #aside-content a,
[data-theme='dark'] .card-widget a {
  color: #4fb8c4;
}

/* ============================================
   Login user info layout — avatar left shift + single-line nick
   Waline v3.7.1 DOM: .wl-login-info > .wl-avatar + .wl-login-nick
   (NOT .wl-user — that's the comment-list author area)
   ============================================ */
#waline-wrap .wl-login-info {
  display: flex;
  flex-direction: column; /* avatar on top, nickname below */
  align-items: center;
  max-width: none; /* keep: lets the nick fit ~10 letters */
  gap: 2px;
  text-align: center;
}

/* Avatar: centered (no horizontal shift needed in vertical layout) */
#waline-wrap .wl-login-info .wl-avatar {
  flex-shrink: 0;
}

/* Nickname: single line, fits ~10 latin letters, ellipsis on overflow.
   MUST use direct-child > so it hits ONLY the nickname text link,
   NOT the avatar-wrapping a.wl-login-nick inside .wl-avatar. */
#waline-wrap .wl-login-info > .wl-login-nick {
  display: block;
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  word-break: normal; /* override Waline's break-all */
}

/* ============================================
   Comment editor definition — give the textarea a clear bordered look
   !important needed: Waline's own CSS loads dynamically AFTER
   personal-theme.css and overrides these at equal specificity.
   ============================================ */
#waline-wrap .wl-editor {
  border: 1.5px solid rgba(31, 111, 120, 0.15) !important;
  background: rgba(255, 255, 255, 0.7) !important;
  border-radius: 10px !important;
  padding: 10px 12px;
}
#waline-wrap .wl-editor:focus {
  border-color: #2e8a99 !important;
  box-shadow: 0 0 0 3px rgba(46, 138, 153, 0.12) !important;
}

/* Login button — make it visually prominent with brand color */
#waline-wrap .wl-btn {
  background: linear-gradient(135deg, #1f6f78, #2e8a99) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 6px 16px !important;
  font-weight: 500;
}
#waline-wrap .wl-btn:hover {
  box-shadow: 0 2px 8px rgba(31, 111, 120, 0.3);
}

/* Footer / bottom toolbar — subtle separator */
#waline-wrap .wl-footer {
  border-top: 1px solid rgba(31, 111, 120, 0.08);
  padding-top: 8px;
  margin-top: 8px;
}

/* Sort bar styling */
#waline-wrap .wl-tab-wrapper a {
  color: #858585 !important;
  transition: color 0.2s;
}
#waline-wrap .wl-tab-wrapper a.active,
#waline-wrap .wl-tab-wrapper a:hover {
  color: #1f6f78 !important;
}

/* Dark mode adjustments for the editor */
[data-theme='dark'] #waline-wrap .wl-editor {
  background: rgba(28, 30, 34, 0.6) !important;
  border-color: rgba(46, 138, 153, 0.25) !important;
}
[data-theme='dark'] #waline-wrap .wl-editor:focus {
  border-color: #2e8a99 !important;
}
[data-theme='dark'] #waline-wrap .wl-btn {
  background: linear-gradient(135deg, #2e8a99, #3fa5b3) !important;
}
[data-theme='dark'] #waline-wrap .wl-footer {
  border-top-color: rgba(46, 138, 153, 0.12);
}

/* ============================================
   Mobile social icons — white circular micro-3D buttons
   #site_social_icons only renders at max-width 768px (theme head.styl),
   so this never affects desktop. The two !important below are the ONLY
   allowed ones: they override the theme's link-hover color shift to white.
   ============================================ */
#page-header #site_social_icons {
  margin-top: 12px;
}

#site_social_icons .social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #24292e !important;
  font-size: 1.25em;
  box-shadow: var(--elev-1), var(--highlight-top);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

#site_social_icons .social-icon:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-2);
}

#site_social_icons .social-icon .fab.fa-envelope {
  color: #4a7dbe !important;
}
