/* share.bactt.id.vn — hướng "Registry": sổ đăng ký theo ngày.
   Token và lý do đằng sau từng lựa chọn nằm trong DESIGN.md. */

/* ---------- Chữ: tự phục vụ, chỉ lấy subset latin + vietnamese ---------- */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/archivo-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plexmono-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plexmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Token ---------- */
:root {
  color-scheme: light;

  /* Nền trắng. Đường kẻ phải đậm hơn một chút so với bản nền giấy cũ, vì trên nền trắng
     đường kẻ mảnh mất độ tương phản — chúng vẫn là thứ mang kết cấu của cả trang. */
  --paper: #FFFFFF;
  --paper-2: #F7F7F4;
  --ink: #12110F;
  --ink-2: #6E6B63;
  --rule: #D4D1CA;
  --rule-2: #EAE8E3;
  --signal: #C8102E;

  --rail: 140px;
  --gutter: 40px;
  --gap: 32px;
  --maxw: 1180px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --t-wordmark: clamp(20px, 2.2vw, 25px);
  --t-day: 20px;
  --t-title: 15px;
  --t-body: 17px;
  --t-ui: 14px;
  --t-meta: 12.5px;
  --t-file: 13px;
}

/* Giao diện chỉ có một bản sáng (theo yêu cầu). Bảng màu tối trước đây được ghi lại trong
   DESIGN.md — cần bật lại thì thêm khối `:root[data-theme="dark"] { ... }` với các giá trị đó. */

/* ---------- Nền ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body) / 1.65 var(--font);
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); }

/* ---------- Đầu trang ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.top-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-block: 14px;
}

.wordmark { margin: 0; font-size: var(--t-wordmark); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.wordmark a { text-decoration: none; }
.wordmark-domain {
  margin-left: 10px;
  font: 400 var(--t-meta) / 1 var(--mono);
  font-weight: 400;
  letter-spacing: .01em;
  color: var(--ink-2);
}

.gauge { display: flex; align-items: center; gap: 12px; margin: 0; font: 400 var(--t-meta) / 1 var(--mono); color: var(--ink-2); }
.gauge-track { display: block; width: 88px; height: 4px; background: var(--rule-2); border: 1px solid var(--rule); }
.gauge-fill { display: block; width: 0; height: 100%; background: var(--ink); transition: width 420ms var(--ease); }
.gauge.is-tight .gauge-fill { background: var(--signal); }
.gauge.is-tight .gauge-text { color: var(--signal); }

/* ---------- Khối ---------- */
.block-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 48px 0 0;
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.3;
}
.block-title::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

.note { margin: 12px 0 0; max-width: 60ch; font-size: var(--t-ui); color: var(--ink-2); }
.empty { margin: 24px 0 0; font-size: var(--t-ui); color: var(--ink-2); }

/* Ô soạn nằm trên một dải xám rất nhạt, tràn hết bề ngang cột nội dung — trên nền trắng thì
   đây là chỗ duy nhất được tô nền, để mắt thấy ngay "ô để nhập" mà không cần đến cái hộp. */
.block--composer {
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  background: var(--paper-2);
  border-block: 1px solid var(--rule);
}

/* ---------- Hàng trên lưới ---------- */
.entry {
  position: relative;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: var(--gap);
  padding-block: 28px;
}
.entry::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--rule);
}
.block--composer .entry::before { display: none; }

/* ---------- Rail: xương sống thời gian ---------- */
.rail { display: flex; flex-direction: column; gap: 1px; }
.rail-day { margin: 0; font-size: var(--t-day); font-weight: 600; line-height: 1.05; }
.rail-my, .rail-time { margin: 0; font: 400 var(--t-meta) / 1.45 var(--mono); color: var(--ink-2); }

.rail-life { position: relative; margin: 12px 0 0; height: 2px; background: var(--rule-2); }
.rail-life-fill { position: absolute; inset: 0 auto 0 0; width: var(--life, 100%); background: var(--ink); }

.entry.is-soon .rail-life-fill { background: var(--signal); }
.entry.is-soon .entry-state { color: var(--signal); }
.entry.is-trash { background: color-mix(in srgb, var(--signal) 5%, transparent); }
.entry.is-trash .rail-life-fill { background: var(--signal); }
.entry.is-trash .entry-state { color: var(--signal); }

/* ---------- Nội dung ---------- */
.body { min-width: 0; }

.entry-text {
  max-width: 66ch;
  margin: 0 0 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.entry-text.is-clamped { max-height: calc(1.65em * 18); overflow: hidden; }
.entry-text > a { text-decoration-color: var(--ink-2); }

.more { margin: -8px 0 16px; padding-inline: 0; color: var(--ink-2); font-weight: 400; }

.entry-media { display: grid; gap: 20px; margin: 0 0 16px; }
.media-item { display: grid; gap: 8px; justify-items: start; }
.media-item img {
  max-width: 100%;
  max-height: 62vh;
  width: auto;
  height: auto;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  display: block;
}
.media-dl { font: 400 var(--t-meta) / 1.4 var(--mono); color: var(--ink-2); }

.files { margin: 0 0 16px; padding: 0; list-style: none; border-top: 1px solid var(--rule-2); }
.file {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-2);
}
.file:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.file-name {
  font: 400 var(--t-file) / 1.4 var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-name a { text-decoration: none; }
.file-name a::after { content: ''; position: absolute; inset: 0; }
.file-name a:hover { text-decoration: underline; }
.file-size { font: 400 var(--t-meta) / 1.4 var(--mono); color: var(--ink-2); }

.entry-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.entry-state { margin: 0; font: 400 var(--t-meta) / 1.45 var(--mono); color: var(--ink-2); }
.entry-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 180ms var(--ease); }
.entry:hover .entry-actions,
.entry:focus-within .entry-actions { opacity: 1; }

/* ---------- Điều khiển ---------- */
.btn {
  appearance: none;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: 600 var(--t-ui) / 1 var(--font);
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: progress; }

.btn-solid { padding-inline: 20px; background: var(--ink); color: var(--paper-2); }
.btn-solid:hover { background: color-mix(in srgb, var(--ink) 84%, var(--signal)); }
.btn-outline { border: 1px solid var(--rule); }
.btn-quiet { padding-inline: 8px; color: var(--ink-2); font-weight: 500; }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { color: var(--signal); }
.btn-danger:hover { background: color-mix(in srgb, var(--signal) 12%, transparent); color: var(--signal); }

/* ---------- Ô soạn ---------- */
.input {
  display: block;
  width: 100%;
  min-height: 78px;
  max-height: 46vh;
  padding: 8px 0 14px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  color: inherit;
  font: 400 var(--t-body) / 1.6 var(--font);
  resize: none;
  overflow-y: auto;
}
.input::placeholder { color: var(--ink-2); }
.input:focus-visible { outline: none; border-bottom-color: var(--ink); box-shadow: 0 1px 0 0 var(--ink); }

.composer-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { font: 400 var(--t-meta) / 1.4 var(--mono); color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 4px 4px 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
}
.chip-name { font: 400 var(--t-meta) / 1.6 var(--mono); max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-size { font: 400 var(--t-meta) / 1.6 var(--mono); color: var(--ink-2); }
.chip-drop { padding: 2px 6px; font-size: var(--t-meta); }

.problem { margin: 12px 0 0; font-size: var(--t-ui); color: var(--signal); }
.progress { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; }
.progress-track { flex: 1; height: 2px; background: var(--rule-2); }
.progress-fill { display: block; width: var(--p, 0%); height: 100%; background: var(--ink); transition: width 120ms linear; }
.progress-text { font: 400 var(--t-meta) / 1 var(--mono); color: var(--ink-2); white-space: nowrap; }

.entry--composer.is-drag { background: color-mix(in srgb, var(--ink) 6%, var(--paper-2)); }

/* ---------- Chân trang, thông báo ---------- */
.foot { margin: 64px auto 48px; font: 400 var(--t-meta) / 1.6 var(--mono); color: var(--ink-2); }

.toast {
  position: fixed;
  left: var(--gutter);
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(90vw, 46ch);
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-size: var(--t-ui);
}

/* ---------- Chuyển động: đúng một khoảnh khắc ---------- */
@keyframes draw-rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.entry.is-new::before { transform-origin: left; animation: draw-rule 420ms var(--ease) both; }
.entry.is-new .rail,
.entry.is-new .body { animation: settle 420ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Điện thoại: rail gập thành dải ngang ---------- */
@media (max-width: 700px) {
  :root { --gutter: 20px; --gap: 12px; --t-body: 16px; }

  .entry { grid-template-columns: minmax(0, 1fr); padding-block: 22px; }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 12px; }
  .rail-life { flex: 1 0 100%; margin: 8px 0 0; }
  .rail-day { font-size: 18px; }

  .entry-text { max-width: none; }
  .entry-actions { opacity: 1; }
  .btn { min-height: 44px; padding-inline: 14px; }
  .btn-quiet { padding-inline: 10px; }
  .more { min-height: 36px; margin-top: -4px; }

  .wordmark-domain { display: none; }
  .gauge-track { width: 56px; }
  .block-title { margin-top: 40px; }
  .foot { margin-block: 48px 32px; }
  .toast { left: var(--gutter); right: var(--gutter); bottom: 16px; max-width: none; }
}

@media (hover: none) {
  .entry-actions { opacity: 1; }
}
