/* blog sticker 模版。顏色、框線、陰影來自 /shared/v1/tokens.css */

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

.back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--ui-text-sub);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back:hover {
  color: var(--ui-text);
}

/* 頁首 */
.intro {
  padding-top: 32px;
  padding-bottom: 8px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(32px, 5.5vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.intro p {
  margin: 12px 0 0;
  max-width: 36em;
  color: var(--ui-text-sub);
  font-size: 16px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 8px;
  margin-top: 22px;
}

.tag-sm {
  padding: 0 8px;
  font-size: 11.5px;
  box-shadow: none;
}

/* 年份分組 */
.year {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0 32px;
  margin-top: 52px;
}

.year-num {
  position: sticky;
  top: 16px;
  align-self: start;
  margin: 0;
  font-family: "Space Grotesk", var(--ui-font);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ui-text);
  text-shadow: 4px 4px 0 var(--ui-accent);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rows li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 4px 16px;
  padding: 14px 0;
  border-top: 2px dashed color-mix(in srgb, var(--ui-line) 18%, transparent);
}

:root[data-theme="dark"] .rows li {
  border-top-color: color-mix(in srgb, var(--ui-text) 14%, transparent);
}

.rows li:first-child {
  border-top: 0;
}

.row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.row time {
  padding-top: 2px;
  color: var(--ui-text-sub);
  font-family: "Space Grotesk", var(--ui-font);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.row-title {
  justify-self: start;
  width: fit-content;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: underline 4px transparent;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.12s ease;
}

.row:hover .row-title,
.row:focus-visible .row-title {
  text-decoration-color: var(--ui-pink);
}

.row-excerpt {
  color: var(--ui-text-sub);
  font-size: 14px;
  line-height: 1.6;
}

.row-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 3px;
  max-width: 260px;
}

/* 標籤頁 */
.tag-section {
  margin-top: 44px;
  scroll-margin-top: 20px;
}

.tag-section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 22px;
}

.tag-section h2 small {
  color: var(--ui-text-sub);
  font-size: 14px;
  font-weight: 500;
}

.tag-dot {
  width: 16px;
  height: 16px;
  border: var(--ui-border);
  border-radius: 5px;
  background: var(--ui-accent);
}

.tag-section:target h2 {
  text-decoration: underline 4px var(--ui-yellow);
  text-underline-offset: 6px;
}

/* 文章 */
.post {
  max-width: calc(68ch + 48px);
  padding-top: 24px;
}

.post-head h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.meta {
  margin: 12px 0 0;
  color: var(--ui-text-sub);
  font-size: 14px;
  font-weight: 500;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.prose {
  margin-top: 36px;
  font-size: 16.5px;
  line-height: 1.85;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin: 0 0 1.1em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.35;
  scroll-margin-top: 20px;
}

.prose h1,
.prose h2 {
  position: relative;
  margin: 2.2em 0 0.7em;
  padding-left: 24px;
  font-size: 1.45em;
}

.prose h1::before,
.prose h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.32em;
  width: 13px;
  height: 13px;
  border: var(--ui-border);
  border-radius: 4px;
  background: var(--ui-yellow);
}

.prose h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.15em;
}

.prose h4 {
  margin: 1.5em 0 0.4em;
  font-size: 1em;
}

.prose a {
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ui-sky);
}

.prose a:hover {
  text-decoration-color: var(--ui-pink);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.25em;
}

.prose blockquote {
  padding: 4px 0 4px 18px;
  border-left: 4px solid var(--ui-lilac);
  color: var(--ui-text-sub);
}

.prose hr {
  margin: 2.4em auto;
  width: 64px;
  border: 0;
  border-top: 3px dotted var(--ui-text-sub);
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em 0;
  border: var(--ui-border);
  border-radius: 12px;
  box-shadow: 5px 5px 0 var(--ui-line);
}

.prose :not(pre) > code {
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ui-yellow) 28%, var(--ui-surface));
  font-size: 0.88em;
}

:root[data-theme="dark"] .prose :not(pre) > code {
  background: var(--ui-yellow-deep);
}

/* 表格 */
.table-wrap {
  margin: 1.6em 0;
  overflow-x: auto;
  border: var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  box-shadow: 5px 5px 0 var(--ui-lilac), 5px 5px 0 2px var(--ui-line);
}

:root[data-theme="dark"] .table-wrap {
  background: var(--ui-lilac-deep);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.table-wrap th,
.table-wrap td {
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-text) 15%, transparent);
}

.table-wrap th {
  background: color-mix(in srgb, var(--ui-yellow) 35%, transparent);
  border-bottom: var(--ui-border);
}

:root[data-theme="dark"] .table-wrap th {
  background: color-mix(in srgb, var(--ui-lilac) 28%, transparent);
}

.table-wrap tr:last-child td {
  border-bottom: 0;
}

/* 程式碼貼紙 */
.code {
  margin: 1.9em 0;
  padding: 0;
  overflow: visible;
}

.code figcaption {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 0;
}

.code-tape {
  position: absolute;
  left: 14px;
  top: -14px;
  padding: 1px 12px;
  rotate: -2deg;
  border-left: 2px dashed rgba(0, 0, 0, 0.12);
  border-right: 2px dashed rgba(0, 0, 0, 0.12);
  background: color-mix(in srgb, var(--ui-accent) 85%, transparent);
  color: var(--ui-on-color);
  font-family: "Space Grotesk", var(--ui-font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.code-copy {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 1;
  border: 1.5px solid var(--ui-line);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

:root[data-theme="dark"] .code-copy {
  background: var(--ui-sky);
  color: var(--ui-on-color);
}

.code:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .code-copy {
    opacity: 1;
  }
}

.code pre {
  margin: 0;
  padding: 24px 18px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 4;
}

.code pre code {
  background: none;
}

/* 程式碼語法顏色：淺色 */
.hljs-comment,
.hljs-quote {
  color: #7a7466;
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-literal {
  color: #b4235a;
  font-weight: 700;
}
.hljs-string,
.hljs-regexp,
.hljs-attr,
.hljs-symbol {
  color: #17795e;
}
.hljs-number,
.hljs-variable,
.hljs-template-variable {
  color: #a0560b;
}
.hljs-title,
.hljs-function .hljs-title,
.hljs-section,
.hljs-name {
  color: #2d54b8;
  font-weight: 700;
}
.hljs-type,
.hljs-class .hljs-title,
.hljs-meta {
  color: #6c46c7;
}

/* 程式碼語法顏色：深色 */
:root[data-theme="dark"] .hljs-comment,
:root[data-theme="dark"] .hljs-quote {
  color: #a39cb3;
}
:root[data-theme="dark"] .hljs-keyword,
:root[data-theme="dark"] .hljs-selector-tag,
:root[data-theme="dark"] .hljs-built_in,
:root[data-theme="dark"] .hljs-literal {
  color: #ff9cb8;
}
:root[data-theme="dark"] .hljs-string,
:root[data-theme="dark"] .hljs-regexp,
:root[data-theme="dark"] .hljs-attr,
:root[data-theme="dark"] .hljs-symbol {
  color: #8ee6c8;
}
:root[data-theme="dark"] .hljs-number,
:root[data-theme="dark"] .hljs-variable,
:root[data-theme="dark"] .hljs-template-variable {
  color: #ffd27a;
}
:root[data-theme="dark"] .hljs-title,
:root[data-theme="dark"] .hljs-function .hljs-title,
:root[data-theme="dark"] .hljs-section,
:root[data-theme="dark"] .hljs-name {
  color: #a8d4ff;
}
:root[data-theme="dark"] .hljs-type,
:root[data-theme="dark"] .hljs-class .hljs-title,
:root[data-theme="dark"] .hljs-meta {
  color: #cdbcff;
}

/* 上一篇 / 下一篇 */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 56px;
}

.pager-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pager-next {
  text-align: right;
}

.pager-label {
  color: var(--ui-text-sub);
  font-size: 13px;
  font-weight: 700;
}

.pager-title {
  font-weight: 700;
  line-height: 1.4;
}

.not-found .ui-button {
  margin: 8px 8px 0 0;
}

.foot {
  max-width: 1040px;
  margin: 72px auto 0;
  padding: 24px 24px 40px;
  color: var(--ui-text-sub);
  font-size: 13px;
}

.foot a {
  text-underline-offset: 3px;
}

/* 手機 */
@media (max-width: 720px) {
  .wrap {
    padding: 0 16px;
  }

  .year {
    display: block;
    margin-top: 40px;
  }

  .year-num {
    position: static;
    margin-bottom: 8px;
    font-size: 44px;
  }

  .rows li {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 46px 1fr;
    gap: 10px;
  }

  .row-tags {
    justify-content: flex-start;
    max-width: none;
    padding-left: 56px;
  }

  .prose {
    font-size: 16px;
  }

  .code {
    margin-left: -4px;
    margin-right: 4px;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: left;
  }
}
