/* ── Reset & Globals ── */

*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --card: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(167, 255, 238, 0.3);
  --text: #d4d4d4;
  --text-heading: #f0f0f0;
  --text-muted: #666;
  --accent: #a7ffee;
  --accent-dim: rgba(167, 255, 238, 0.15);
  --flower-yellow: #fce700;
  --danger: #ff6b6b;
  --radius: 12px;
  --max-w: 680px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
  display: block;
  align-items: initial;
  perspective: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}
a:hover {
  opacity: 0.8;
}

/* ── Flower Background ── */

.night {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  transform: none;
  z-index: 0;
  background: radial-gradient(ellipse at bottom, rgba(145, 233, 255, 0.04) 0%, transparent 50%),
              var(--bg) !important;
  filter: none !important;
  will-change: opacity;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  will-change: opacity;
}

.flowers {
  position: fixed !important;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scale(0.55);
  transform-origin: bottom center;
  opacity: 0.1;
  pointer-events: none;
  z-index: 2;
  filter: blur(0.5px);
  will-change: opacity;
}

/* Grow animations: faster (halve durations and delays) */
.flower__leafs { animation-duration: 1s !important; }
.flower__line { animation-duration: 2s !important; }
.grow-ans { animation-duration: 1s !important; }
.flower { --fl-speed: 0.4s !important; }
.flower__line__leaf { animation-delay: 0.4s !important; }

/* Sway animations: much slower so flowers feel calm after growing */
.flower--1 {
  -webkit-animation: moving-flower-1 20s linear infinite !important;
  animation: moving-flower-1 20s linear infinite !important;
}
.flower--2 {
  -webkit-animation: moving-flower-2 24s linear infinite !important;
  animation: moving-flower-2 24s linear infinite !important;
}
.flower__grass--1 {
  -webkit-animation: moving-grass 28s ease-in-out infinite !important;
  animation: moving-grass 28s ease-in-out infinite !important;
}

#page-content {
  position: relative;
  z-index: 3;
  transition: opacity 0.14s ease;
}

/* ── Layout ── */

.blog-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ── Header ── */

.blog-header {
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.blog-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.blog-title a {
  color: inherit;
}

/* ── Name Hero (typing animation) ── */

.name-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 3rem 0 2.5rem;
}

.name-hero__avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.name-hero__inner {
  display: inline-flex;
  align-items: baseline;
  height: calc(clamp(1.8rem, 8vw, 3.2rem) * 1.3 + 5px);
}

.name-hero__text {
  font-size: clamp(1.8rem, 8vw, 3.2rem);
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.01em;
  line-height: 1.3;
  border-bottom: 2px solid transparent;
  padding-bottom: 3px;
  transition: opacity 0.1s, border-color 0.2s, background-color 0.2s;
  white-space: nowrap;
}

.name-hero__text:empty::before {
  content: '\200b';
}

.name-hero__text.ime-composing {
  border-bottom: 2px dotted rgba(167, 255, 238, 0.4);
}

.name-hero__text.ime-candidate {
  border-bottom: 2px solid var(--accent);
  background: rgba(167, 255, 238, 0.06);
  border-radius: 3px;
  padding: 0 6px 3px;
  margin: 0 -6px;
}

.name-hero__cursor {
  display: inline-block;
  width: 3px;
  height: clamp(1.8rem, 8vw, 3.2rem);
  background: var(--accent);
  margin-left: 3px;
  border-radius: 1.5px;
  vertical-align: middle;
  animation: cursor-blink 1.2s ease infinite;
  box-shadow: 0 0 8px rgba(167, 255, 238, 0.25);
  flex-shrink: 0;
}

.name-hero__cursor.typing {
  animation: none;
  opacity: 1;
}

@keyframes cursor-blink {
  0%, 40% { opacity: 1; }
  50%, 90% { opacity: 0; }
  100% { opacity: 1; }
}

/* ── Post Cards (Index) ── */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.post-card {
  display: block;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.post-card:hover {
  opacity: 1;
}
.post-card::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.post-card:first-child {
  padding-top: 0;
}

.post-card__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card__date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.post-card__excerpt {
  font-size: 0.95rem;
  color: var(--text);
  opacity: 0.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (hover: hover) {
  .post-card:hover::after {
    transform: scaleX(1);
  }
  .post-card:hover .post-card__title {
    color: var(--accent);
  }
  .post-card:hover .post-card__excerpt {
    opacity: 0.9;
  }
}

.empty-state {
  text-align: center;
  padding: 4rem 0;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ── Single Post ── */

.post-header {
  margin-bottom: 2.5rem;
}

.post-header__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.post-header__date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-body h1,
.post-body h2,
.post-body h3 {
  color: var(--text-heading);
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.post-body h1 { font-size: 1.6rem; }
.post-body h2 { font-size: 1.35rem; }
.post-body h3 { font-size: 1.15rem; }

.post-body p {
  margin-bottom: 1.25rem;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text);
  opacity: 0.85;
  font-style: italic;
}

.post-body pre {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.post-body code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.88em;
}

.post-body ul,
.post-body ol {
  margin: 1rem 0 1.25rem 1.5rem;
}
.post-body li {
  margin-bottom: 0.3rem;
}

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.back-link:hover {
  color: var(--accent);
  opacity: 1;
}

/* ── Login ── */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 320px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-card__icon {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  opacity: 0.5;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  text-align: center;
  letter-spacing: 0.15em;
}
.login-card input[type="password"]:focus {
  border-color: var(--border-focus);
}
.login-card input[type="password"]::placeholder {
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.login-card__btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(167, 255, 238, 0.15);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.login-card__btn:hover {
  background: rgba(167, 255, 238, 0.2);
  border-color: rgba(167, 255, 238, 0.25);
}

.login-error {
  color: var(--danger);
  text-align: center;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ── Admin ── */

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-bar__links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
}
.admin-bar__links a {
  color: var(--text-muted);
}
.admin-bar__links a:hover {
  color: var(--accent);
  opacity: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(167, 255, 238, 0.12);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn:hover {
  background: rgba(167, 255, 238, 0.2);
  opacity: 1;
}

.btn--danger {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.12);
}
.btn--danger:hover {
  background: rgba(255, 107, 107, 0.18);
}

.btn--sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.admin-post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.admin-post-row__info {
  flex: 1;
  min-width: 0;
}

.admin-post-row__title {
  font-weight: 500;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-post-row__date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.admin-post-row__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.admin-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Editor ── */

.editor-title-input {
  width: 100%;
  padding: 0.75rem 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-heading);
  font-size: 1.75rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: -0.02em;
  outline: none;
  margin-bottom: 1.5rem;
  transition: border-color 0.15s;
}
.editor-title-input:focus {
  border-color: var(--border-focus);
}
.editor-title-input::placeholder {
  color: var(--text-muted);
}

.editor-wrap {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.save-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  align-self: center;
  margin-right: auto;
}

/* Quill dark theme overrides */
.ql-toolbar.ql-snow {
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  background: rgba(255, 255, 255, 0.02);
}

.ql-container.ql-snow {
  border: none !important;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--text);
  min-height: 400px;
}

.ql-editor {
  padding: 1.5rem !important;
  line-height: 1.8;
  min-height: 400px;
}

.ql-editor.ql-blank::before {
  color: var(--text-muted) !important;
  font-style: normal !important;
}

.ql-snow .ql-stroke {
  stroke: var(--text-muted) !important;
}
.ql-snow .ql-fill {
  fill: var(--text-muted) !important;
}
.ql-snow .ql-picker-label {
  color: var(--text-muted) !important;
}
.ql-snow .ql-picker-options {
  background: #1a1a1a !important;
  border-color: var(--border) !important;
  border-radius: 8px !important;
  padding: 0.5rem !important;
}
.ql-snow .ql-picker-item {
  color: var(--text) !important;
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar .ql-active .ql-stroke {
  stroke: var(--accent) !important;
}
.ql-toolbar button:hover .ql-fill,
.ql-toolbar .ql-active .ql-fill {
  fill: var(--accent) !important;
}
.ql-toolbar button:hover,
.ql-toolbar .ql-active {
  color: var(--accent) !important;
}

.ql-editor h1,
.ql-editor h2,
.ql-editor h3 {
  color: var(--text-heading);
}

.ql-editor a {
  color: var(--accent);
}

.ql-editor blockquote {
  border-left-color: var(--accent) !important;
  color: var(--text);
}

.ql-editor pre.ql-syntax {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text) !important;
}

.ql-editor img {
  max-width: 100%;
  border-radius: var(--radius);
}

.ql-snow .ql-tooltip {
  background: #1a1a1a !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4) !important;
}
.ql-snow .ql-tooltip input[type="text"] {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  border-radius: 6px !important;
}

/* ── 404 ── */

.not-found {
  text-align: center;
  padding: 6rem 0;
}
.not-found__code {
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-heading);
  opacity: 0.3;
  margin-bottom: 1rem;
}

/* ── Responsive ── */

@media (max-width: 600px) {
  body {
    font-size: 15px;
  }

  .blog-content {
    padding: 1.5rem 1rem 3rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .name-hero {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 2rem 0 2rem;
  }

  .name-hero__avatar {
    width: 72px;
    height: 72px;
  }

  .post-header__title {
    font-size: 1.45rem;
  }

  .post-body {
    font-size: 1.05rem;
    line-height: 1.85;
  }

  .post-card {
    padding: 1.25rem 0;
    min-height: 48px;
  }

  .post-card__title {
    font-size: 1.1rem;
  }

  .post-card__date,
  .post-header__date {
    font-size: 0.85rem;
  }

  .editor-title-input {
    font-size: 1.25rem;
  }

  .admin-post-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-post-row__actions {
    width: 100%;
  }

  .flowers {
    transform: translateX(-50%) scale(0.35) !important;
  }

  .login-card {
    margin: 0 1rem;
  }

  .back-link {
    font-size: 0.95rem;
  }

  .btn {
    min-height: 44px;
  }

  .btn--sm {
    padding: 0.5rem 0.85rem;
    min-height: 44px;
  }

  .admin-bar__links {
    gap: 0.25rem;
  }

  .admin-bar__links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 380px) {
  .post-header__title {
    font-size: 1.35rem;
  }
}

/* Touch & iOS */
@media (hover: none) {
  .post-card:active { opacity: 0.7; }
  .btn:active { opacity: 0.7; }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 600px) {
  input[type="text"],
  input[type="password"],
  textarea,
  .ql-editor {
    font-size: 16px !important;
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .blog-content {
    padding-bottom: calc(3rem + env(safe-area-inset-bottom));
  }
}
