/*ヘッダー*/
header{
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 20px 40px;

    background-color: var(--header-bg);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    /* テーマ切り替えのフェード。時間は base.css の :root で一括管理。 */
    transition: background-color var(--theme-fade);

    position: fixed;
    top: 0;
    left: 0;
    width: 100%;

    box-sizing: border-box;

    z-index: 100;
}

nav ul{
    display: flex;
    gap: 30px;

    list-style: none;
    margin: 0;
    padding: 0;
}

nav a{
    text-decoration: none;
    color: var(--text-color);

    transition: color var(--theme-fade);
}
/*ヘッダー：ダークモード*/
.theme-switch{
    position: relative;
}

.theme-switch__input{
    display: none;
}

.theme-switch__label{
    position: relative;

    display: block;

    width: 70px;
    height: 35px;

    border-radius: 50px;

    /* ライトモード時のトラック(溝)の色。ダークは下の :checked 側。 */
    background-color: #FFEF6C;

    cursor: pointer;

    transition: .3s;
}

/* ▼ 太陽と月はトラックの中に置き、今のモードのほうを見せる

     つまみ(span)は 29px 幅で、左端3px から始まり、
     押すと 35px 右へ動く。つまり覆う範囲はこうなる。

       ライト(つまみ左)  3px 〜 32px   → 左の月が隠れ、右の太陽が見える
       ダーク(つまみ右) 38px 〜 67px   → 右の太陽が隠れ、左の月が見える

     ★左を月、右を太陽にしているのはこのため(並びは base.html)。
       逆にすると「これから切り替わる先」が見える形になる。

   ★位置を left/right + width: 29px + text-align: center で決めている理由

     つまみが覆う範囲とぴったり同じ大きさの箱を作り、その中で中央ぞろえにしている。
     こうするとアイコンの字幅がどうであれ
     ・必ず範囲の中央に来る
     ・隠れるべきときに端から覗かない
     の2つが保証される。字の左端を left: 9px のように直接指定すると、
     アイコンを差し替えるたびに調整が要る。

   ★縦位置は top: 50% + translateY(-50%) でトラックの中央に合わせる。

     文字の ☀ ☾ を使っていたときは 47%(中央より約1px上)にしてあったが、
     アイコンに変えたら上に寄って見えたので、計算どおりの中央に戻した。

     ★上下にずらしたいときは translateY の値で調整する。
         transform: translateY(calc(-50% + 1px));   1px下げる
         transform: translateY(calc(-50% - 1px));   1px上げる
       top の % をいじるより、何px動かしたいのかが読んで分かる。 */
.theme-switch__moon,
.theme-switch__sun{
    position: absolute;
    top: 50%;

    width: 29px;
    text-align: center;

    transform: translateY(-50%);

    font-size: 14px;

    /* ★つまみに隠れている側をクリックできてしまわないようにする。
         label の中なので押せば切り替わるが、
         アイコンの上だけカーソルが変わるのを防ぐ意味もある。 */
    pointer-events: none;
}

/* ダーク時に見える側。トラックの #64748b に対してコントラスト比 4.8。 */
.theme-switch__moon{
    left: 3px;

    color: #ffffff;
}

/* ★ライト時に見える側。
     白のままだとトラックの #FFEF6C に対して 1.2 しかなく、ほぼ同化する。
     濃いアンバーにして 6.0 を確保している。 */
.theme-switch__sun{
    right: 3px;

    color: #92400e;
}

.theme-switch__label span{
    position: absolute;

    top: 3px;
    left: 3px;

    width: 29px;
    height: 29px;

    border-radius: 50%;

    background-color: white;

    transition: .3s;

    box-shadow: 0 2px 8px rgba(0,0,0,.25);

    /* ★つまみを必ずアイコンより前に出すための保険。
         位置を指定した要素どうしは、指定が無ければ「後に書いたほうが上」になる。
         今は base.html でアイコン→つまみの順に並べてあるので効いているが、
         順番を入れ替えるとアイコンが白いつまみを突き抜ける。 */
    z-index: 1;
}

/* ▼ ここから下がダークモード(= つまみが右)のとき

   ★body.dark ではなく :checked を使っているのは、
     つまみの移動やトラックの色と同じ仕組みでそろえるため。
     script.js が body.dark とチェック状態を必ず一緒に切り替えている。

   ★アイコンの色はモードで変えないので、ここには色の指定が無い。
     見えるほうが入れ替わるだけで、それぞれの色は固定でよい。 */
.theme-switch__input:checked
+ .theme-switch__label{
    background-color: #64748b;
}

.theme-switch__input:checked
+ .theme-switch__label span{
    transform: translateX(35px);
}

/*ヘッダー：ハンバーガーメニュー*/
.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 15px;

    width: 40px;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

.hamburger-icon span {
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition:
        transform 0.3s ease,
        background-color var(--theme-fade);
}

.hamburger-icon.open span {
    background-color: white;
}

.hamburger-icon span:first-child {
    opacity: 1;
}

.hamburger-icon.open span:first-child {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-icon.open span:last-child {
    transform: rotate(-45deg) translate(6px, -6px);
}


.menu-links {
    position: fixed;
    top: 0;
    left: 0;

    width: 320px;
    height: 100vh;

    background-color: #737272;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.5s ease,
        visibility 0s linear 0.5s;

    z-index: 1000;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;

    padding-top: 50px;
}

.menu-links h1,
.menu-links li {
    opacity: 0;
    transform: translateY(20px);

    transition:
        opacity 0.4s ease,
        transform 0.4s ease;
}

.menu-links.open h1,
.menu-links.open li {
    opacity: 1;
    transform: translateY(0);
}

.menu-links h1 {
    color: #f9fafb;
    font-size: 3.5rem;
    margin-top: 50px;
    margin-bottom: 40px;
}

.menu-links ul {
    display: flex;
    flex-direction: column;
    align-items: center;
    list-style: none;
    padding: 0;
}

.menu-links a {
    font-size: 1.5rem;
    color: #f9fafb;
    text-decoration: none;
}

.menu-links li {
    list-style: none;
    margin: 20px 0;
}

.menu-links.open {
    opacity: 1;
    visibility: visible;

    transition:
        opacity 0.5s ease,
        visibility 0s linear 0s;
}

.menu-links.open h1 {
    transition-delay: 0s;
}

.menu-links.open li:nth-child(1) {
    transition-delay: 0.07s;
}

.menu-links.open li:nth-child(2) {
    transition-delay: 0.14s;
}

.menu-links.open li:nth-child(3) {
    transition-delay: 0.21s;
}

.menu-links.open li:nth-child(4) {
    transition-delay: 0.28s;
}

.menu-links.open li:nth-child(5) {
    transition-delay: 0.35s;
}

