/* --- リセットCSS & ボックスモデル --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box; /* padding/borderを幅に含める */
}

/* --- CSS変数 --- */
:root {
  --main-color: #3498db;
  --accent-color: #e74c3c;
  --base-spacing: 16px;
}

body {
  padding: 20px;
  font-family: sans-serif;
  line-height: 1.6;
}

section {
  margin-bottom: 40px;
}

/* --- 1. セレクタと優先順位 --- */
p {
  color: red;
}

.title {
  color: blue;
}

#main {
  color: green;
}

.parent p {
  font-weight: bold;
}

.hover-link:hover {
  color: var(--accent-color);
  text-decoration: none;
}

/* --- 2. ボックスモデルと余白 --- */
.box-container {
  background-color: #eee;
  display: inline-block;
  border: 1px solid #ccc;
}

.box-margin {
  background-color: red;
  border: solid 3px black;
  width: 100px;
  height: 100px;
  margin: 10px; /* 外側の余白 */
  color: white;
}

.box-padding {
  background-color: blue;
  border: solid 3px yellow;
  width: 100px;
  height: 100px;
  padding: 10px; /* 内側の余白 */
  color: white;
}

/* --- 3. レイアウト共通パーツ --- */
.child {
  width: 100px;
  height: 100px;
  background: linear-gradient(-45deg, #788cff, #b4c8ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 1px solid #fff;
}

/* Flexbox */
.flex-container {
  display: flex;
  border: solid 3px #ccc;
  margin-bottom: 10px;
}

.flex-container.center {
  justify-content: center;
}

.flex-container.column {
  flex-direction: column;
}

/* --- 4. Grid --- */
.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr; /* 3列 */
  gap: 10px;
  border: solid 3px #ccc;
  justify-items: center;
}

/* --- 5. アニメーション --- */

/* Transition */
.button {
  padding: 10px 20px;
  background-color: var(--main-color);
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s;
}

.button:hover {
  background-color: var(--accent-color);
  transform: scale(1.05);
}

/* Keyframes */
@keyframes float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

.floating-card {
  width: 200px;
  padding: 20px;
  margin-top: 20px;
  background: white;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  text-align: center;
  animation: float 3s ease-in-out infinite;
}

/* --- 6. 疑似要素 --- */
.pseudo-title {
  position: relative;
  padding-left: 15px;
  margin-top: 20px;
}

.pseudo-title::before {
  content: "";
  position: absolute;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: var(--main-color);
}

a[target="_blank"]::after {
  content: " (外部サイトへ)";
  font-size: 0.8em;
  color: #888;
}

/* --- 7. メディアクエリ --- */
@media screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
  .mq-text::after {
    content: " ★現在モバイル表示です";
    color: blue;
    font-weight: bold;
  }
}
