@import url('https://fonts.googleapis.com/css2?family=DotGothic16&display=swap');

:root{
  --bg: #000;
  --fg: #88ff00;

  /* JSでスクロール速度に応じて変化（位置は動かさない） */
  --noise-o: .18;
  --flicker-o: .24;
  --scan-o: .55;
}


*{ box-sizing: border-box; }
html,body{ height: 100%; }

body{
  margin: 0;
  background: #fff;
  color: var(--fg);
  font-family: "DotGothic16", sans-serif;
  font-weight: 400;
  font-style: normal;
  overflow-x: hidden;
}

h3 {
    padding: 0;
    margin: 0;
}

#bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: url(/images/bg.webp);
    z-index: -1;
    background-size: 3500px;
}

.page{ min-height: 100vh; }

/* 画面中央固定 */
.stage{
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
}

.window{
  width: min(980px, 90vw);
  border: 1px solid rgba(136,255,0,.22);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,.78);
}

.titlebar{
  height: 44px;
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: center;
  padding: 0 14px;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.dots{ display:flex; gap:8px; }
.dot{ width:12px; height:12px; border-radius:999px; opacity:.9; }
.dot.red{ background:#ff5f57; }
.dot.yellow{ background:#febc2e; }
.dot.green{ background:#28c840; }

.title{
  justify-self: center;
  font-size: 12px;
  letter-spacing: .02em;
  color: rgba(255,255,255,.55);
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}

/* ===== Terminal（高さ固定） ===== */
.terminal{
  position: relative;
  height: 70vh;
  background: #000;
  overflow: hidden;
  filter: contrast(1.18) saturate(1.15);
}

/* 内部スクロール禁止の“窓” */
.terminal-viewport{
  position: relative;
  height: 100%;
  overflow: hidden;

  /* 最終行が切れない安全地帯 */
  padding: 22px 20px 56px;

  z-index: 2;
}

.terminal-content{
  will-change: transform;
}

.terminal-text{
  line-height: 1.6;
  text-shadow:
    0 0 18px rgba(136,255,0,.22),
    0 0 6px rgba(136,255,0,.22),
    0 0 2px rgba(136,255,0,.22);
}

/* ブロック間を少し空ける（端末ログ感） */
.t_write{
    display: block;
}

/* preは整形保持 */
pre.t_write{
  white-space: pre-wrap;
}

/* pは自然改行でもOK（日本語の段落向け） */
p.t_write{
  white-space: normal;
}

/* タイプが進んだ瞬間だけ発光を増やす（ブレ無し） */
.terminal.type-pulse .terminal-text{
  text-shadow:
    0 0 28px rgba(136,255,0,.35),
    0 0 10px rgba(136,255,0,.30),
    0 0 2px rgba(136,255,0,.28);
}

/* Fallout風: ブロックカーソル */
.cursor{
  display: inline-block;
  width: .72ch;
  height: 1.1em;
  vertical-align: -0.2em;
  margin-left: .1ch;
  background: var(--fg);
  box-shadow:
    0 0 18px rgba(136,255,0,.42),
    0 0 2px rgba(136,255,0,.40);
  animation: blink 0.78s steps(1,end) infinite;
}
@keyframes blink{
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* アクティブなブロックのカーソルだけ表示 */
.t_write:not(.is-active) .cursor{
  opacity: 0;
  animation: none;
}

/* リンク色指定（要望どおり） */
.terminal-text a{
  color: #fff;
  text-decoration: underline;
}
.terminal-text a:visited{
  color: #fff;
}
.terminal-text a:hover{
  color: #f00;
}

/* ===== FX overlays ===== */
.fx{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 3;
}

.scanline{
  opacity: var(--scan-o);
  mix-blend-mode: overlay;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0),
    rgba(136,255,0,.08),
    rgba(0,0,0,0)
  );
  height: 180px;
  width: 100%;
  top: -200px;
  animation: scanMove 2.2s linear infinite;
}
@keyframes scanMove{
  0%{ transform: translateY(-220px); }
  100%{ transform: translateY(calc(100% + 220px)); }
}

.noise{
  opacity: var(--noise-o);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27240%27%20height%3D%27240%27%3E%3Cfilter%20id%3D%27n%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%270.85%27%20numOctaves%3D%274%27%20stitchTiles%3D%27stitch%27/%3E%3C/filter%3E%3Crect%20width%3D%27240%27%20height%3D%27240%27%20filter%3D%27url(%23n)%27%20opacity%3D%270.55%27/%3E%3C/svg%3E");
  background-size: 280px 280px;
  animation: noiseShift .22s steps(2,end) infinite;
}
@keyframes noiseShift{
  0%{ background-position: 0 0; }
  100%{ background-position: 280px -140px; }
}

/* CRT演出 */
.crt::before,
.crt::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 4;
}

.crt::before{
  opacity: .55;
  background:
    radial-gradient(1200px 800px at 50% 35%, rgba(136,255,0,.10), rgba(0,0,0,0) 60%),
    radial-gradient(900px 700px at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.65) 100%),
    linear-gradient(rgba(255,255,255,0.04) 50%, rgba(0,0,0,0.10) 50%);
  background-size: auto, auto, 100% 3px;
  mix-blend-mode: overlay;
}

.crt::after{
  opacity: var(--flicker-o);
  background:
    linear-gradient(90deg,
      rgba(255,0,0,0.06),
      rgba(0,255,0,0.03),
      rgba(0,0,255,0.06)
    );
  mix-blend-mode: overlay;
  animation: flicker 4.8s infinite;
}
@keyframes flicker{
  0%{ opacity: calc(var(--flicker-o) * .75); }
  6%{ opacity: calc(var(--flicker-o) * 1.35); }
  9%{ opacity: calc(var(--flicker-o) * .7); }
  15%{ opacity: calc(var(--flicker-o) * 1.2); }
  38%{ opacity: calc(var(--flicker-o) * .85); }
  61%{ opacity: calc(var(--flicker-o) * 1.4); }
  77%{ opacity: calc(var(--flicker-o) * .8); }
  100%{ opacity: calc(var(--flicker-o) * 1.0); }
}

/* ページスクロール量生成（JSが上書き） */
.scroll-pad{
  height: 200vh;
}

strong {
    font-size: 150%;
    font-weight: normal;
    border-bottom: 1px solid #fff;
}



/* これが“線ブロック” */
.t_rule {
  position: relative;
  height: 1px;
  margin: 12px 0;
  padding: 0 20px;
}

/* 本体は疑似要素で作ると transform が楽 */
.t_rule::before{
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 90vw;          /* 画面幅いっぱい */
  height: 1px;
  background: #88ff00;      /* 好きな色に */
  transform-origin: left center;
  transform: translateX(-50%) scaleX(var(--p, 0)); /* 0→1で伸びる */
}

.wp_works {
}
.wp_works .list {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.wp_works .list .cell{
  width: 49%;
  margin-bottom: 20px;
  padding: 20px;
  position: relative;
}

/* ===== スクロール到達で“枠線を描く” =====
   borderはアニメしづらいので、疑似要素の4辺を順に伸ばして描画する
*/
.wp_works .list .cell::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  will-change: background-size;
  background:
    linear-gradient(#88ff00, #88ff00) left top / 0 1px no-repeat,
    linear-gradient(#88ff00, #88ff00) right top / 1px 0 no-repeat,
    linear-gradient(#88ff00, #88ff00) right bottom / 0 1px no-repeat,
    linear-gradient(#88ff00, #88ff00) left bottom / 1px 0 no-repeat;
}

.wp_works .list .cell.is-inview::after{
  opacity: 1;
  animation: cellBorderDraw .75s ease forwards;
}

/* 上に戻った時は“逆に消える” */
.wp_works .list .cell.is-outview::after{
  opacity: 1;
  animation: cellBorderErase .75s ease forwards;
}

@keyframes cellBorderDraw{
  0%   { background-size: 0 1px, 1px 0, 0 1px, 1px 0; }
  25%  { background-size: 100% 1px, 1px 0, 0 1px, 1px 0; }
  50%  { background-size: 100% 1px, 1px 100%, 0 1px, 1px 0; }
  75%  { background-size: 100% 1px, 1px 100%, 100% 1px, 1px 0; }
  100% { background-size: 100% 1px, 1px 100%, 100% 1px, 1px 100%; }
}

@keyframes cellBorderErase{
  /* Drawの逆再生: 左 -> 下 -> 右 -> 上 の順で消える */
  0%   { opacity: 1; background-size: 100% 1px, 1px 100%, 100% 1px, 1px 100%; }
  25%  { opacity: 1; background-size: 100% 1px, 1px 100%, 100% 1px, 1px 0; }
  50%  { opacity: 1; background-size: 100% 1px, 1px 100%, 0 1px, 1px 0; }
  75%  { opacity: 1; background-size: 100% 1px, 1px 0, 0 1px, 1px 0; }
  100% { opacity: 0; background-size: 0 1px, 1px 0, 0 1px, 1px 0; }
}

@media (prefers-reduced-motion: reduce){
  .wp_works .list .cell.is-inview::after{
    animation: none;
    background-size: 100% 1px, 1px 100%, 100% 1px, 1px 100%;
  }

  .wp_works .list .cell.is-outview::after{
    animation: none;
    opacity: 0;
    background-size: 0 1px, 1px 0, 0 1px, 1px 0;
  }
}
.wp_works .list .cell h3 {
    margin-bottom: -2px;
}
.wp_works .list .cell p {
    color: rgba(255, 255, 255, .4);
    margin: 0;
    padding: 0;
}
