/* ==========================================================================
   NowReading BookLog — Windows 10 Metro / Modern UI, dark theme

   Metro rules followed throughout: no rounded corners, no shadows, no
   gradients, no translucency. Flat solid tiles, typography-led hierarchy,
   a single accent colour, and content over chrome.
   ========================================================================== */

:root {
  --bg:            #000000;  /* Windows 10 dark: true black background */
  --tile:          #1f1f1f;
  --tile-hover:    #2d2d2d;
  --tile-alt:      #2b2b2b;
  --line:          #3d3d3d;
  --line-strong:   #5a5a5a;

  --text:          #ffffff;
  --text-dim:      #a6a6a6;
  --text-faint:    #767676;  /* Windows disabled-text grey */

  --accent:        #adff2f;
  --accent-hover:  #c1ff5e;
  --accent-press:  #8fd91f;
  /* The accent is a high-luminance lime, so anything sitting on it needs a
     dark foreground — white would be unreadable. */
  --on-accent:     #0d1a00;
  --danger:        #e81123;  /* Windows 10 error red */

  --maxw:          1100px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  /* Segoe UI first, then Windows/macOS Japanese faces. No webfont download. */
  font-family: "Segoe UI", "Segoe UI Variable Text", "Yu Gothic UI", "Meiryo UI",
               Meiryo, "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--on-accent); }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 3rem;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

code {
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
  font-size: .92em;
  background: var(--tile);
  padding: .1em .35em;
}

/* --------------------------------------------------------------- header --
   Metro headers are large and set in a light weight, with tight tracking. */

.site-header { margin-bottom: clamp(1.75rem, 4vw, 2.5rem); }

.site-title {
  margin: 0 0 .25rem;
  font-size: clamp(1.9rem, 5.5vw, 2.9rem);
  font-weight: 200;
  line-height: 1.15;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.site-title__icon { font-size: .8em; }

.site-lead {
  margin: 0;
  color: var(--text-dim);
  font-size: .95rem;
}

/* ---------------------------------------------------------------- form --- */

.loader {
  display: flex;
  gap: 0;
  align-items: flex-start;
  flex-wrap: wrap;
}

.field {
  flex: 1 1 18rem;
  min-width: 0;
}

.field__label {
  display: block;
  font-size: .8rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-bottom: .35rem;
}

/* Flat rectangle with a hard 2px accent border on focus — the Windows 10
   text-box treatment. */
.field__input {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  color: var(--text);
  background: var(--tile);
  border: 2px solid var(--line);
  border-radius: 0;
  transition: border-color .1s linear, background-color .1s linear;
}

.field__input::placeholder { color: var(--text-faint); }

.field__input:hover { border-color: var(--line-strong); }

.field__input:focus {
  outline: none;
  background: #000;
  border-color: var(--accent);
}

.field__note {
  margin: .4rem 0 0;
  font-size: .78rem;
  color: var(--text-faint);
}

.field__note b { color: var(--text-dim); }

.field--invalid .field__input { border-color: var(--danger); }
.field--invalid .field__note  { color: #ff6b74; }

/* --------------------------------------------------------------- button --
   Square, flat, no radius. Accent fill for primary, hairline box otherwise. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1.4rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 400;
  line-height: 1.6;
  text-decoration: none;
  white-space: nowrap;
  background: none;
  border: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: background-color .1s linear, border-color .1s linear, color .1s linear;
}

/* Windows keyboard focus is a hard rectangle, not a soft ring. */
.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* On the accent-filled buttons a white rect would vanish into the lime. */
.btn--primary:focus-visible,
.btn--tweet:focus-visible {
  outline-color: var(--on-accent);
}

.btn--primary {
  align-self: flex-start;
  /* Offset by the label's height (font-size x line-height + margin) so the
     button's top edge lines up with the input's. */
  margin-top: calc(.8rem * 1.6 + .35rem);
  margin-left: .5rem;
  /* Same padding and metrics as .field__input, so both are the same height. */
  padding-block: .6rem;
  font-size: 1rem;
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); border-color: var(--accent-press); }

/* Once the button wraps onto its own line, the alignment offsets become a
   stray gap — make it a full-width block instead. */
@media (max-width: 560px) {
  .btn--primary {
    flex: 1 1 100%;
    margin-top: .6rem;
    margin-left: 0;
  }
}

.btn--primary[aria-busy="true"] {
  color: var(--text-faint);
  background: var(--tile-alt);
  border-color: var(--tile-alt);
  pointer-events: none;
}

.btn--tweet {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.btn--tweet:hover  { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--tweet:active { background: var(--accent-press); border-color: var(--accent-press); }

.btn--ghost {
  color: var(--text-dim);
  background: transparent;
  border-color: var(--line-strong);
}

.btn--ghost:hover { color: #fff; background: var(--tile-hover); border-color: #fff; }

.btn__icon { width: 1em; height: 1em; }

/* ------------------------------------------------------------- progress --
   The Metro indeterminate loader: five dots sweeping across the width. */

.progress {
  position: relative;
  height: 4px;
  margin-top: 1.5rem;
  overflow: hidden;
}

.progress[hidden] { display: none; }

.progress span {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 4px;
  background: var(--accent);
  animation: metro-dots 3s cubic-bezier(.35, 0, .25, 1) infinite;
}

.progress span:nth-child(1) { animation-delay: 0s; }
.progress span:nth-child(2) { animation-delay: .15s; }
.progress span:nth-child(3) { animation-delay: .3s; }
.progress span:nth-child(4) { animation-delay: .45s; }
.progress span:nth-child(5) { animation-delay: .6s; }

@keyframes metro-dots {
  0%   { left: 0;    opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

/* --------------------------------------------------------------- status -- */

.status {
  margin: 1rem 0 0;
  min-height: 1.4rem;
  font-size: .9rem;
  color: var(--text-dim);
}

.status:empty { margin: 0; min-height: 0; }

/* Error uses a solid accent bar on the leading edge — Metro's inline
   notification pattern. */
.status--error {
  color: #fff;
  padding: .7rem .9rem;
  background: var(--tile);
  border-left: 4px solid var(--danger);
}

/* ----------------------------------------------------------------- grid --
   Tiles butt up against each other with a small, even gutter. */

.grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin: 1.5rem 0 0;
  padding: 0;
}

@media (max-width: 460px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ----------------------------------------------------------------- tile -- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--tile);
  border: 2px solid transparent;
  transition: background-color .1s linear, border-color .1s linear;
  animation: tile-in .3s cubic-bezier(.1, .9, .2, 1) both;
}

.card:hover {
  background: var(--tile-hover);
  border-color: var(--line-strong);
}

/* Live tiles depress slightly when pressed. */
.card:active { transform: scale(.985); }

@keyframes tile-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.card__cover {
  position: relative;
  aspect-ratio: 3 / 4;
  margin-bottom: .7rem;
  overflow: hidden;
  background: #000;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card__img[hidden] { display: none; }

/* No cover available: a solid accent tile carrying the title, the way a
   Metro tile falls back to text. */
.card__placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: flex-end;
  padding: .7rem;
  font-size: .78rem;
  line-height: 1.45;
  color: var(--on-accent);
  background: var(--accent);
}

.card--no-cover .card__placeholder { display: flex; }

.card__placeholder span {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Metro labels: small, uppercase, letterspaced — no pill, no border. */
.card__badge {
  display: block;
  margin-bottom: .3rem;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

.card__title {
  margin: 0 0 .8rem;
  font-size: .9rem;
  font-weight: 400;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card__actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card__actions .btn {
  width: 100%;
  padding: .45rem .5rem;
  font-size: .8rem;
}

/* ------------------------------------------------------------- skeleton --
   Flat blocks that pulse. No shimmer sweep — that reads as glassy, not Metro. */

.card--skeleton {
  animation: none;
  pointer-events: none;
}

.card--skeleton:hover {
  background: var(--tile);
  border-color: transparent;
}

.sk {
  background: var(--tile-alt);
  animation: pulse 1.4s steps(2, end) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

.sk--cover { width: 100%; height: 100%; }
.sk--badge { width: 3rem;  height: .7rem; margin-bottom: .45rem; }
.sk--line  { height: .8rem; margin-bottom: .45rem; }
.sk--short { width: 60%; }
.sk--btn   { height: 1.9rem; margin-top: .8rem; }

/* --------------------------------------------------------------- footer -- */

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: .78rem;
  color: var(--text-faint);
}

.site-footer p { margin: .25rem 0; }

/* ------------------------------------------------------------ a11y prefs -- */

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

  .card:active { transform: none; }
}
