/* ============================================================
   CSS 17.04 — Valid and invalid fields
   ============================================================
   The HTML gives the rules:
     type="email"           → must look like an email
     required               → must not be empty
     pattern="[0-9]{10}"    → exactly 10 digits
   CSS styles the result:
     :user-invalid  → the user typed and left the field, and it is WRONG
     :user-valid    → the user typed and left the field, and it is RIGHT
   (:invalid / :valid also exist, but they turn red BEFORE the user types
    anything — that feels unfriendly, so :user-invalid is better.)
   ============================================================ */

.check-form input:user-invalid {
  border-color: #E54B4F;
  background-color: #FDECEC;
}

.check-form input:user-valid {
  border-color: #1F9D55;
}

.check-form input:user-valid + .hint {
  display: none;
}

.hint {
  display: none;                    /* hidden at first */
  color: #E54B4F;
  font-size: 14px;
  margin: 4px 0 0;
}

.check-form input:user-invalid + .hint {
  display: block;                   /* show the message right after a wrong field */
}

.check-form label:has(+ input:user-valid)::after {
  content: " ✓";
  color: #1F9D55;
}
/* Try it: change pattern="[0-9]{10}" in the HTML to pattern="[0-9]{6}"
   → now a 6-digit PIN code is valid instead. */


/* ------------------------------------------------------------
   Only to make the form visible — not part of this lesson
   ------------------------------------------------------------ */
body { font-family: Arial, sans-serif; font-size: 17px; }
.check-form { max-width: 380px; }
.check-form label { display: block; font-weight: bold; margin: 16px 0 6px; }
.check-form input {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 2px solid #C9C9C9;
  border-radius: 8px;
}
